Merge branch 'master' into mlb2

This commit is contained in:
Olaf Seibert 2017-04-28 23:22:58 +02:00
commit a4bc859d15
5 changed files with 122 additions and 0 deletions

36
parse.c
View File

@ -755,6 +755,42 @@ EX_TREE *parse_unary(
tp = new_ex_lit(flt[0]);
tp->cp = endcp;
}
return tp;
}
case 'p':
/* psect limits, low or high */ {
char bound = tolower((unsigned char)cp[2]);
char *cp2 = skipwhite(cp + 3);
int islocal = 0;
char *endcp;
char *psectname = get_symbol(cp2, &endcp, &islocal);
SYMBOL *sectsym = lookup_sym(psectname, &section_st);
if (sectsym && !islocal) {
SECTION *psect = sectsym->section;
tp = new_ex_tree();
tp->type = EX_SYM;
tp->data.symbol = sectsym;
tp->cp = cp;
if (bound == 'l') {
; /* that's it */
} else if (bound == 'h') {
EX_TREE *rightp = new_ex_lit(psect->size);
tp = new_ex_bin(EX_ADD, tp, rightp);
} else {
tp = ex_err(tp, endcp);
/* report(stack->top, "^p: %c not recognized", bound); */
}
} else {
/* report(stack->top, "psect name %s not found"); */
tp = ex_err(new_ex_lit(0), endcp);
}
free(psectname);
tp->cp = endcp;
cp = endcp;
return tp;
}
}

View File

@ -21,6 +21,7 @@ TESTS="test-asciz \
test-prec \
test-psect \
test-rad50 \
test-ua-pl \
test-undef \
test-word-comma"

35
tests/test-ua-pl.lst.ok Normal file
View File

@ -0,0 +1,35 @@
1 ;;;;;
2 ;
3 ; Test ^pl and ^ph
4
5 000000 .PSECT section
6
7 000000 000000' .word <^pl section>
8 000002 000014' .word <^ph section>
9 000004 000000' .word <^pl code>
10 000006 000010' .word <^ph code>
11 000010 010' .byte <^ph code>
12 000011 000C .byte <^ph code> / 256
13
14 000000 .PSECT code
15
16 000000 000000' .word <^pl section>
17 000002 000014' .word <^ph section>
18 000004 000000' .word <^pl code>
19 000006 000010' .word <^ph code>
20
21 .end
21
Symbol table
. ******R 003
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)
CODE 000010 003 (RW,I,LCL,REL,CON,NOSAV)

21
tests/test-ua-pl.mac Normal file
View File

@ -0,0 +1,21 @@
;;;;;
;
; Test ^pl and ^ph
.PSECT section
.word <^pl section>
.word <^ph section>
.word <^pl code>
.word <^ph code>
.byte <^ph code>
.byte <^ph code> / 256
.PSECT code
.word <^pl section>
.word <^ph section>
.word <^pl code>
.word <^ph code>
.end

29
tests/test-ua-pl.objd.ok Normal file
View File

@ -0,0 +1,29 @@
GSD:
MODNAME .MAIN.=0 flags=0
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
XFER . ABS.=1 flags=10
ENDGSD
RLD
Location counter definition SECTIO+0
TEXT ADDR=0 LEN=12
000000: 000000 000014 000000 000010 ........
000010: 000010 ..
RLD
Internal 0=0
Internal 2=14
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 ........
RLD
PSECT plus offset 0=SECTIO+0
PSECT plus offset 2=SECTIO+14
Internal 4=0
Internal 6=10
ENDMOD