comparison lwasm/pass1.c @ 142:697bc543368c

Implement distinction between . and * for OS9 modules
author lost@l-w.ca
date Fri, 19 Aug 2011 23:55:40 -0600
parents b3557f8325f7
children 9cf1796259b2
comparison
equal deleted inserted replaced
141:11ebce0183a5 142:697bc543368c
116 cl -> soff = -1; 116 cl -> soff = -1;
117 cl -> dshow = -1; 117 cl -> dshow = -1;
118 cl -> dsize = 0; 118 cl -> dsize = 0;
119 cl -> dptr = NULL; 119 cl -> dptr = NULL;
120 cl -> isbrpt = 0; 120 cl -> isbrpt = 0;
121 cl -> dlen = 0;
121 as -> cl = cl; 122 as -> cl = cl;
122 if (!as -> line_tail) 123 if (!as -> line_tail)
123 { 124 {
124 as -> line_head = cl; 125 as -> line_head = cl;
125 cl -> addr = lw_expr_build(lw_expr_type_int, 0); 126 cl -> addr = lw_expr_build(lw_expr_type_int, 0);
127 cl -> daddr = lw_expr_build(lw_expr_type_int, 0);
126 } 128 }
127 else 129 else
128 { 130 {
129 lw_expr_t te; 131 lw_expr_t te;
130 132
135 te = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, cl -> prev); 137 te = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, cl -> prev);
136 cl -> addr = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, cl -> prev -> addr, te); 138 cl -> addr = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, cl -> prev -> addr, te);
137 lw_expr_destroy(te); 139 lw_expr_destroy(te);
138 lwasm_reduce_expr(as, cl -> addr); 140 lwasm_reduce_expr(as, cl -> addr);
139 // lw_expr_simplify(cl -> addr, as); 141 // lw_expr_simplify(cl -> addr, as);
142
143 // set the data address if relevant
144 te = lw_expr_build(lw_expr_type_special, lwasm_expr_linedlen, cl -> prev);
145 cl -> daddr = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, cl -> prev -> daddr, te);
146 lw_expr_destroy(te);
147 lwasm_reduce_expr(as, cl -> daddr);
140 148
141 // carry DP value forward 149 // carry DP value forward
142 cl -> dpval = cl -> prev -> dpval; 150 cl -> dpval = cl -> prev -> dpval;
143 151
144 } 152 }
319 { 327 {
320 struct line_expr_s *le; 328 struct line_expr_s *le;
321 329
322 cl -> len = -1; 330 cl -> len = -1;
323 // call parse function 331 // call parse function
332 debug_message(as, 100, "len = %d, dlen = %d", cl -> len, cl -> dlen);
324 (instab[opnum].parse)(as, cl, &p1); 333 (instab[opnum].parse)(as, cl, &p1);
334 if ((cl -> inmod == 0) && cl -> len >= 0 && cl -> dlen >= 0)
335 {
336 if (cl -> len == 0)
337 cl -> len = cl -> dlen;
338 else
339 cl -> dlen = cl -> len;
340 }
325 341
326 if (*p1 && !isspace(*p1)) 342 if (*p1 && !isspace(*p1))
327 { 343 {
328 // flag bad operand error 344 // flag bad operand error
329 lwasm_register_error(as, cl, "Bad operand (%s)", p1); 345 lwasm_register_error(as, cl, "Bad operand (%s)", p1);
341 357
342 /* try resolving the instruction as well */ 358 /* try resolving the instruction as well */
343 if (cl -> insn >= 0 && instab[cl -> insn].resolve) 359 if (cl -> insn >= 0 && instab[cl -> insn].resolve)
344 { 360 {
345 (instab[cl -> insn].resolve)(as, cl, 0); 361 (instab[cl -> insn].resolve)(as, cl, 0);
362 if ((cl -> inmod == 0) && cl -> len >= 0 && cl -> dlen >= 0)
363 {
364 if (cl -> len == 0)
365 cl -> len = cl -> dlen;
366 else
367 cl -> dlen = cl -> len;
368 }
346 } 369 }
347 370
348 } 371 }
349 else if (as -> instruct == 1) 372 else if (as -> instruct == 1)
350 { 373 {
360 if (cl -> sym && cl -> symset == 0) 383 if (cl -> sym && cl -> symset == 0)
361 { 384 {
362 debug_message(as, 50, "Register symbol %s: %s", cl -> sym, lw_expr_print(cl -> addr)); 385 debug_message(as, 50, "Register symbol %s: %s", cl -> sym, lw_expr_print(cl -> addr));
363 386
364 // register symbol at line address 387 // register symbol at line address
365 if (!register_symbol(as, cl, cl -> sym, cl -> addr, symbol_flag_none)) 388 if (instab[cl -> insn].flags & lwasm_insn_setdata)
366 { 389 {
367 // symbol error 390 if (!register_symbol(as, cl, cl -> sym, cl -> daddr, symbol_flag_none))
368 // lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym); 391 {
392 // symbol error
393 // lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym);
394 }
395 }
396 else
397 {
398 if (!register_symbol(as, cl, cl -> sym, cl -> addr, symbol_flag_none))
399 {
400 // symbol error
401 // lwasm_register_error(as, cl, "Bad symbol '%s'", cl -> sym);
402 }
369 } 403 }
370 } 404 }
371 debug_message(as, 40, "Line address: %s", lw_expr_print(cl -> addr)); 405 debug_message(as, 40, "Line address: %s", lw_expr_print(cl -> addr));
372 } 406 }
373 407