Mercurial > repos > blastem
comparison 68kinst.c @ 79:d212e0cd0b7e
Implement indexed with 8-bit displacement addressing modes in decoder and disassembler
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 21 Dec 2012 22:24:45 -0800 |
parents | 36f1133837d0 |
children | 645fe435cb48 |
comparison
equal
deleted
inserted
replaced
78:463641032588 | 79:d212e0cd0b7e |
---|---|
29 ext = *(++cur); | 29 ext = *(++cur); |
30 dst->params.regs.pri = reg; | 30 dst->params.regs.pri = reg; |
31 dst->params.regs.displacement = sign_extend16(ext); | 31 dst->params.regs.displacement = sign_extend16(ext); |
32 break; | 32 break; |
33 case MODE_AREG_INDEX_MEM: | 33 case MODE_AREG_INDEX_MEM: |
34 //TODO: implement me | 34 #ifdef M68020 |
35 //TODO: implement me for M68020+ support | |
36 #else | |
37 dst->addr_mode = MODE_AREG_INDEX_DISP8; | |
38 dst->params.regs.pri = reg; | |
39 ext = *(++cur); | |
40 dst->params.regs.sec = ext >> 11;//includes areg/dreg bit, reg num and word/long bit | |
41 dst->params.regs.displacement = sign_extend8(ext&0xFF); | |
42 #endif | |
35 break; | 43 break; |
36 case MODE_PC_INDIRECT_ABS_IMMED: | 44 case MODE_PC_INDIRECT_ABS_IMMED: |
37 switch(reg) | 45 switch(reg) |
38 { | 46 { |
39 case 0: | 47 case 0: |
44 case 1: | 52 case 1: |
45 dst->addr_mode = MODE_ABSOLUTE; | 53 dst->addr_mode = MODE_ABSOLUTE; |
46 ext = *(++cur); | 54 ext = *(++cur); |
47 dst->params.immed = ext << 16 | *(++cur); | 55 dst->params.immed = ext << 16 | *(++cur); |
48 break; | 56 break; |
57 case 3: | |
58 #ifdef M68020 | |
59 //TODO: Implement me for M68020+ support; | |
60 #else | |
61 dst->addr_mode = MODE_PC_INDEX_DISP8; | |
62 ext = *(++cur); | |
63 dst->params.regs.sec = ext >> 11;//includes areg/dreg bit, reg num and word/long bit | |
64 dst->params.regs.displacement = sign_extend8(ext&0xFF); | |
65 #endif | |
49 case 2: | 66 case 2: |
50 dst->addr_mode = MODE_PC_DISPLACE; | 67 dst->addr_mode = MODE_PC_DISPLACE; |
51 ext = *(++cur); | 68 ext = *(++cur); |
52 dst->params.regs.displacement = sign_extend16(ext); | 69 dst->params.regs.displacement = sign_extend16(ext); |
53 break; | 70 break; |
65 case OPSIZE_LONG: | 82 case OPSIZE_LONG: |
66 dst->params.immed = ext << 16 | *(++cur); | 83 dst->params.immed = ext << 16 | *(++cur); |
67 break; | 84 break; |
68 } | 85 } |
69 break; | 86 break; |
70 //TODO: implement the rest of these | |
71 } | 87 } |
72 break; | 88 break; |
73 } | 89 } |
74 return cur; | 90 return cur; |
75 } | 91 } |
1145 case MODE_AREG_POSTINC: | 1161 case MODE_AREG_POSTINC: |
1146 return sprintf(dst, "%s (a%d)+", c, decoded->params.regs.pri); | 1162 return sprintf(dst, "%s (a%d)+", c, decoded->params.regs.pri); |
1147 case MODE_AREG_PREDEC: | 1163 case MODE_AREG_PREDEC: |
1148 return sprintf(dst, "%s -(a%d)", c, decoded->params.regs.pri); | 1164 return sprintf(dst, "%s -(a%d)", c, decoded->params.regs.pri); |
1149 case MODE_AREG_DISPLACE: | 1165 case MODE_AREG_DISPLACE: |
1150 return sprintf(dst, "%s (a%d, %d)", c, decoded->params.regs.pri, decoded->params.regs.displacement); | 1166 return sprintf(dst, "%s (%d, a%d)", c, decoded->params.regs.displacement, decoded->params.regs.pri); |
1167 case MODE_AREG_INDEX_DISP8: | |
1168 return sprintf(dst, "%s (%d, a%d, %c%d.%c)", c, decoded->params.regs.displacement, decoded->params.regs.pri, (decoded->params.regs.sec & 0x10) ? 'a': 'd', (decoded->params.regs.sec >> 1) & 0x7, (decoded->params.regs.sec & 1) ? 'l': 'w'); | |
1151 case MODE_IMMEDIATE: | 1169 case MODE_IMMEDIATE: |
1152 case MODE_IMMEDIATE_WORD: | 1170 case MODE_IMMEDIATE_WORD: |
1153 return sprintf(dst, (decoded->params.immed <= 128 ? "%s #%d" : "%s #$%X"), c, decoded->params.immed); | 1171 return sprintf(dst, (decoded->params.immed <= 128 ? "%s #%d" : "%s #$%X"), c, decoded->params.immed); |
1154 case MODE_ABSOLUTE_SHORT: | 1172 case MODE_ABSOLUTE_SHORT: |
1155 return sprintf(dst, "%s $%X.w", c, decoded->params.immed); | 1173 return sprintf(dst, "%s $%X.w", c, decoded->params.immed); |
1156 case MODE_ABSOLUTE: | 1174 case MODE_ABSOLUTE: |
1157 return sprintf(dst, "%s $%X", c, decoded->params.immed); | 1175 return sprintf(dst, "%s $%X", c, decoded->params.immed); |
1158 case MODE_PC_DISPLACE: | 1176 case MODE_PC_DISPLACE: |
1159 return sprintf(dst, "%s (pc, %d)", c, decoded->params.regs.displacement); | 1177 return sprintf(dst, "%s (%d, pc)", c, decoded->params.regs.displacement); |
1178 case MODE_PC_INDEX_DISP8: | |
1179 return sprintf(dst, "%s (%d, pc, %c%d.%c)", c, decoded->params.regs.displacement, (decoded->params.regs.sec & 0x10) ? 'a': 'd', (decoded->params.regs.sec >> 1) & 0x7, (decoded->params.regs.sec & 1) ? 'l': 'w'); | |
1160 default: | 1180 default: |
1161 return 0; | 1181 return 0; |
1162 } | 1182 } |
1163 } | 1183 } |
1164 | 1184 |