comparison lwasm/insn_rlist.c @ 552:f9ffd1935cee

Add explicit immediate mode to register list instructions (PSHS, etc.) There is actual code in the wild that wants to use things like PSHS #0 which are valid 6809 instructions and actually listed in the literature. So add the capability to do so.
author William Astle <lost@l-w.ca>
date Fri, 30 Jun 2023 09:40:17 -0600
parents f6e03c2cebfb
children
comparison
equal deleted inserted replaced
551:4ec5c94ade71 552:f9ffd1935cee
25 #include <ctype.h> 25 #include <ctype.h>
26 26
27 #include "lwasm.h" 27 #include "lwasm.h"
28 #include "instab.h" 28 #include "instab.h"
29 29
30 PARSEFUNC(insn_parse_imm8);
31 EMITFUNC(insn_emit_imm8);
32
30 PARSEFUNC(insn_parse_rlist) 33 PARSEFUNC(insn_parse_rlist)
31 { 34 {
32 int rb = 0; 35 int rb = 0;
33 int rn; 36 int rn;
34 static const char *regs = "CCA B DPX Y U PCD S "; 37 static const char *regs = "CCA B DPX Y U PCD S ";
38
39 l -> lint = 0;
40 if (**p == '#')
41 {
42 insn_parse_imm8(as, l, p);
43 l -> lint = 1;
44 return;
45 }
35 46
36 while (**p && !isspace(**p) && **p != ';' && **p != '*') 47 while (**p && !isspace(**p) && **p != ';' && **p != '*')
37 { 48 {
38 rn = lwasm_lookupreg2(regs, p); 49 rn = lwasm_lookupreg2(regs, p);
39 if (rn < 0) 50 if (rn < 0)
82 l -> pb = rb; 93 l -> pb = rb;
83 } 94 }
84 95
85 EMITFUNC(insn_emit_rlist) 96 EMITFUNC(insn_emit_rlist)
86 { 97 {
98 if (l -> lint == 1)
99 {
100 insn_emit_imm8(as, l);
101 return;
102 }
103
87 lwasm_emitop(l, instab[l -> insn].ops[0]); 104 lwasm_emitop(l, instab[l -> insn].ops[0]);
88 lwasm_emit(l, l -> pb); 105 lwasm_emit(l, l -> pb);
89 106
90 l -> cycle_adj = lwasm_cycle_calc_rlist(l); 107 l -> cycle_adj = lwasm_cycle_calc_rlist(l);
91 } 108 }