diff --git a/rept_irpc.c b/rept_irpc.c index 419b816..fec90c1 100644 --- a/rept_irpc.c +++ b/rept_irpc.c @@ -38,13 +38,14 @@ char *rept_stream_gets( char *cp; for (;;) { + if (rstr->count <= 0) + return NULL; + if ((cp = buffer_stream_gets(str)) != NULL) return cp; - if (--rstr->count <= 0) - return NULL; - buffer_stream_rewind(str); + rstr->count--; } } @@ -84,6 +85,8 @@ STREAM *expand_rept( return NULL; } + list_value(stack->top, value->data.lit); + gb = new_buffer(); levelmod = 0; diff --git a/tests/2.11BSD-m11-code.lst.ok b/tests/2.11BSD-m11-code.lst.ok index 78b2ace..f8133ef 100644 --- a/tests/2.11BSD-m11-code.lst.ok +++ b/tests/2.11BSD-m11-code.lst.ok @@ -996,7 +996,7 @@ 301 001252 110422 movb r4,(r2)+ 302 001254 032704 000020 bit #cc.nam,r4 303 001260 001405 beq 3$ - 304 .rept 4 + 304 000004 .rept 4 305 movb (r1)+,(r2)+ 306 .endm 1 001262 112122 movb (r1)+,(r2)+ diff --git a/tests/2.11BSD-m11-expr.lst.ok b/tests/2.11BSD-m11-expr.lst.ok index 4918b40..ff3bb93 100644 --- a/tests/2.11BSD-m11-expr.lst.ok +++ b/tests/2.11BSD-m11-expr.lst.ok @@ -906,7 +906,7 @@ 154 000600 126167 000005 000000G cmpb 5(r1),objsec 155 000606 001407 beq 2$ 156 000610 052716 000020 1$: bis #cc.nam,(sp) - 157 .rept 4 + 157 000004 .rept 4 158 movb (r1)+,(r2)+ 159 .endm 1 000614 112122 movb (r1)+,(r2)+ @@ -1644,7 +1644,7 @@ 527 003006 call crfref ;cref into proper roll 1 003006 004767 000000G jsr pc,crfref 528 003012 012701 000000G mov #symbol,r1 - 529 .rept 4 ;move into code buffer + 529 000004 .rept 4 ;move into code buffer 530 movb (r1)+,(r2)+ 531 .endm 1 003016 112122 movb (r1)+,(r2)+ diff --git a/tests/2.11BSD-m11-macro.lst.ok b/tests/2.11BSD-m11-macro.lst.ok index ce2c4ef..0289444 100644 --- a/tests/2.11BSD-m11-macro.lst.ok +++ b/tests/2.11BSD-m11-macro.lst.ok @@ -1121,19 +1121,18 @@ 114 000005 sector: .blkb 1 ;symbol/expression type 115 000006 value: .blkw 1 ;expression value 116 000010 rellvl: .blkw 1 - 117 .rept maxxmt-<<.-symbol>/2> ;end of grouped data + 117 000000 .rept maxxmt-<<.-symbol>/2> ;end of grouped data 118 .blkw 119 .endm - 1 000012 .blkw 120 - 121 000014 clcnam: .blkw 2 ;current location counter symbol - 122 000020 clcfgs: .blkb 1 - 123 000021 clcsec: .blkb 1 - 124 000022 clcloc: .blkw 1 - 125 000024 clcmax: .blkw 1 + 121 000012 clcnam: .blkw 2 ;current location counter symbol + 122 000016 clcfgs: .blkb 1 + 123 000017 clcsec: .blkb 1 + 124 000020 clcloc: .blkw 1 + 125 000022 clcmax: .blkw 1 126 - 127 000026 xitsec ;return to normal - 1 000026 entsec .text + 127 000024 xitsec ;return to normal + 1 000024 entsec .text 1 000000 .psect .text con 127 128 prop1: ;process pass 1 @@ -1288,11 +1287,11 @@ $TIMDF=000007 CH.MUL=000052 ENDFLG=****** G LET.R =0 9$3 000260R L 002 CH.SUB=000055 ERRBTS=****** G MDFFLG=000004 SECROL=000012 G AATTRS=000130 CH.UAR=000136 EXMFLG 000000RG 010 MK.SYM=000001 SECTOR 000005RG 009 B.IDF =000001 CH.XCL=000047 FF =000014 MODE 000004RG 009 SETMAX=****** G -BKSIZ 000002RG 008 CLCFGS 000020RG 009 FLAGS 000004RG 009 NEXT =****** G SETNB =****** G -BPMB =000020 CLCLOC 000022RG 009 FT.ID =000001 OBJCHN=****** G SETXPR=****** G -BSSFLG=000004 CLCMAX 000024RG 009 FT.UNX=000001 OPENO =****** G SHRFLG=000001 -CATTRS=000170 CLCNAM 000014RG 009 GETLIN=****** G OVRFLG=000020 SPACE =000040 -CH.ADD=000053 CLCSEC 000021RG 009 GLBFLG=000100 PASS 000000RG 008 STMNT =****** G +BKSIZ 000002RG 008 CLCFGS 000016RG 009 FLAGS 000004RG 009 NEXT =****** G SETNB =****** G +BPMB =000020 CLCLOC 000020RG 009 FT.ID =000001 OBJCHN=****** G SETXPR=****** G +BSSFLG=000004 CLCMAX 000022RG 009 FT.UNX=000001 OPENO =****** G SHRFLG=000001 +CATTRS=000170 CLCNAM 000012RG 009 GETLIN=****** G OVRFLG=000020 SPACE =000040 +CH.ADD=000053 CLCSEC 000017RG 009 GLBFLG=000100 PASS 000000RG 008 STMNT =****** G CH.AND=000046 CNDROL=000020 G INSERT=****** G PATTRS=000050 SWTROL=000022 G CH.BSL=000134 CODROL=000014 G INSFLG=000002 PDPV45=000000 SYMBOL 000000RG 009 CH.COL=000072 CPOPJ =****** G LBLFLG=000002 PROP1 000000RG 002 SYMROL=000002 G @@ -1319,7 +1318,7 @@ DPURE 000020 005 (RW,I,LCL,REL,CON,NOSAV) MIXED 000000 006 (RW,I,LCL,REL,CON,NOSAV) ERRMES 000000 007 (RW,I,LCL,REL,CON,NOSAV) IMPURE 000006 008 (RW,I,LCL,REL,CON,NOSAV) -IMPPAS 000026 009 (RW,I,LCL,REL,CON,NOSAV) +IMPPAS 000024 009 (RW,I,LCL,REL,CON,NOSAV) IMPLIN 000002 010 (RW,I,LCL,REL,CON,NOSAV) SWTSEC 000000 011 (RW,I,LCL,REL,CON,NOSAV) CNDSEC 000000 012 (RW,I,LCL,REL,CON,NOSAV) diff --git a/tests/2.11BSD-m11-misc.lst.ok b/tests/2.11BSD-m11-misc.lst.ok index e77211a..f35c1c4 100644 --- a/tests/2.11BSD-m11-misc.lst.ok +++ b/tests/2.11BSD-m11-misc.lst.ok @@ -1152,7 +1152,7 @@ 1 001006 000207 rts pc 291 292 - 293 .rept 20 ;generate xmit sequence + 293 000020 .rept 20 ;generate xmit sequence 294 mov (r1)+,(r2)+ 295 .endm 1 001010 012122 mov (r1)+,(r2)+ diff --git a/tests/2.11BSD-m11-xlat.lst.ok b/tests/2.11BSD-m11-xlat.lst.ok index db6d490..8263318 100644 --- a/tests/2.11BSD-m11-xlat.lst.ok +++ b/tests/2.11BSD-m11-xlat.lst.ok @@ -2086,7 +2086,7 @@ 694 004202 116767 000000' 000000G movb silly,mode 695 004210 116767 000000C 000000G movb <^pl rolsiz>+1+secrol,sector 696 004216 012703 000000G 1$: mov #clcnam,r3 - 697 .rept 5 + 697 000005 .rept 5 698 mov -(r3),-(sp) 699 .endr 1 004222 014346 mov -(r3),-(sp) diff --git a/tests/RunTests b/tests/RunTests index 7bcf973..2077424 100755 --- a/tests/RunTests +++ b/tests/RunTests @@ -23,6 +23,7 @@ TESTS="test-asciz \ test-prec \ test-psect \ test-rad50 \ + test-rept \ test-ua-pl \ test-undef \ test-word-comma" diff --git a/tests/test-rept.lst.ok b/tests/test-rept.lst.ok new file mode 100644 index 0000000..b5705f5 --- /dev/null +++ b/tests/test-rept.lst.ok @@ -0,0 +1,38 @@ + 1 000000 .REPT 0 + 2 THIS IS A BIG BLOCK OF COMMENTS + 3 WE DON'T EXPECT THAT IT WILL EVER BE ASSEMBLED + 4 MORE STUFF TO SAY HERE + 5 + 6 .ENDR + 7 + 8 + 9 000000 005001 clr r1 + 10 000001 .rept 1 + 11 inc r1 + 12 .endr + 1 000002 005201 inc r1 + 13 + 14 000004 005002 clr r2 + 15 000002 .rept 2 + 16 inc r2 + 17 .endr + 1 000006 005202 inc r2 + 1 000010 005202 inc r2 + 18 + 19 000012 005000 clr r0 +test-rept.mac:20: ***ERROR .REPT value must be constant + 20 .rept undefd + 21 000014 005200 inc r0 + 22 .endr + 22 + + +Symbol table + +. ******R 001 + + +Program sections: + +. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV) + 000016 001 (RW,I,LCL,REL,CON,NOSAV) diff --git a/tests/test-rept.mac b/tests/test-rept.mac new file mode 100644 index 0000000..905cfd2 --- /dev/null +++ b/tests/test-rept.mac @@ -0,0 +1,22 @@ + .REPT 0 +THIS IS A BIG BLOCK OF COMMENTS +WE DON'T EXPECT THAT IT WILL EVER BE ASSEMBLED +MORE STUFF TO SAY HERE + + .ENDR + + + clr r1 + .rept 1 + inc r1 + .endr + + clr r2 + .rept 2 + inc r2 + .endr + + clr r0 + .rept undefd + inc r0 + .endr