Joe H. Allen's exorsim with 6809 (and 6801)
リビジョン | 6fd5f8407f93d1fa99a443e3b31d5792633f911d (tree) |
---|---|
日時 | 2020-11-17 01:24:53 |
作者 | Joel Matthew Rees <joel.rees@gmai...> |
コミッター | Joel Matthew Rees |
assembler additions functional, lightly tested, but allow things like
sts #
@@ -20,6 +20,7 @@ | ||
20 | 20 | #include <stdlib.h> |
21 | 21 | #include <string.h> |
22 | 22 | |
23 | +#include "exorsim.h" /* JMR20201103 */ | |
23 | 24 | #include "asm6800.h" |
24 | 25 | #include "utils.h" /* JMR20201103 */ |
25 | 26 |
@@ -191,6 +192,9 @@ enum { | ||
191 | 192 | ACC, /* Accumulator needed */ |
192 | 193 | ACC1, /* Accumulator optional */ |
193 | 194 | ACCB, /* we need an A or a B: add 0x01 for B */ |
195 | +#ifdef SIM6801 | |
196 | + ACCD, /* LDD,STD,ADDD,SUBD */ | |
197 | +#endif /* def SIM6801 */ | |
194 | 198 | NONE /* No operand */ |
195 | 199 | }; |
196 | 200 |
@@ -236,11 +240,22 @@ struct { char *insn; int opcode; int type; } table[] = | ||
236 | 240 | { "orab", 0xca, RM }, |
237 | 241 | { "addb", 0xcb, RM }, |
238 | 242 | |
243 | +#ifdef SIM6801 | |
244 | + { "subd", 0x83, ACCD }, | |
245 | + { "addd", 0xc3, ACCD }, | |
246 | + { "ldd", 0xcc, ACCD }, | |
247 | + { "std", 0xcd, ACCD }, | |
248 | +#endif /* def SIM6801 */ | |
249 | + | |
239 | 250 | { "cpx", 0x8c, IDX }, |
240 | 251 | { "bsr", 0x8d, REL }, |
241 | 252 | { "lds", 0x8e, IDX }, |
242 | 253 | { "sts", 0x8f, IDX }, |
254 | +#ifndef SIM6801 | |
243 | 255 | { "jsr", 0x8d, RMW }, |
256 | +#else /* def SIM6801 */ | |
257 | + { "jsr", 0x8d, IDX }, | |
258 | +#endif /* ndef SIM6801 */ | |
244 | 259 | { "ldx", 0xce, IDX }, |
245 | 260 | { "stx", 0xcf, IDX }, |
246 | 261 |
@@ -250,6 +265,9 @@ struct { char *insn; int opcode; int type; } table[] = | ||
250 | 265 | { "ror", 0x46, RMW }, |
251 | 266 | { "asr", 0x47, RMW }, |
252 | 267 | { "asl", 0x48, RMW }, |
268 | +#ifdef SIM6801 | |
269 | +/* { "lsl", 0x48, NONE }, / * alias */ | |
270 | +#endif /* def SIM6801 */ | |
253 | 271 | { "rol", 0x49, RMW }, |
254 | 272 | { "dec", 0x4a, RMW }, |
255 | 273 | { "inc", 0x4c, RMW }, |
@@ -263,6 +281,9 @@ struct { char *insn; int opcode; int type; } table[] = | ||
263 | 281 | { "rora", 0x46, NONE }, |
264 | 282 | { "asra", 0x47, NONE }, |
265 | 283 | { "asla", 0x48, NONE }, |
284 | +#ifdef SIM6801 | |
285 | +/* { "lsla", 0x48, NONE }, / * alias */ | |
286 | +#endif /* def SIM6801 */ | |
266 | 287 | { "rola", 0x49, NONE }, |
267 | 288 | { "deca", 0x4a, NONE }, |
268 | 289 | { "inca", 0x4c, NONE }, |
@@ -275,6 +296,9 @@ struct { char *insn; int opcode; int type; } table[] = | ||
275 | 296 | { "rorb", 0x56, NONE }, |
276 | 297 | { "asrb", 0x57, NONE }, |
277 | 298 | { "aslb", 0x58, NONE }, |
299 | +#ifdef SIM6801 | |
300 | +/* { "lslb", 0x58, NONE }, / * alias */ | |
301 | +#endif /* def SIM6801 */ | |
278 | 302 | { "rolb", 0x59, NONE }, |
279 | 303 | { "decb", 0x5a, NONE }, |
280 | 304 | { "incb", 0x5c, NONE }, |
@@ -282,6 +306,11 @@ struct { char *insn; int opcode; int type; } table[] = | ||
282 | 306 | { "clrb", 0x5f, NONE }, |
283 | 307 | |
284 | 308 | { "nop", 0x01, NONE }, |
309 | +#ifdef SIM6801 | |
310 | + { "lsrd", 0x04, NONE }, | |
311 | + { "asld", 0x05, NONE }, | |
312 | +/* { "lsld", 0x05, NONE }, / * alias */ | |
313 | +#endif /* def SIM6801 */ | |
285 | 314 | { "tap", 0x06, NONE }, |
286 | 315 | { "tpa", 0x07, NONE }, |
287 | 316 | { "inx", 0x08, NONE }, |
@@ -300,10 +329,19 @@ struct { char *insn; int opcode; int type; } table[] = | ||
300 | 329 | { "aba", 0x1b, NONE }, |
301 | 330 | |
302 | 331 | { "bra", 0x20, REL }, |
332 | +#ifdef SIM6801 | |
333 | + { "brn", 0x21, REL }, | |
334 | +#endif /* def SIM6801 */ | |
303 | 335 | { "bhi", 0x22, REL }, |
304 | 336 | { "bls", 0x23, REL }, |
305 | 337 | { "bcc", 0x24, REL }, |
338 | +#ifdef SIM6801 | |
339 | +/* { "bhs", 0x24, REL }, / * alias */ | |
340 | +#endif /* def SIM6801 */ | |
306 | 341 | { "bcs", 0x25, REL }, |
342 | +#ifdef SIM6801 | |
343 | +/* { "blo", 0x25, REL }, / * alias */ | |
344 | +#endif /* def SIM6801 */ | |
307 | 345 | { "bne", 0x26, REL }, |
308 | 346 | { "beq", 0x27, REL }, |
309 | 347 | { "bvc", 0x28, REL }, |
@@ -325,8 +363,18 @@ struct { char *insn; int opcode; int type; } table[] = | ||
325 | 363 | { "psh", 0x36, ACCB }, |
326 | 364 | { "psha", 0x36, NONE }, |
327 | 365 | { "pshb", 0x37, NONE }, |
366 | +#ifdef SIM6801 | |
367 | + { "pulx", 0x38, NONE }, | |
368 | +#endif /* def SIM6801 */ | |
328 | 369 | { "rts", 0x39, NONE }, |
370 | +#ifdef SIM6801 | |
371 | + { "abx", 0x3a, NONE }, | |
372 | +#endif /* defSIM6801 */ | |
329 | 373 | { "rti", 0x3b, NONE }, |
374 | +#ifdef SIM6801 | |
375 | + { "pshx", 0x3c, NONE }, | |
376 | + { "mul", 0x3d, NONE }, | |
377 | +#endif /* def SIM6801 */ | |
330 | 378 | { "wai", 0x3e, NONE }, |
331 | 379 | { "swi", 0x3f, NONE }, |
332 | 380 |
@@ -537,7 +585,11 @@ unsigned assemble(unsigned char *mem, unsigned addr, char *buf) | ||
537 | 585 | add_fixup(sy, addr, FIXUP_DIR, operand); |
538 | 586 | mem[addr++] = operand; |
539 | 587 | goto done; |
588 | +#ifndef SIM6801 | |
540 | 589 | } else if (type == IDX) { |
590 | +#else /* def SIM6801 */ | |
591 | + } else if (type == IDX || type == ACCD) { | |
592 | +#endif /* ndef SIM6801 */ | |
541 | 593 | /* 16-bit immediate */ |
542 | 594 | mem[addr++] = opcode; |
543 | 595 | if (sy) |
@@ -560,7 +612,11 @@ unsigned assemble(unsigned char *mem, unsigned addr, char *buf) | ||
560 | 612 | if (buf[0] == ',' && (buf[1] == 'x' || buf[1] == 'X')) { |
561 | 613 | ndx: |
562 | 614 | /* We have an indexed operand */ |
615 | +#ifndef SIM6801 | |
563 | 616 | if (type == RM || type == IDX || type == RMW) { |
617 | +#else /* def SIM6801 */ | |
618 | + if (type == RM || type == IDX || type == ACCD || type == RMW) { | |
619 | +#endif /* ndef SIM6801 */ | |
564 | 620 | mem[addr++] = opcode + 0x20;; |
565 | 621 | if (sy) |
566 | 622 | add_fixup(sy, addr, FIXUP_DIR, operand); |
@@ -572,11 +628,19 @@ unsigned assemble(unsigned char *mem, unsigned addr, char *buf) | ||
572 | 628 | } |
573 | 629 | } else { |
574 | 630 | /* We have a direct address operand */ |
631 | +#ifndef SIM6801 | |
575 | 632 | if ((type == RM || type == IDX) && !sy && operand < 256) { |
633 | +#else /* def SIM6801 */ | |
634 | + if ((type == RM || type == IDX || type == ACCD) && !sy && operand < 256) { | |
635 | +#endif /* ndef SIM6801 */ | |
576 | 636 | mem[addr++] = opcode + 0x10; |
577 | 637 | mem[addr++] = operand; |
578 | 638 | goto done; |
639 | +#ifndef SIM6801 | |
579 | 640 | } else if (type == RM || type == IDX || type == RMW) { |
641 | +#else /* def SIM6801 */ | |
642 | + } else if (type == RM || type == IDX || type == ACCD || type == RMW) { | |
643 | +#endif /* ndef SIM6801 */ | |
580 | 644 | mem[addr++] = opcode + 0x30; |
581 | 645 | if (sy) |
582 | 646 | add_fixup(sy, addr, FIXUP_EXT, operand); |