Merge branch 'master' into mlb2

This commit is contained in:
Olaf Seibert 2017-04-27 21:56:54 +02:00
commit f202984a3c
4 changed files with 85 additions and 1 deletions

View File

@ -938,6 +938,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++;
@ -946,6 +950,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++;
@ -1133,9 +1140,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;

View File

@ -8,6 +8,7 @@
TESTS="test-asciz \
test-backpatch \
test-blkb \
test-bsl-mac-arg \
test-complex-reloc \
test-endm \

41
tests/test-blkb.lst.ok Normal file
View File

@ -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)

25
tests/test-blkb.mac Normal file
View File

@ -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