comparison lwasm/insn_tfm.c @ 370:8764142b3192

Convert internal error/warning handling framework to a new unified system Replace the ad hoc error and warning handling with a new system that codifies the errors with specific codes. This makes it possible in the future for error numbers to be used for testing and other purposes. It also makes sure the error strings themselves are consistent. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 22 Jun 2015 18:49:38 -0600
parents 09021ba6d755
children 2abcd82b455f
comparison
equal deleted inserted replaced
369:682524a1f32f 370:8764142b3192
32 int tfm = 0; 32 int tfm = 0;
33 33
34 c = strchr(reglist, toupper(*(*p)++)); 34 c = strchr(reglist, toupper(*(*p)++));
35 if (!c) 35 if (!c)
36 { 36 {
37 lwasm_register_error(as, l, "Unknown operation"); 37 lwasm_register_error(as, l, E_UNKNOWN_OPERATION);
38 return; 38 return;
39 } 39 }
40 r0 = c - reglist; 40 r0 = c - reglist;
41 if (**p == '+') 41 if (**p == '+')
42 { 42 {
48 (*p)++; 48 (*p)++;
49 tfm = 2; 49 tfm = 2;
50 } 50 }
51 if (*(*p)++ != ',') 51 if (*(*p)++ != ',')
52 { 52 {
53 lwasm_register_error(as, l, "Unknown operation"); 53 lwasm_register_error(as, l, E_UNKNOWN_OPERATION);
54 return; 54 return;
55 } 55 }
56 c = strchr(reglist, toupper(*(*p)++)); 56 c = strchr(reglist, toupper(*(*p)++));
57 if (!c) 57 if (!c)
58 { 58 {
59 lwasm_register_error(as, l, "Unknown operation"); 59 lwasm_register_error(as, l, E_UNKNOWN_OPERATION);
60 return; 60 return;
61 } 61 }
62 r1 = c - reglist; 62 r1 = c - reglist;
63 63
64 if (**p == '+') 64 if (**p == '+')
72 tfm |= 8; 72 tfm |= 8;
73 } 73 }
74 74
75 if (**p && !isspace(**p)) 75 if (**p && !isspace(**p))
76 { 76 {
77 lwasm_register_error(as, l, "Bad operand"); 77 lwasm_register_error(as, l, E_OPERAND_BAD);
78 return; 78 return;
79 } 79 }
80 80
81 // valid values of tfm here are: 81 // valid values of tfm here are:
82 // 1: r0+,r1 (2) 82 // 1: r0+,r1 (2)
100 case 4: // r0,r1+ 100 case 4: // r0,r1+
101 l -> lint = instab[l -> insn].ops[3]; 101 l -> lint = instab[l -> insn].ops[3];
102 break; 102 break;
103 103
104 default: 104 default:
105 lwasm_register_error(as, l, "Unknown operation"); 105 lwasm_register_error(as, l, E_UNKNOWN_OPERATION);
106 return; 106 return;
107 } 107 }
108 l -> pb = (r0 << 4) | r1; 108 l -> pb = (r0 << 4) | r1;
109 l -> len = OPLEN(l -> lint) + 1; 109 l -> len = OPLEN(l -> lint) + 1;
110 } 110 }
125 // D,X,Y,U,S,PC,W,V 125 // D,X,Y,U,S,PC,W,V
126 // A,B,CC,DP,0,0,E,F 126 // A,B,CC,DP,0,0,E,F
127 r0 = lwasm_lookupreg2(regs, p); 127 r0 = lwasm_lookupreg2(regs, p);
128 if (r0 < 0 || *(*p)++ != ',') 128 if (r0 < 0 || *(*p)++ != ',')
129 { 129 {
130 lwasm_register_error(as, l, "Bad operand"); 130 lwasm_register_error(as, l, E_OPERAND_BAD);
131 r0 = r1 = 0; 131 r0 = r1 = 0;
132 } 132 }
133 else 133 else
134 { 134 {
135 r1 = lwasm_lookupreg2(regs, p); 135 r1 = lwasm_lookupreg2(regs, p);
136 if (r1 < 0) 136 if (r1 < 0)
137 { 137 {
138 lwasm_register_error(as, l, "Bad operand"); 138 lwasm_register_error(as, l, E_OPERAND_BAD);
139 r0 = r1 = 0; 139 r0 = r1 = 0;
140 } 140 }
141 } 141 }
142 l -> len = instab[l -> insn].ops[0] + 1; 142 l -> len = instab[l -> insn].ops[0] + 1;
143 l -> pb = (r0 << 4) | r1; 143 l -> pb = (r0 << 4) | r1;