forked from RebeccaRGB/unununium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
un-disas.c
68 lines (53 loc) · 1.17 KB
/
un-disas.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2008,2009 Segher Boessenkool <[email protected]>
// Licensed under the terms of the GNU GPL, version 2
// http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "types.h"
#include "disas.h"
#define N_MEM 0x400000
static u16 mem[N_MEM];
u8 isVsmile = 0;
u8 verbose = 1;
int main(int argc, char *argv[])
{
FILE *in;
u32 i, n;
int argIdx;
if (argc < 2) {
fprintf(stderr, "usage: %s <rom-file> [-vsmile] [-minimal]\n", argv[0]);
exit(1);
}
//
if (argc > 2){
for (argIdx=2; argIdx< argc; argIdx++){
if (strcmp("-vsmile", argv[argIdx]) == 0){
isVsmile = 1;
}
else if (strcmp("-minimal", argv[argIdx]) == 0){
verbose = 0;
}
else {
fprintf(stderr,"Invalid argument %s\n", argv[argIdx]);
exit(1);
}
}
}
//
in = fopen(argv[1], "rb");
if (!in) {
perror("Cannot read ROM file");
exit(1);
}
n = fread(mem, 2, N_MEM, in);
fclose(in);
// gross, but whatever. one day i'll fix this, but not today
#ifdef _BIG_ENDIAN
for (i = 0; i < n; i++)
mem[i] = (mem[i] << 8) | (mem[i] >> 8);
#endif
for (i = 0; i < n; )
i += disas(mem, i);
return 0;
}