diff --git a/assemble_aux.c b/assemble_aux.c index 22b0684..ac3a24f 100644 --- a/assemble_aux.c +++ b/assemble_aux.c @@ -659,7 +659,7 @@ int do_word( } else { EX_TREE *value = parse_expr(cp, 0); - if (value->cp > cp) { + if (value->type != EX_ERR && value->cp > cp) { store_value(stack, tr, size, value); cp = value->cp; diff --git a/parse.c b/parse.c index 2e9f406..7e158b9 100644 --- a/parse.c +++ b/parse.c @@ -953,7 +953,7 @@ EX_TREE *parse_unary( int islocal = 0; char *endcp; char *psectname = get_symbol(cp2, &endcp, &islocal); - SYMBOL *sectsym = lookup_sym(psectname, §ion_st); + SYMBOL *sectsym = psectname ? lookup_sym(psectname, §ion_st) : NULL; if (sectsym && !islocal) { SECTION *psect = sectsym->section; @@ -970,11 +970,20 @@ EX_TREE *parse_unary( tp = new_ex_bin(EX_ADD, tp, rightp); } else { tp = ex_err(tp, endcp); - /* report(stack->top, "^p: %c not recognized", bound); */ + /* report(stack->top, "^p: %c not recognized\n", bound); */ } } else { - /* report(stack->top, "psect name %s not found"); */ - tp = ex_err(new_ex_lit(0), endcp); + /* report(stack->top, "psect name %s not found\n", psectname); */ + if (pass == 0) { + /* + * During the first pass it is expected that the psect is not + * found. Return a dummy value of the expected size, so that + * the size of the psect keeps in sync. + */ + tp = new_ex_lit(0); + } else { + tp = ex_err(new_ex_lit(0), endcp); + } } free(psectname); tp->cp = endcp; @@ -1072,9 +1081,6 @@ EX_TREE *parse_unary( get_symbol a second time. */ if (!(label = get_symbol(cp, &cp, &local))) { - if (!EOL(*cp)) { - cp++; /*JH: eat first char of illegal label, else endless loop on implied .WORD */ - } tp = ex_err(NULL, cp); /* Not a valid label. */ return tp; } diff --git a/tests/SetTestOk b/tests/SetTestOk new file mode 100755 index 0000000..6901328 --- /dev/null +++ b/tests/SetTestOk @@ -0,0 +1,21 @@ +#!/bin/sh +# +set_ok() { + t="$1" + + if [ -e "$t".lst.ok ] + then + cp "$t".lst "$t".lst.ok + fi + + if [ -e "$t".objd.ok ] + then + cp "$t".objd "$t".objd.okd + fi +} + +for fn in "$@" +do + set_ok "$fn" +done + diff --git a/tests/test-asciz.lst.ok b/tests/test-asciz.lst.ok index 537f196..0518914 100644 --- a/tests/test-asciz.lst.ok +++ b/tests/test-asciz.lst.ok @@ -35,28 +35,24 @@ test-asciz.mac:18: ***ERROR Complex expression cannot be assigned to a symbol 18 .asciz =DEF= ; syntax error: assignment test-asciz.mac:19: ***ERROR Complex expression cannot be assigned to a symbol 19 .asciz =###= ; syntax error: assignment -test-asciz.mac:20: ***ERROR .WORD on odd boundary -test-asciz.mac:20: ***ERROR Invalid expression - 20 000075 000 000001 000000 .asciz :SOH: ; syntax error: colon not allowed -test-asciz.mac:21: ***ERROR Illegal symbol definition .ASCIZ -test-asciz.mac:21: ***ERROR Invalid expression -test-asciz.mac:21: ***ERROR Invalid expression -test-asciz.mac:21: ***ERROR Invalid expression -test-asciz.mac:21: ***ERROR Invalid expression - 21 000102 000000 000000 000000 .asciz :###: ; syntax error: colon not allowed - 000110 000000 - 22 000112 043 043 043 .asciz ^###^ ; previous versions of this macro11 - 000115 000 - 23 ; used ^/.../ quoting as an extension; however this should be ^...^. - 23 + 20 000075 000 .even +test-asciz.mac:21: ***ERROR Invalid expression in .WORD + 21 000076 000001 .asciz :SOH: ; syntax error: colon not allowed +test-asciz.mac:22: ***ERROR Illegal symbol definition .ASCIZ +test-asciz.mac:22: ***ERROR Invalid expression in .WORD + 22 .asciz :###: ; syntax error: colon not allowed + 23 000100 043 043 043 .asciz ^###^ ; previous versions of this macro11 + 000103 000 + 24 ; used ^/.../ quoting as an extension; however this should be ^...^. + 24 Symbol table -. ******R 001 .ASCIZ 000075R 001 CR = 000015 LF = 000012 SOH = 000001 +. ******R 001 .ASCIZ 000076R 001 CR = 000015 LF = 000012 SOH = 000001 Program sections: . ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV) - 000116 001 (RW,I,LCL,REL,CON,NOSAV) + 000104 001 (RW,I,LCL,REL,CON,NOSAV) diff --git a/tests/test-asciz.mac b/tests/test-asciz.mac index 2b92c78..84a3c0b 100644 --- a/tests/test-asciz.mac +++ b/tests/test-asciz.mac @@ -17,6 +17,7 @@ SOH = 1 .asciz &###& ; another weird delimiter .asciz =DEF= ; syntax error: assignment .asciz =###= ; syntax error: assignment + .even .asciz :SOH: ; syntax error: colon not allowed .asciz :###: ; syntax error: colon not allowed .asciz ^###^ ; previous versions of this macro11 diff --git a/tests/test-include.lst.ok b/tests/test-include.lst.ok index 8e6c067..a5b0dc0 100644 --- a/tests/test-include.lst.ok +++ b/tests/test-include.lst.ok @@ -46,8 +46,8 @@ test-include.mac:14: ***ERROR Bad .INCLUDE file name test-include.mac:15: ***ERROR Bad .INCLUDE file name 15 .include - 8 000002 000014' .word <^ph section> + 8 000002 000012' .word <^ph section> 9 000004 000000' .word <^pl code> 10 000006 000010' .word <^ph code> 11 000010 010' .byte <^ph code> @@ -14,7 +14,7 @@ 14 000000 .PSECT code 15 16 000000 000000' .word <^pl section> - 17 000002 000014' .word <^ph section> + 17 000002 000012' .word <^ph section> 18 000004 000000' .word <^pl code> 19 000006 000010' .word <^ph code> 20 @@ -31,5 +31,5 @@ Program sections: . ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV) 000000 001 (RW,I,LCL,REL,CON,NOSAV) -SECTIO 000014 002 (RW,I,LCL,REL,CON,NOSAV) +SECTIO 000012 002 (RW,I,LCL,REL,CON,NOSAV) CODE 000010 003 (RW,I,LCL,REL,CON,NOSAV) diff --git a/tests/test-ua-pl.objd.ok b/tests/test-ua-pl.objd.ok index 7c487c5..84ec434 100644 --- a/tests/test-ua-pl.objd.ok +++ b/tests/test-ua-pl.objd.ok @@ -3,27 +3,27 @@ GSD: PSECT =0 CON RW REL LCL I flags=40 PSECT . ABS.=0 OVR RW ABS GBL I flags=104 PSECT CODE =10 CON RW REL LCL I flags=40 - PSECT SECTIO=14 CON RW REL LCL I flags=40 + PSECT SECTIO=12 CON RW REL LCL I flags=40 XFER . ABS.=1 flags=10 ENDGSD RLD Location counter definition SECTIO+0 TEXT ADDR=0 LEN=12 - 000000: 000000 000014 000000 000010 ........ + 000000: 000000 000012 000000 000010 ........ 000010: 000010 .. RLD Internal 0=0 - Internal 2=14 + Internal 2=12 PSECT plus offset 4=CODE+0 PSECT plus offset 6=CODE+10 PSECT plus offset byte 10=CODE+10 Complex byte 11=CODE:10 256 / store Location counter definition CODE+0 TEXT ADDR=0 LEN=10 - 000000: 000000 000014 000000 000010 ........ + 000000: 000000 000012 000000 000010 ........ RLD PSECT plus offset 0=SECTIO+0 - PSECT plus offset 2=SECTIO+14 + PSECT plus offset 2=SECTIO+12 Internal 4=0 Internal 6=10 ENDMOD