Mercurial > hg > index.cgi
comparison lwasm/output.c @ 12:6b9991fb39b6
Brought forward patch to fix bug with complex external references generating invalid relocations in the object file
author | lost@l-w.ca |
---|---|
date | Sat, 22 Jan 2011 16:11:15 -0700 |
parents | 7317fbe024af |
children | d92b9c968731 |
comparison
equal
deleted
inserted
replaced
11:a0317b794b7b | 12:6b9991fb39b6 |
---|---|
232 | 232 |
233 int write_code_obj_expraux(lw_expr_t e, void *of) | 233 int write_code_obj_expraux(lw_expr_t e, void *of) |
234 { | 234 { |
235 int tt; | 235 int tt; |
236 int v; | 236 int v; |
237 int count = 1; | |
237 unsigned char buf[16]; | 238 unsigned char buf[16]; |
238 | 239 |
239 tt = lw_expr_type(e); | 240 tt = lw_expr_type(e); |
240 | 241 |
241 switch (tt) | 242 switch (tt) |
242 { | 243 { |
243 case lw_expr_type_oper: | 244 case lw_expr_type_oper: |
244 buf[0] = 0x04; | 245 buf[0] = 0x04; |
246 | |
245 switch (lw_expr_whichop(e)) | 247 switch (lw_expr_whichop(e)) |
246 { | 248 { |
247 case lw_expr_oper_plus: | 249 case lw_expr_oper_plus: |
248 buf[1] = 0x01; | 250 buf[1] = 0x01; |
251 count = lw_expr_operandcount(e) - 1; | |
249 break; | 252 break; |
250 | 253 |
251 case lw_expr_oper_minus: | 254 case lw_expr_oper_minus: |
252 buf[1] = 0x02; | 255 buf[1] = 0x02; |
253 break; | 256 break; |
254 | 257 |
255 case lw_expr_oper_times: | 258 case lw_expr_oper_times: |
256 buf[1] = 0x03; | 259 buf[1] = 0x03; |
260 count = lw_expr_operandcount(e) - 1; | |
257 break; | 261 break; |
258 | 262 |
259 case lw_expr_oper_divide: | 263 case lw_expr_oper_divide: |
260 buf[1] = 0x04; | 264 buf[1] = 0x04; |
261 break; | 265 break; |
297 break; | 301 break; |
298 | 302 |
299 default: | 303 default: |
300 buf[1] = 0xff; | 304 buf[1] = 0xff; |
301 } | 305 } |
302 writebytes(buf, 2, 1, of); | 306 while (count--) |
307 writebytes(buf, 2, 1, of); | |
303 return 0; | 308 return 0; |
304 | 309 |
305 case lw_expr_type_int: | 310 case lw_expr_type_int: |
306 v = lw_expr_intval(e); | 311 v = lw_expr_intval(e); |
307 buf[0] = 0x01; | 312 buf[0] = 0x01; |