Skip to content

Commit 252f5f7

Browse files
committed
Little optimizations to actions.asm.
1 parent 1a98035 commit 252f5f7

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

src/actions.asm

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,34 @@ set_type:
447447
xit: rts
448448
.endproc
449449

450+
; Label definition search/create
451+
.proc E_LABEL_DEF
452+
jsr label_create
453+
454+
; Fills all undefined labels with current position - saved for the label
455+
bcs nfound
456+
457+
; Check label number
458+
cloop: bmi error ; label already defined
459+
460+
; Write current codep to AX
461+
jsr patch_codep
462+
ldy #0
463+
lda #1
464+
sta (tmp1), y
465+
466+
; Continue
467+
next: jsr next_laddr
468+
bcc cloop
469+
nfound:
470+
lda #128
471+
jsr add_laddr_list
472+
bcs error
473+
bcc advance_varn
474+
error: sec
475+
rts
476+
.endproc
477+
450478
; Loop iteration for label-address,
451479
; increment pointer, compares with end
452480
; and reads values
@@ -551,34 +579,6 @@ nfound: lda #0
551579
ret: rts
552580
.endproc
553581

554-
; Label definition search/create
555-
.proc E_LABEL_DEF
556-
jsr label_create
557-
558-
; Fills all undefined labels with current position - saved for the label
559-
bcs nfound
560-
561-
; Check label number
562-
cloop: bmi error ; label already defined
563-
564-
; Write current codep to AX
565-
jsr patch_codep
566-
ldy #0
567-
lda #1
568-
sta (tmp1), y
569-
570-
; Continue
571-
next: jsr next_laddr
572-
bcc cloop
573-
nfound:
574-
lda #128
575-
jsr add_laddr_list
576-
bcs error
577-
jmp advance_varn
578-
error: sec
579-
xit: rts
580-
.endproc
581-
582582
; Check if all labels are defined
583583
; Returns C=1 if ok.
584584
.proc check_labels
@@ -591,10 +591,10 @@ start:
591591
cpy laddr_ptr
592592
lda tmp1+1
593593
sbc laddr_ptr+1
594-
bcs E_LABEL_DEF::xit
594+
bcs E_LABEL::ret
595595

596596
lda (tmp1), y
597-
beq E_LABEL_DEF::xit
597+
beq E_LABEL::ret
598598

599599
; Note: C = 0 from above!
600600
tya
@@ -606,25 +606,6 @@ start:
606606
.endproc
607607

608608
; Actions for LOOPS
609-
.proc pop_patch_codep
610-
jsr pop_codep
611-
.endproc ; Fall through
612-
.proc patch_codep
613-
; Patches saved position with current position
614-
sta tmp2
615-
stx tmp2+1
616-
jsr get_codep
617-
ldy #0
618-
clc
619-
adc reloc_addr
620-
sta (tmp2),y
621-
iny
622-
txa
623-
adc reloc_addr+1
624-
sta (tmp2),y
625-
clc
626-
rts ; C is cleared on exit!
627-
.endproc
628609

629610
.proc E_PUSH_LT
630611
; Push current position, don't emit
@@ -722,7 +703,8 @@ rtsclc: clc
722703
.proc E_POP_PROC_1
723704
; Pop saved "jump to end" position
724705
lda #LT_PROC_1
725-
jmp pop_patch_codep
706+
.assert LT_PROC_1 = 0, error, "LT_PROC_1 must be 0"
707+
beq pop_patch_codep
726708
.endproc
727709

728710
.proc E_EXIT_LOOP
@@ -827,14 +809,32 @@ comp_y: cpx #$FC
827809
bmi no_elif
828810
lda #LT_ELIF
829811
cmp loop_stk, y
830-
bne no_elif
831-
; ELIF, remove from stack and patch
832-
jmp pop_patch_codep
812+
beq pop_patch_codep ; ELIF, remove from stack and patch
833813
no_elif:
834814
clc
835815
rts
836816
.endproc
837817

818+
.proc pop_patch_codep
819+
jsr pop_codep
820+
.endproc ; Fall through
821+
.proc patch_codep
822+
; Patches saved position with current position
823+
sta tmp2
824+
stx tmp2+1
825+
jsr get_codep
826+
ldy #0
827+
clc
828+
adc reloc_addr
829+
sta (tmp2),y
830+
iny
831+
txa
832+
adc reloc_addr+1
833+
sta (tmp2),y
834+
clc
835+
rts ; C is cleared on exit!
836+
.endproc
837+
838838
.proc E_ELIF
839839
ldy #LT_ELIF
840840
.byte $2C ; Skip 2 bytes over next "LDA"
@@ -857,7 +857,7 @@ type: lda #LT_ELSE
857857
; Parch current position + 2 (over jump)
858858
lda tmp1
859859
ldx tmp1+1
860-
jmp patch_codep
860+
bne patch_codep
861861
.endproc
862862

863863
; vi:syntax=asm_ca65

0 commit comments

Comments
 (0)