annotate arm7dis/armdis.c @ 86:537cf2245d98

beginning of ARM7 disassembler
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 28 Mar 2014 07:01:27 +0000
parents
children f7fba8518fa2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <sys/types.h>
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <stdio.h>
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <stdlib.h>
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 extern char *binfilename;
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 extern u_char *filemap;
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 extern u_long disasm_len, base_vma;
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 extern unsigned get_u16(), get_u32();
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 void
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 arm_disasm_line(off)
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 u_long off;
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 {
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 u_long word;
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 word = get_u32(filemap + off);
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 printf("%8x:\t%08x\t", base_vma + off, word);
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 if ((word >> 28) == 0xF) {
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 printf("invalid\n");
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 return;
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 }
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 }
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 main(argc, argv)
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 char **argv;
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 {
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 u_long off;
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 common_init(argc, argv, 4);
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 for (off = 0; off < disasm_len; off += 4)
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 arm_disasm_line(off);
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 exit(0);
537cf2245d98 beginning of ARM7 disassembler
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 }