7 #define ADS ":::AGSdisas " VERSION " by rofl0r:::"
9 static int usage(char *argv0
) {
10 dprintf(2, ADS
"\nusage:\n%s [-oblf] file.o [file.s]\n"
11 "pass input and optionally output filename.\n"
13 "-o : dump offset comments in disassembly\n"
14 "-b : dump hexadecimal bytecode comments in disassembly\n"
15 "-f : dump informative original fixups section\n"
16 "-l : remove linenumber debug assembly directives [produces smaller files]\n"
21 static void disas(char *o
, char *s
, int flags
) {
26 ASI
*i
= ASI_read_script(f
, &sc
) ? &sc
: 0;
27 dprintf(1, "disassembling %s -> %s", o
, s
);
28 if(!i
|| !ASI_disassemble(f
, i
, s
, flags
)) dprintf(1, " FAIL");
34 int main(int argc
, char**argv
) {
36 while ((c
= getopt(argc
, argv
, "oblf")) != EOF
) switch(c
) {
37 case 'o': flags
|= DISAS_DEBUG_OFFSETS
; break;
38 case 'b': flags
|= DISAS_DEBUG_BYTECODE
; break;
39 case 'l': flags
|= DISAS_SKIP_LINENO
; break;
40 case 'f': flags
|= DISAS_DEBUG_FIXUPS
; break;
41 default: return usage(argv
[0]);
43 if(!argv
[optind
]) return usage(argv
[0]);
44 char *o
= argv
[optind
], *s
, out
[256];
47 snprintf(out
, 256, "%s", o
);
48 out
[l
-1] = 's'; // overflow me!
50 } else s
= argv
[optind
+1];
52 dprintf(2, "error: input and output file (%s) identical!\n", o
);