diff --git a/assemble.c b/assemble.c index b20c866..71c7d00 100644 --- a/assemble.c +++ b/assemble.c @@ -926,6 +926,10 @@ static int assemble( return 1; case P_EVEN: + cp = skipwhite(cp); + if (!EOL(*cp)) { + report(stack->top, ".EVEN must not have an argument\n"); + } if (DOT & 1) { list_word(stack->top, DOT, 0, 1, ""); DOT++; @@ -934,6 +938,9 @@ static int assemble( return 1; case P_ODD: + if (!EOL(*cp)) { + report(stack->top, ".EVEN must not have an argument\n"); + } if (!(DOT & 1)) { list_word(stack->top, DOT, 0, 1, ""); DOT++; @@ -1121,9 +1128,19 @@ static int assemble( case P_BLKW: case P_BLKB: { - EX_TREE *value = parse_expr(cp, 0); + EX_TREE *value; int ok = 1; + cp = skipwhite(cp); + if (EOL(*cp)) { + /* If no argument, assume 1. Documented but + * discouraged. Par 6.5.3, page 6-32. */ + /* warning(stack->top, "Argument to .BLKB/.BLKW should be present; 1 assumed\n"); */ + value = new_ex_lit(1); + } else { + value = parse_expr(cp, 0); + } + if (value->type != EX_LIT) { report(stack->top, "Argument to .BLKB/.BLKW " "must be constant\n"); ok = 0; diff --git a/tests/RunTests b/tests/RunTests index b9796be..76e506e 100755 --- a/tests/RunTests +++ b/tests/RunTests @@ -8,6 +8,7 @@ TESTS="test-asciz \ test-backpatch \ + test-blkb \ test-bsl-mac-arg \ test-complex-reloc \ test-endm \ diff --git a/tests/test-blkb.lst.ok b/tests/test-blkb.lst.ok new file mode 100644 index 0000000..0ccced9 --- /dev/null +++ b/tests/test-blkb.lst.ok @@ -0,0 +1,41 @@ + 1 ;;;;; + 2 ; + 3 ; Test .BLKB and .BLKW + 4 ; + 5 000000 label: .blkb ; not recommended, but default argument is 1 + 6 000001 .blkb 1 + 7 000002 .blkb 2 + 8 000004 .blkb 100. +test-blkb.mac:9: ***ERROR Argument to .BLKB/.BLKW must be constant + 9 .blkb label ; error: not an constant expression + 10 + 11 000150 000 .odd + 12 + 13 000151 .blkw 1 ; should maybe be an error: odd address + 14 + 15 000153 000 .even + 16 + 17 000154 label2: .blkb ; not recommended, but default argument is 1 + 18 000155 .blkb 1 + 19 000156 .blkb 2 + 20 000160 .blkb 100. +test-blkb.mac:21: ***ERROR Argument to .BLKB/.BLKW must be constant + 21 .blkb label2 ; error: not an constant expression + 22 + 23 +test-blkb.mac:24: ***ERROR .EVEN must not have an argument + 24 .even 1 ; error: no argument allowed +test-blkb.mac:25: ***ERROR .EVEN must not have an argument + 25 000324 000 .odd 1 ; error: no argument allowed + 25 + + +Symbol table + +. ******R 001 LABEL 000000R 001 LABEL2 000154R 001 + + +Program sections: + +. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV) + 000325 001 (RW,I,LCL,REL,CON,NOSAV) diff --git a/tests/test-blkb.mac b/tests/test-blkb.mac new file mode 100644 index 0000000..88e39eb --- /dev/null +++ b/tests/test-blkb.mac @@ -0,0 +1,25 @@ +;;;;; +; +; Test .BLKB and .BLKW +; +label: .blkb ; not recommended, but default argument is 1 + .blkb 1 + .blkb 2 + .blkb 100. + .blkb label ; error: not an constant expression + + .odd + + .blkw 1 ; should maybe be an error: odd address + + .even + +label2: .blkb ; not recommended, but default argument is 1 + .blkb 1 + .blkb 2 + .blkb 100. + .blkb label2 ; error: not an constant expression + + + .even 1 ; error: no argument allowed + .odd 1 ; error: no argument allowed