Skip to content

Commit 88b14ef

Browse files
committed
Minor size optimizations to the parser, 8 bytes less.
1 parent 50b1484 commit 88b14ef

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

src/actions.asm

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,11 +660,8 @@ ret: rts
660660
sta loop_stk - 1, y
661661
pla
662662
asl ; Check BIT 6
663-
bmi xit
664-
::inc_opos_2:
665-
jsr parser_inc_opos
666-
jsr parser_inc_opos
667-
xit: clc
663+
bpl emit_AX
664+
clc
668665
rts ; C is cleared on exit!
669666
.endproc
670667

@@ -759,10 +756,11 @@ move:
759756
.endproc
760757

761758
.proc E_POP_WHILE
759+
; Skip over jump (position + 2)
760+
jsr emit_AX
762761
; Pop saved "jump to end" position
763762
lda #LT_WHILE_2
764-
; Save current position + 2 (skip over jump)
765-
jsr inc_opos_2
763+
; Save current position
766764
jsr pop_patch_codep
767765
; Pop saved "loop reentry" position
768766
lda #LT_WHILE_1

src/interp/clearmem.asm

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,14 @@ saved_cpu_stack:
120120
tya
121121
inx
122122
ldy alloc_size
123-
beq nxt
124-
; .byte $2C ; Skip 2 bytes over next "DEC"
125-
bne loop ; Prefer branch, is faster
123+
jmp nxt ; Start loop
126124

127125
pgloop: dec move_dest+1
128126
loop: dey
129127
sta (move_dest), y
130-
bne loop
128+
nxt: bne loop
131129

132-
nxt: dex
130+
dex
133131
bne pgloop
134132

135133
rts

src/parse.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ parse_eof:
148148
;lda #TOK_END ; Already A=0 from above
149149
.assert TOK_END = 0, error, "Parser depends on TOK_END = 0"
150150
clc
151-
jmp emit_const ; Exit after emit
151+
bcc emit_const ; Exit after emit
152152

153153
.proc parser_fetch
154154
inc pptr

0 commit comments

Comments
 (0)