Motorola M6800 (6800) Exorciser / SWTPC emulator plus 6801 instruction set emulation
修订版 | cc0e06aeb3c9272f68b0f27a7df1e37ab9de3c85 (tree) |
---|---|
时间 | 2020-11-22 17:23:23 |
作者 | Joel Matthew Rees <joel.rees@gmai...> |
Commiter | Joel Matthew Rees |
unasm changed to runtime option for 6801, lightly tested, forgotten
exorsim.c added
@@ -192,9 +192,9 @@ enum { | ||
192 | 192 | ACC, /* Accumulator needed */ |
193 | 193 | ACC1, /* Accumulator optional */ |
194 | 194 | ACCB, /* we need an A or a B: add 0x01 for B */ |
195 | -#ifdef SIM6801 | |
195 | +/* #ifdef SIM6801 */ | |
196 | 196 | ACCD, /* LDD,STD,ADDD,SUBD */ |
197 | -#endif /* def SIM6801 */ | |
197 | +/* #endif / * def SIM6801 */ | |
198 | 198 | NONE /* No operand */ |
199 | 199 | }; |
200 | 200 |
@@ -0,0 +1,28 @@ | ||
1 | +/* Configurations file | |
2 | + * for modifications to Joseph H. Allen's Exorsim | |
3 | + * This file copyright 2020 Joel Matthew Rees | |
4 | + * | |
5 | + * This is free software; you can redistribute it and/or modify it under the | |
6 | + * terms of the GNU General Public License as published by the Free Software | |
7 | + * Foundation; either version 1, or (at your option) any later version. | |
8 | + * | |
9 | + * It is distributed in the hope that it will be useful, but WITHOUT ANY | |
10 | + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
11 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
12 | + * details. | |
13 | + * | |
14 | + * You should have received a copy of the GNU General Public License along with | |
15 | + * this software; see the file COPYING. If not, write to the Free Software Foundation, | |
16 | + * 675 Mass Ave, Cambridge, MA 02139, USA. | |
17 | + */ | |
18 | + | |
19 | + | |
20 | +#define EXORSIM_C | |
21 | + | |
22 | +#include "exorsim.h" | |
23 | + | |
24 | +unsigned cputype = SIM6801; | |
25 | + | |
26 | + | |
27 | + | |
28 | + |
@@ -258,11 +258,11 @@ void show_trace(int insn_no, struct trace_entry *t) | ||
258 | 258 | } case 0x02: /* SBC N,Z,V,C (no H?) */ { |
259 | 259 | insn = "SBC"; |
260 | 260 | break; |
261 | - } case 0x03: /* ACCMD should never get here at run time? */ { | |
261 | + } case 0x03: /* ACCMD should never get here at run time when CPU is 6801? */ { | |
262 | 262 | if (cputype == 0x6800) |
263 | 263 | goto invalid; /* ??? */ |
264 | 264 | else |
265 | - insn = "SUBD***"; | |
265 | + insn = "???SUBD"; | |
266 | 266 | break; |
267 | 267 | } case 0x04: /* AND N,Z,V=0 */ { |
268 | 268 | insn = "AND"; |
@@ -349,31 +349,31 @@ void show_trace(int insn_no, struct trace_entry *t) | ||
349 | 349 | insn = "STS"; |
350 | 350 | break; |
351 | 351 | } case 0x9D: case 0xAD: case 0xBD: /* JSR */ { |
352 | - if (cputype == 0x6800 && t->insn[0] == 0x9D) | |
353 | -{ fputs( "JSR error\n", stderr ); goto invalid16; | |
354 | -} else if (t->cc & 0x80) | |
352 | + if (cputype < 0x6801 && t->insn[0] == 0x9D) | |
353 | + goto invalid16; | |
354 | + else if (t->cc & 0x80) | |
355 | 355 | sprintf(buf3, "EA=%4.4X%s", t->ea, buf_ea); |
356 | 356 | insn = "JSR"; |
357 | 357 | subr = 1; |
358 | 358 | break; |
359 | 359 | } case 0xC3: case 0xD3: case 0xE3: case 0xF3: /* ADDD N,Z,V,C (6801) */ { |
360 | - if (cputype == 0x6800) | |
361 | -{ fputs( "ADDD error\n", stderr ); goto invalid16; | |
362 | -} else if (t->cc & 0x80) | |
360 | + if (cputype < 0x6801) | |
361 | + goto invalid16; | |
362 | + else if (t->cc & 0x80) | |
363 | 363 | sprintf(buf3, "EA=%4.4X%s D=%4.4X", t->ea, buf_ea, t->data); |
364 | 364 | insn = "ADDD"; |
365 | 365 | break; |
366 | 366 | } case 0xCC: case 0xDC: case 0xEC: case 0xFC: /* LDD N,Z,V=0 (6801) */ { |
367 | - if (cputype == 0x6800) | |
368 | -{ fputs( "LDD error\n", stderr ); goto invalid16; | |
369 | -} else if (t->cc & 0x80) | |
367 | + if (cputype < 0x6801) | |
368 | + goto invalid16; | |
369 | + else if (t->cc & 0x80) | |
370 | 370 | sprintf(buf3, "EA=%4.4X%s D=%4.4X", t->ea, buf_ea, t->data); |
371 | 371 | insn = "LDD"; |
372 | 372 | break; |
373 | 373 | } case 0xCD: case 0xDD: case 0xED: case 0xFD: /* STD N,Z,V=0 (6801) */ { |
374 | - if (cputype == 0x6800) | |
375 | -{ fputs( "STD error\n", stderr ); goto invalid16; | |
376 | -} else if (t->cc & 0x80) | |
374 | + if (cputype < 0x6801) | |
375 | + goto invalid16; | |
376 | + else if (t->cc & 0x80) | |
377 | 377 | sprintf(buf3, "EA=%4.4X%s D=%4.4X", t->ea, buf_ea, t->data); |
378 | 378 | insn = "STD"; |
379 | 379 | break; |
@@ -389,7 +389,6 @@ void show_trace(int insn_no, struct trace_entry *t) | ||
389 | 389 | break; |
390 | 390 | } default: /* ??? */ { |
391 | 391 | invalid16: |
392 | -fprintf( stderr, "invalid16 from mnemonic: %x\n", t->insn[0] ); | |
393 | 392 | goto invalid; |
394 | 393 | break; |
395 | 394 | } |
@@ -475,16 +474,14 @@ fprintf( stderr, "invalid16 from mnemonic: %x\n", t->insn[0] ); | ||
475 | 474 | insn = "NOP"; |
476 | 475 | break; |
477 | 476 | } case 0x04: /* LSRD N=0,Z,V,C (6801) */ { |
478 | - if (cputype == 0x6800) | |
477 | + if (cputype < 0x6801) | |
479 | 478 | goto invalidinh; |
480 | - else | |
481 | - insn = "LSRD"; | |
479 | + insn = "LSRD"; | |
482 | 480 | break; |
483 | 481 | } case 0x05: /* LSLD N,Z,V,C (6801) */ { |
484 | - if (cputype == 0x6800) | |
482 | + if (cputype < 0x6801) | |
485 | 483 | goto invalidinh; |
486 | - else | |
487 | - insn = "LSLD"; | |
484 | + insn = "LSLD"; | |
488 | 485 | break; |
489 | 486 | } case 0x06: /* TAP (all flags) */ { |
490 | 487 | insn = "TAP"; |
@@ -542,15 +539,13 @@ fprintf( stderr, "invalid16 from mnemonic: %x\n", t->insn[0] ); | ||
542 | 539 | insn = "BRA"; |
543 | 540 | break; |
544 | 541 | } case 0x21: /* BRN (6801) */ { |
545 | - if (cputype == 0x6800) | |
542 | + if (cputype < 0x6801) | |
546 | 543 | goto invalidinh; |
547 | - else { | |
548 | - sprintf(buf + strlen(buf), "%2.2X ", t->insn[1]); | |
549 | - sprintf(operand, " %4.4X", t->pc + 2 + (char)t->insn[1]); | |
550 | - if (t->cc & 0x80) | |
551 | - sprintf(buf3, "EA=%4.4X%s", t->ea, buf_ea); | |
552 | - insn = "BRN"; | |
553 | - } | |
544 | + sprintf(buf + strlen(buf), "%2.2X ", t->insn[1]); | |
545 | + sprintf(operand, " %4.4X", t->pc + 2 + (char)t->insn[1]); | |
546 | + if (t->cc & 0x80) | |
547 | + sprintf(buf3, "EA=%4.4X%s", t->ea, buf_ea); | |
548 | + insn = "BRN"; | |
554 | 549 | break; |
555 | 550 | } case 0x22: /* BHI */ { |
556 | 551 | sprintf(buf + strlen(buf), "%2.2X ", t->insn[1]); |
@@ -675,7 +670,7 @@ fprintf( stderr, "invalid16 from mnemonic: %x\n", t->insn[0] ); | ||
675 | 670 | insn = "PSHB"; |
676 | 671 | break; |
677 | 672 | } case 0x38: /* PULX (6801) */ { |
678 | - if (cputype == 0x6800) | |
673 | + if (cputype < 0x6801) | |
679 | 674 | goto invalidinh; |
680 | 675 | else |
681 | 676 | insn = "PULX"; |
@@ -685,26 +680,23 @@ fprintf( stderr, "invalid16 from mnemonic: %x\n", t->insn[0] ); | ||
685 | 680 | subr = 1; |
686 | 681 | break; |
687 | 682 | } case 0x3A: /* ABX (6801) */ { |
688 | - if (cputype == 0x6800) | |
683 | + if (cputype < 0x6801) | |
689 | 684 | goto invalidinh; |
690 | - else | |
691 | - insn = "ABX"; | |
685 | + insn = "ABX"; | |
692 | 686 | break; |
693 | 687 | } case 0x3B: /* RTI */ { |
694 | 688 | insn = "RTI"; |
695 | 689 | subr = 1; |
696 | 690 | break; |
697 | 691 | } case 0x3C: /* PSHX (6801) */ { |
698 | - if (cputype == 0x6800) | |
692 | + if (cputype < 0x6801) | |
699 | 693 | goto invalidinh; |
700 | - else | |
701 | - insn = "PSHX"; | |
694 | + insn = "PSHX"; | |
702 | 695 | break; |
703 | 696 | } case 0x3D: /* MUL C=accb bit 7 (6801) */ { |
704 | - if (cputype == 0x6800) | |
697 | + if (cputype < 0x6801) | |
705 | 698 | goto invalidinh; |
706 | - else | |
707 | - insn = "MUL"; | |
699 | + insn = "MUL"; | |
708 | 700 | break; |
709 | 701 | } case 0x3E: /* WAI */ { |
710 | 702 | insn = "WAI"; |
@@ -997,7 +989,7 @@ void sim(void) | ||
997 | 989 | } |
998 | 990 | switch (opcode) { |
999 | 991 | case 0x83: case 0x93: case 0xA3: case 0xB3: /* SUBD N,Z,V,C (6801) */ { |
1000 | - if (cputype == 0x6800) { | |
992 | + if (cputype < 0x6801) { | |
1001 | 993 | fprintf( stderr, "Internal error on SUBD (6800)\n" ); |
1002 | 994 | goto invalid16; |
1003 | 995 | } |
@@ -1018,7 +1010,7 @@ void sim(void) | ||
1018 | 1010 | t->ea = ea; t->data = w; |
1019 | 1011 | fw = ix - w; |
1020 | 1012 | z_flag = Z_16(fw); |
1021 | - if (cputype == 0x6800) { | |
1013 | + if (cputype < 0x6801) { | |
1022 | 1014 | f = ( ix >> 8 ) - ( w >> 8 ); |
1023 | 1015 | n_flag = N(f); |
1024 | 1016 | v_flag = V(ix >> 8, w >> 8, f); |
@@ -1048,18 +1040,18 @@ void sim(void) | ||
1048 | 1040 | } |
1049 | 1041 | case 0x9D: /* (6801) */ |
1050 | 1042 | case 0xAD: case 0xBD: /* JSR */ { |
1051 | - if (cputype == 0x6800 && opcode == 0x9D) | |
1052 | -{ fputs( "JSR op error\n", stderr ); goto invalid16; | |
1053 | -} else { | |
1043 | + if (cputype < 0x6801 && opcode == 0x9D) | |
1044 | + goto invalid16; | |
1045 | + else { | |
1054 | 1046 | push2(pc); |
1055 | 1047 | jump(ea); |
1056 | 1048 | t->ea = ea; |
1057 | 1049 | } |
1058 | 1050 | break; |
1059 | 1051 | } case 0xC3: case 0xD3: case 0xE3: case 0xF3: /* ADDD N,Z,V,C (6801) */ { |
1060 | - if (cputype == 0x6800) | |
1061 | -{ fputs( "ADDD op error\n", stderr ); goto invalid16; | |
1062 | -} else { | |
1052 | + if (cputype < 0x6801) | |
1053 | + goto invalid16; | |
1054 | + else { | |
1063 | 1055 | setACCD( accd ); |
1064 | 1056 | w = mread2(ea); |
1065 | 1057 | t->ea = ea; t->data = w; |
@@ -1072,9 +1064,9 @@ void sim(void) | ||
1072 | 1064 | } |
1073 | 1065 | break; |
1074 | 1066 | } case 0xCC: case 0xDC: case 0xEC: case 0xFC: /* LDD N,Z,V=0 (6801) */ { |
1075 | - if (cputype == 0x6800) | |
1076 | -{ fputs( "LDD op error\n", stderr ); goto invalid16; | |
1077 | -} else { | |
1067 | + if (cputype < 0x6801) | |
1068 | + goto invalid16; | |
1069 | + else { | |
1078 | 1070 | accd = mread2(ea); |
1079 | 1071 | t->ea = ea; t->data = accd; |
1080 | 1072 | z_flag = Z_16( accd ); |
@@ -1084,9 +1076,9 @@ void sim(void) | ||
1084 | 1076 | } |
1085 | 1077 | break; |
1086 | 1078 | } case 0xDD: case 0xED: case 0xFD: /* STD N,Z,V=0 (6801) */ { |
1087 | - if (cputype == 0x6800) | |
1088 | -{ fputs( "STD op error\n", stderr ); goto invalid16; | |
1089 | -} else { | |
1079 | + if (cputype < 0x6801) | |
1080 | + goto invalid16; | |
1081 | + else { | |
1090 | 1082 | setACCD( accd ); |
1091 | 1083 | n_flag = N_16( accd ); |
1092 | 1084 | z_flag = Z_16( accd ); |
@@ -1111,8 +1103,6 @@ void sim(void) | ||
1111 | 1103 | break; |
1112 | 1104 | } default: /* ??? */ { |
1113 | 1105 | invalid16: |
1114 | -fprintf( stderr, "invalid16 from opcode: %x => %x\n", t->insn[0], opcode ); | |
1115 | - | |
1116 | 1106 | goto invalid; |
1117 | 1107 | break; |
1118 | 1108 | } |
@@ -1255,7 +1245,7 @@ fprintf( stderr, "invalid16 from opcode: %x => %x\n", t->insn[0], opcode ); | ||
1255 | 1245 | case 0x01: /* NOP */ { /* Do nothing */ |
1256 | 1246 | break; |
1257 | 1247 | } case 0x04: /* LSRD (6801) */ { |
1258 | - if (cputype == 0x6800) | |
1248 | + if (cputype < 0x6801) | |
1259 | 1249 | goto invalidinh; |
1260 | 1250 | else { |
1261 | 1251 | setACCD( accd ); |
@@ -1269,7 +1259,7 @@ fprintf( stderr, "invalid16 from opcode: %x => %x\n", t->insn[0], opcode ); | ||
1269 | 1259 | } |
1270 | 1260 | break; |
1271 | 1261 | } case 0x05: /* LSLD (6801) */ { |
1272 | - if (cputype == 0x6800) | |
1262 | + if (cputype < 0x6801) | |
1273 | 1263 | goto invalidinh; |
1274 | 1264 | else { |
1275 | 1265 | setACCD( accd ); |
@@ -1369,7 +1359,7 @@ fprintf( stderr, "invalid16 from opcode: %x => %x\n", t->insn[0], opcode ); | ||
1369 | 1359 | jump(t->ea = (pc + offset)); |
1370 | 1360 | break; |
1371 | 1361 | } case 0x21: /* BRN (6801) */ { |
1372 | - if (cputype == 0x6800) | |
1362 | + if (cputype < 0x6801) | |
1373 | 1363 | goto invalidinh; |
1374 | 1364 | else { |
1375 | 1365 | offset = fetch(); |
@@ -1485,7 +1475,7 @@ fprintf( stderr, "invalid16 from opcode: %x => %x\n", t->insn[0], opcode ); | ||
1485 | 1475 | push(accb); |
1486 | 1476 | break; |
1487 | 1477 | } case 0x38: /* PULX (6801) */ { |
1488 | - if (cputype == 0x6800) | |
1478 | + if (cputype < 0x6801) | |
1489 | 1479 | goto invalidinh; |
1490 | 1480 | else { |
1491 | 1481 | ix = pull2(); |
@@ -1499,7 +1489,7 @@ fprintf( stderr, "invalid16 from opcode: %x => %x\n", t->insn[0], opcode ); | ||
1499 | 1489 | jump(pull2()); |
1500 | 1490 | break; |
1501 | 1491 | } case 0x3A: /* ABX (6801) */ { |
1502 | - if (cputype == 0x6800) | |
1492 | + if (cputype < 0x6801) | |
1503 | 1493 | goto invalidinh; |
1504 | 1494 | else { |
1505 | 1495 | ix = ix + accb; |
@@ -1513,14 +1503,14 @@ fprintf( stderr, "invalid16 from opcode: %x => %x\n", t->insn[0], opcode ); | ||
1513 | 1503 | jump(pull2()); |
1514 | 1504 | break; |
1515 | 1505 | } case 0x3C: /* PSHX (6801) */ { |
1516 | - if (cputype == 0x6800) | |
1506 | + if (cputype < 0x6801) | |
1517 | 1507 | goto invalidinh; |
1518 | 1508 | else { |
1519 | 1509 | push2(ix); |
1520 | 1510 | } |
1521 | 1511 | break; |
1522 | 1512 | } case 0x3D: /* MUL C=accb bit 7 (6801) */ { |
1523 | - if (cputype == 0x6800) | |
1513 | + if (cputype < 0x6801) | |
1524 | 1514 | goto invalidinh; |
1525 | 1515 | else { |
1526 | 1516 | unsigned product = acca * accb; |
@@ -22,6 +22,7 @@ | ||
22 | 22 | #include <stdlib.h> |
23 | 23 | #include <string.h> |
24 | 24 | |
25 | +#include "exorsim.h" /* JMR20201121 */ | |
25 | 26 | #include "utils.h" |
26 | 27 | #include "unasm6800.h" |
27 | 28 |
@@ -50,6 +51,8 @@ int main(int argc, char *argv[]) | ||
50 | 51 | ++x; |
51 | 52 | char *p = argv[x]; |
52 | 53 | parse_hex(&p, &addr); |
54 | + } else if (!strcmp(argv[x], "--6801")) { | |
55 | + cputype = 0x6801; | |
53 | 56 | } else { |
54 | 57 | err: |
55 | 58 | printf("M6800 unassembler\n"); |
@@ -58,6 +61,7 @@ int main(int argc, char *argv[]) | ||
58 | 61 | printf("\n"); |
59 | 62 | printf(" --facts file Annotate with known facts\n"); |
60 | 63 | printf(" --addr hhhh Starting address of dumpfile\n"); |
64 | + printf(" --6801 Handle additional 6801 instructions\n"); | |
61 | 65 | exit(-1); |
62 | 66 | } |
63 | 67 | } else { |
@@ -267,11 +267,9 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
267 | 267 | sprintf(buf + strlen(buf), "%2.2X ", opcode = mem[pc++]); |
268 | 268 | |
269 | 269 | if (opcode & 0x80) { |
270 | -#ifdef SIM6801 | |
271 | - if ( ((opcode & 0x0F) < 0x0C) && ((opcode & 0x0F) != 0x03) ) { | |
272 | -#else | |
273 | - if ((opcode & 0x0F) < 0x0C) { | |
274 | -#endif /* def SIM6801 */ | |
270 | + unsigned opc_det = opcode & 0x0f; | |
271 | + if ( (cputype < 0x6801 && opc_det < 0x0C) | |
272 | + || (opc_det < 0x0c && opc_det != 0x03) ) { | |
275 | 273 | /* Get operand A */ |
276 | 274 | if (opcode & 0x40) { |
277 | 275 | sprintf(operand, "B"); |
@@ -321,19 +319,12 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
321 | 319 | } case 0x02: /* SBC N,Z,V,C (no H?) */ { |
322 | 320 | insn = "SBC"; |
323 | 321 | break; |
324 | - } | |
325 | -#ifdef SIM6801 | |
326 | - case 0x03: /* ACCMD should never get here at run time. */ { | |
327 | - insn = ""; | |
328 | - break; | |
329 | - } | |
330 | -#else | |
331 | - case 0x03: /* ??? */ { | |
322 | + } case 0x03: /* ACCMD should never get here at run time when CPU is 6801? */ { | |
323 | + if (cputype == 0x6801) | |
324 | + fprintf( stderr, "Internal error on SUBD (6801)\n" ); | |
332 | 325 | insn = "???"; |
333 | 326 | break; |
334 | - } | |
335 | -#endif /* ndef SIM6801 */ | |
336 | - case 0x04: /* AND N,Z,V=0 */ { | |
327 | + } case 0x04: /* AND N,Z,V=0 */ { | |
337 | 328 | insn = "AND"; |
338 | 329 | break; |
339 | 330 | } case 0x05: /* BIT N,Z,V=0*/ { |
@@ -389,13 +380,12 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
389 | 380 | } |
390 | 381 | } |
391 | 382 | switch (opcode) { |
392 | -#ifdef SIM6801 | |
393 | 383 | case 0x83: case 0x93: case 0xA3: case 0xB3: /* SUBD N,Z,V,C (6801) */ { |
394 | - insn = "SUBD"; | |
384 | + /* Should never come here when cputype == 0x6800. */ | |
385 | + /* But if it does, we want to do something defined. */ | |
386 | + insn = (cputype < 0x6801) ? "???SUBD" : "SUBD"; | |
395 | 387 | break; |
396 | - } | |
397 | -#endif /* def SIM6801 */ | |
398 | - case 0x8C: case 0x9C: case 0xAC: case 0xBC: /* CPX N,Z,V */ { | |
388 | + } case 0x8C: case 0x9C: case 0xAC: case 0xBC: /* CPX N,Z,V */ { | |
399 | 389 | insn = "CPX"; |
400 | 390 | break; |
401 | 391 | } case 0x8D: /* BSR REL */ { |
@@ -410,35 +400,36 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
410 | 400 | } case 0x8F: case 0x9F: case 0xAF: case 0xBF: /* STS N,Z,V */ { |
411 | 401 | insn = "STS"; |
412 | 402 | break; |
413 | - } | |
414 | -#ifdef SIM6801 | |
415 | - case 0x9D: /* (6801) */ | |
416 | -#endif /* def SIM6801 */ | |
417 | - case 0xAD: case 0xBD: /* JSR */ { | |
403 | + } case 0x9D: case 0xAD: case 0xBD: /* JSR */ { | |
404 | + if (cputype < 0x6801 && opcode == 0x9D) | |
405 | + goto invalid16; | |
418 | 406 | branch_target = (mem[pc - 2] << 8) + mem[pc - 1]; |
419 | 407 | is_jsr = 1; |
420 | 408 | insn = "JSR"; |
421 | 409 | break; |
422 | - } | |
423 | -#ifdef SIM6801 | |
424 | - case 0xC3: case 0xD3: case 0xE3: case 0xF3: /* ADDD N,Z,V,C (6801) */ { | |
410 | + } case 0xC3: case 0xD3: case 0xE3: case 0xF3: /* ADDD N,Z,V,C (6801) */ { | |
411 | + if (cputype < 0x6801) | |
412 | + goto invalid16; | |
425 | 413 | insn = "ADDD"; |
426 | 414 | break; |
427 | 415 | } case 0xCC: case 0xDC: case 0xEC: case 0xFC: /* LDD N,Z,V=0 (6801) */ { |
416 | + if (cputype < 0x6801) | |
417 | + goto invalid16; | |
428 | 418 | insn = "LDD"; |
429 | 419 | break; |
430 | 420 | } case 0xCD: case 0xDD: case 0xED: case 0xFD: /* STD N,Z,V=0 (6801) */ { |
421 | + if (cputype < 0x6801) | |
422 | + goto invalid16; | |
431 | 423 | insn = "STD"; |
432 | 424 | break; |
433 | - } | |
434 | -#endif /* def SIM6801 */ | |
435 | - case 0xCE: case 0xDE: case 0xEE: case 0xFE: /* LDX N,Z,V */ { | |
425 | + } case 0xCE: case 0xDE: case 0xEE: case 0xFE: /* LDX N,Z,V */ { | |
436 | 426 | insn = "LDX"; |
437 | 427 | break; |
438 | 428 | } case 0xCF: case 0xDF: case 0xEF: case 0xFF: /* STX N,Z,V */ { |
439 | 429 | insn = "STX"; |
440 | 430 | break; |
441 | 431 | } default: /* ??? */ { |
432 | +invalid16: | |
442 | 433 | insn = "???"; |
443 | 434 | break; |
444 | 435 | } |
@@ -520,17 +511,17 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
520 | 511 | case 0x01: /* NOP */ { /* Do nothing */ |
521 | 512 | insn = "NOP"; |
522 | 513 | break; |
523 | - } | |
524 | -#ifdef SIM6801 | |
525 | - case 0x04: /* LSRD N=0,Z,V,C (6801) */ { | |
514 | + } case 0x04: /* LSRD N=0,Z,V,C (6801) */ { | |
515 | + if (cputype < 0x6801) | |
516 | + goto invalidinh; | |
526 | 517 | insn = "LSRD"; |
527 | 518 | break; |
528 | 519 | } case 0x05: /* LSLD N,Z,V,C (6801) */ { |
520 | + if (cputype < 0x6801) | |
521 | + goto invalidinh; | |
529 | 522 | insn = "LSLD"; |
530 | 523 | break; |
531 | - } | |
532 | -#endif /* def SIM6801 */ | |
533 | - case 0x06: /* TAP (all flags) */ { | |
524 | + } case 0x06: /* TAP (all flags) */ { | |
534 | 525 | insn = "TAP"; |
535 | 526 | break; |
536 | 527 | } case 0x07: /* TPA */ { |
@@ -585,18 +576,16 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
585 | 576 | sprintf(operand + strlen(operand), " $%4.4X", branch_target); |
586 | 577 | insn = "BRA"; |
587 | 578 | break; |
588 | - } | |
589 | -#ifdef SIM6801 | |
590 | - case 0x21: /* BRN (6801) */ { | |
579 | + } case 0x21: /* BRN (6801) */ { | |
580 | + if (cputype < 0x6801) | |
581 | + goto invalidinh; | |
591 | 582 | offset = mem[pc++]; |
592 | 583 | sprintf(buf + strlen(buf), "%2.2X ", mem[pc - 1]); |
593 | 584 | branch_target = pc + offset; |
594 | 585 | sprintf(operand + strlen(operand), " $%4.4X", branch_target); |
595 | 586 | insn = "BRN"; |
596 | 587 | break; |
597 | - } | |
598 | -#endif /* def SIM6801 */ | |
599 | - case 0x22: /* BHI */ { | |
588 | + } case 0x22: /* BHI */ { | |
600 | 589 | offset = mem[pc++]; |
601 | 590 | sprintf(buf + strlen(buf), "%2.2X ", mem[pc - 1]); |
602 | 591 | branch_target = pc + offset; |
@@ -718,37 +707,33 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
718 | 707 | } case 0x37: /* PSHB */ { |
719 | 708 | insn = "PSHB"; |
720 | 709 | break; |
721 | - } | |
722 | -#ifdef SIM6801 | |
723 | - case 0x38: /* PULX (6801) */ { | |
710 | + } case 0x38: /* PULX (6801) */ { | |
711 | + if (cputype < 0x6801) | |
712 | + goto invalidinh; | |
724 | 713 | insn = "PULX"; |
725 | 714 | break; |
726 | - } | |
727 | -#endif /* def SIM6801 */ | |
728 | - case 0x39: /* RTS */ { | |
715 | + } case 0x39: /* RTS */ { | |
729 | 716 | insn = "RTS"; |
730 | 717 | break; |
731 | - } | |
732 | -#ifdef SIM6801 | |
733 | - case 0x3A: /* ABX (6801) */ { | |
718 | + } case 0x3A: /* ABX (6801) */ { | |
719 | + if (cputype < 0x6801) | |
720 | + goto invalidinh; | |
734 | 721 | insn = "ABX"; |
735 | 722 | break; |
736 | - } | |
737 | -#endif /* def SIM6801 */ | |
738 | - case 0x3B: /* RTI */ { | |
723 | + } case 0x3B: /* RTI */ { | |
739 | 724 | insn = "RTI"; |
740 | 725 | break; |
741 | - } | |
742 | -#ifdef SIM6801 | |
743 | - case 0x3C: /* PSHX (6801) */ { | |
726 | + } case 0x3C: /* PSHX (6801) */ { | |
727 | + if (cputype < 0x6801) | |
728 | + goto invalidinh; | |
744 | 729 | insn = "PSHX"; |
745 | 730 | break; |
746 | 731 | } case 0x3D: /* MUL C=accb bit 7 (6801) */ { |
732 | + if (cputype < 0x6801) | |
733 | + goto invalidinh; | |
747 | 734 | insn = "MUL"; |
748 | 735 | break; |
749 | - } | |
750 | -#endif /* def SIM6801 */ | |
751 | - case 0x3E: /* WAI */ { | |
736 | + } case 0x3E: /* WAI */ { | |
752 | 737 | insn = "WAI"; |
753 | 738 | break; |
754 | 739 | } case 0x3F: /* SWI */ { |
@@ -758,6 +743,7 @@ void unasm_line(unsigned char *mem, unsigned short *at_pc, char *outbuf, int *at | ||
758 | 743 | is_swi = mem[ea]; |
759 | 744 | break; |
760 | 745 | } default: /* ??? */ { |
746 | +invalidinh: | |
761 | 747 | insn = "???"; |
762 | 748 | break; |
763 | 749 | } |