-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathun-disas.c
45 lines (33 loc) · 805 Bytes
/
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
// 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 "types.h"
#include "disas.h"
#define N_MEM 0x400000
static u16 mem[N_MEM];
int main(int argc, char *argv[])
{
FILE *in;
u32 i, n;
if (argc != 2) {
fprintf(stderr, "usage: %s <rom-file>\n", argv[0]);
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;
}