comparison dis.c @ 151:6b593ea0ed90

Implement MULU/MULS and DIVU/DIVS
author Mike Pavone <pavone@retrodev.com>
date Thu, 03 Jan 2013 22:07:40 -0800
parents 4a400aec81bb
children afbfb0ac0256
comparison
equal deleted inserted replaced
150:3e68e517cc01 151:6b593ea0ed90
61 } 61 }
62 } 62 }
63 63
64 uint8_t labels = 0; 64 uint8_t labels = 0;
65 uint8_t addr = 0; 65 uint8_t addr = 0;
66 uint8_t only = 0;
66 67
67 int main(int argc, char ** argv) 68 int main(int argc, char ** argv)
68 { 69 {
69 long filesize; 70 long filesize;
70 unsigned short *filebuf; 71 unsigned short *filebuf;
76 filesize = ftell(f); 77 filesize = ftell(f);
77 fseek(f, 0, SEEK_SET); 78 fseek(f, 0, SEEK_SET);
78 filebuf = malloc(filesize); 79 filebuf = malloc(filesize);
79 fread(filebuf, 2, filesize/2, f); 80 fread(filebuf, 2, filesize/2, f);
80 fclose(f); 81 fclose(f);
82 deferred *def = NULL, *tmpd;
81 for(uint8_t opt = 2; opt < argc; ++opt) { 83 for(uint8_t opt = 2; opt < argc; ++opt) {
82 if (argv[opt][0] == '-') { 84 if (argv[opt][0] == '-') {
83 switch (argv[opt][1]) 85 switch (argv[opt][1])
84 { 86 {
85 case 'l': 87 case 'l':
86 labels = 1; 88 labels = 1;
87 break; 89 break;
88 case 'a': 90 case 'a':
89 addr = 1; 91 addr = 1;
90 break; 92 break;
91 } 93 case 'o':
94 only = 1;
95 break;
96 }
97 } else {
98 uint32_t address = strtol(argv[opt], NULL, 16);
99 def = defer(address, def);
100 reference(address);
92 } 101 }
93 } 102 }
94 for(cur = filebuf; cur - filebuf < (filesize/2); ++cur) 103 for(cur = filebuf; cur - filebuf < (filesize/2); ++cur)
95 { 104 {
96 *cur = (*cur >> 8) | (*cur << 8); 105 *cur = (*cur >> 8) | (*cur << 8);
99 uint32_t int_2 = filebuf[0x68/2] << 16 | filebuf[0x6A/2]; 108 uint32_t int_2 = filebuf[0x68/2] << 16 | filebuf[0x6A/2];
100 uint32_t int_4 = filebuf[0x70/2] << 16 | filebuf[0x72/2]; 109 uint32_t int_4 = filebuf[0x70/2] << 16 | filebuf[0x72/2];
101 uint32_t int_6 = filebuf[0x78/2] << 16 | filebuf[0x7A/2]; 110 uint32_t int_6 = filebuf[0x78/2] << 16 | filebuf[0x7A/2];
102 uint16_t *encoded, *next; 111 uint16_t *encoded, *next;
103 uint32_t size; 112 uint32_t size;
104 deferred *def = NULL, *tmpd; 113 if (!def || !only) {
105 def = defer(start, def); 114 def = defer(start, def);
106 def = defer(int_2, def); 115 def = defer(int_2, def);
107 def = defer(int_4, def); 116 def = defer(int_4, def);
108 def = defer(int_6, def); 117 def = defer(int_6, def);
118 }
109 uint32_t address; 119 uint32_t address;
110 while(def) { 120 while(def) {
111 do { 121 do {
112 encoded = NULL; 122 encoded = NULL;
113 address = def->address; 123 address = def->address;