comparison lwasm/pseudo.c @ 235:aa0056ca7319

Added a padding value for the ALIGN directive
author lost
date Fri, 12 Jun 2009 05:25:41 +0000
parents 59a138df0401
children a58f49a77441
comparison
equal deleted inserted replaced
234:4e25aa2af73c 235:aa0056ca7319
324 324
325 OPFUNC(pseudo_align) 325 OPFUNC(pseudo_align)
326 { 326 {
327 int cn; 327 int cn;
328 int r, v; 328 int r, v;
329 329 int pad = 0;
330 if (as -> passnum == 2) 330 // we have to parse this on pass 2 so that we get the pad value
331 { 331 // if (as -> passnum == 2)
332 skip_operand(p); 332 // {
333 while (as -> addr < l -> symaddr) 333 // skip_operand(p);
334 lwasm_emit(as, l, 0); 334 // while (as -> addr < l -> symaddr)
335 return; 335 // lwasm_emit(as, l, 0);
336 } 336 // return;
337 // }
337 338
338 r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0); 339 r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
339 if (r != 0) 340 if (r != 0)
340 { 341 {
341 l -> symaddr = as -> addr; 342 l -> symaddr = as -> addr;
350 351
351 cn = l -> codeaddr % v; 352 cn = l -> codeaddr % v;
352 if (cn) 353 if (cn)
353 cn = v - cn; 354 cn = v - cn;
354 355
356 if (**p == ',')
357 {
358 // we have a padding value specified
359 (*p)++;
360 r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST, &pad, 1);
361 if (r != 0 && as -> passnum == 2)
362 {
363 register_error(as, l, 2, "Illegal padding value - must be constant on pass 2");
364 return;
365 }
366 }
367
355 while (cn--) 368 while (cn--)
356 { 369 {
357 lwasm_emit(as, l, 0); 370 lwasm_emit(as, l, pad);
358 } 371 }
359 l -> symaddr = as -> addr; 372 l -> symaddr = as -> addr;
360 } 373 }
361 374
362 OPFUNC(pseudo_equ) 375 OPFUNC(pseudo_equ)