comparison lwasm/insn_tfm.c @ 402:b20f14edda5a

Completed initial conversion to new parser allowing spaces in operands Converted the remaining addressing modes. This required a complete rewrite of a large portion of the indexed addressing parser. Now the entire indexed parsing system is programmatic without cheating with a lookup table. This update also fixes the "force 0,r" by writing a literal 0,r which is *supposed* to work. There will likely be some pseudo ops that need tweaking for space handling, specially those that take multiple operands of some description which are not expressions. (The expression parser call eats the spaces both before and after the expression, if appropriate.)
author William Astle <lost@l-w.ca>
date Wed, 14 Oct 2015 20:49:41 -0600
parents 2abcd82b455f
children 01bdad2118aa
comparison
equal deleted inserted replaced
401:bbe5401a9bf3 402:b20f14edda5a
46 else if (**p == '-') 46 else if (**p == '-')
47 { 47 {
48 (*p)++; 48 (*p)++;
49 tfm = 2; 49 tfm = 2;
50 } 50 }
51 lwasm_skip_to_next_token(l, p);
51 if (*(*p)++ != ',') 52 if (*(*p)++ != ',')
52 { 53 {
53 lwasm_register_error(as, l, E_UNKNOWN_OPERATION); 54 lwasm_register_error(as, l, E_UNKNOWN_OPERATION);
54 return; 55 return;
55 } 56 }
57 lwasm_skip_to_next_token(l, p);
56 c = strchr(reglist, toupper(*(*p)++)); 58 c = strchr(reglist, toupper(*(*p)++));
57 if (!c) 59 if (!c)
58 { 60 {
59 lwasm_register_error(as, l, E_REGISTER_BAD); 61 lwasm_register_error(as, l, E_REGISTER_BAD);
60 return; 62 return;
129 // register to register (r0,r1) 131 // register to register (r0,r1)
130 // registers are in order: 132 // registers are in order:
131 // D,X,Y,U,S,PC,W,V 133 // D,X,Y,U,S,PC,W,V
132 // A,B,CC,DP,0,0,E,F 134 // A,B,CC,DP,0,0,E,F
133 r0 = lwasm_lookupreg2(regs, p); 135 r0 = lwasm_lookupreg2(regs, p);
136 lwasm_skip_to_next_token(l, p);
134 if (r0 < 0 || *(*p)++ != ',') 137 if (r0 < 0 || *(*p)++ != ',')
135 { 138 {
136 lwasm_register_error(as, l, E_OPERAND_BAD); 139 lwasm_register_error(as, l, E_OPERAND_BAD);
137 r0 = r1 = 0; 140 r0 = r1 = 0;
138 } 141 }
139 else 142 else
140 { 143 {
144 lwasm_skip_to_next_token(l, p);
141 r1 = lwasm_lookupreg2(regs, p); 145 r1 = lwasm_lookupreg2(regs, p);
142 if (r1 < 0) 146 if (r1 < 0)
143 { 147 {
144 lwasm_register_error(as, l, E_OPERAND_BAD); 148 lwasm_register_error(as, l, E_OPERAND_BAD);
145 r0 = r1 = 0; 149 r0 = r1 = 0;