OBJS = add.o \
addeqsp.o \
+ addysp.o \
and.o \
aslax1.o \
aslax2.o \
call.o \
compl.o \
dec.o \
+ decsp1.o \
+ decsp2.o \
+ decsp3.o \
+ decsp4.o \
+ decsp5.o \
+ decsp6.o \
+ decsp7.o \
+ decsp8.o \
div.o \
enter.o \
eq.o \
gt.o \
icmp.o \
inc.o \
+ incsp1.o \
+ incsp2.o \
+ incsp3.o \
+ incsp4.o \
+ incsp5.o \
+ incsp6.o \
+ incsp7.o \
+ incsp8.o \
ladd.o \
laddeq.o \
laddeqsp.o \
lsubeqsp.o \
lswap.o \
lswitch.o \
- lt.o \
+ lt.o \
ltest.o \
ludiv.o \
luge.o \
makebool.o \
mod.o \
mul.o \
- ne.o \
- neg.o \
- or.o \
+ ne.o \
+ neg.o \
+ or.o \
+ popa.o \
popsreg.o \
push.o \
pushb.o \
pushbsp.o \
pushw.o \
pushwsp.o \
+ return0.o \
+ return1.o \
rsub.o \
runtime.o \
shelp.o \
shreax1.o \
shreax2.o \
shreax3.o \
+ staspp.o \
staxsp.o \
+ staxspp.o \
steaxsp.o \
sub.o \
subeqsp.o \
+ subysp.o \
swap.o \
switch.o \
test.o \
all: $(OBJS)
clean:
- @rm -f *~ $(COBJS:.o=.s) $(OBJS) $(LOBJS)
+ @rm -f *~ $(COBJS:.o=.s) $(OBJS)
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Increment the stackpointer by value in y
+;
+
+ .export addysp1, addysp
+ .importzp sp
+
+addysp1:
+ iny
+addysp: pha ; Save A
+ clc
+ tya ; Get the value
+ adc sp ; Add low byte
+ sta sp ; Put it back
+ bcc @L1 ; If no carry, we're done
+ inc sp+1 ; Inc high byte
+@L1: pla ; Restore A
+ rts
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Decrement the stackpointer by 1
+;
+
+ .export decsp1
+ .importzp sp
+
+.proc decsp1
+
+ ldy sp
+ bne @L1
+ dec sp+1
+@L1: dec sp
+ rts
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Decrement the stackpointer by 2
+;
+
+ .export decsp2
+ .importzp sp
+
+.proc decsp2
+
+ ldy sp
+ beq @L1
+ dey
+ beq @L2
+ dey
+ sty sp
+ rts
+
+@L1: dey
+@L2: dey
+ sty sp
+ dec sp+1
+ rts
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Decrement the stackpointer by 3
+;
+
+ .export decsp3
+ .import subysp
+
+.proc decsp3
+
+ ldy #3
+ jmp subysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Decrement the stackpointer by 4
+;
+
+ .export decsp4
+ .import subysp
+
+.proc decsp4
+
+ ldy #4
+ jmp subysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Decrement the stackpointer by 5
+;
+
+ .export decsp5
+ .import subysp
+
+.proc decsp5
+
+ ldy #5
+ jmp subysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Decrement the stackpointer by 6
+;
+
+ .export decsp6
+ .import subysp
+
+.proc decsp6
+
+ ldy #6
+ jmp subysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Decrement the stackpointer by 7
+;
+
+ .export decsp7
+ .import subysp
+
+.proc decsp7
+
+ ldy #7
+ jmp subysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Decrement the stackpointer by 8
+;
+
+ .export decsp8
+ .import subysp
+
+.proc decsp8
+
+ ldy #8
+ jmp subysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Increment the stackpointer by 1
+;
+
+ .export incsp1
+ .importzp sp
+
+.proc incsp1
+
+ inc sp
+ bne @L1
+ inc sp+1
+@L1: rts
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Increment the stackpointer by 2. For performance reasons,
+; this modules does also contain the popax function.
+
+ .export popax, incsp2
+ .importzp sp
+
+; Pop a/x from stack. This function will run directly into incsp2
+
+.proc popax
+
+ ldy #1
+ lda (sp),y ; get hi byte
+ tax ; into x
+ dey
+ lda (sp),y ; get lo byte
+
+.endproc
+
+
+
+.proc incsp2
+
+ ldy sp ; 3
+ iny ; 2
+ beq @L1 ; 2
+ iny ; 2
+ beq @L2 ; 2
+ sty sp ; 3
+ rts
+
+@L1: iny ; 2
+@L2: sty sp ; 3
+ inc sp+1 ; 5
+ rts
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Increment the stackpointer by 3
+;
+
+ .export incsp3
+ .import addysp
+
+.proc incsp3
+
+ ldy #3
+ jmp addysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Increment the stackpointer by 4
+;
+
+ .export incsp4
+ .import addysp
+
+.proc incsp4
+
+ ldy #4
+ jmp addysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Increment the stackpointer by 5
+;
+
+ .export incsp5
+ .import addysp
+
+.proc incsp5
+
+ ldy #5
+ jmp addysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Increment the stackpointer by 6
+;
+
+ .export incsp6
+ .import addysp
+
+.proc incsp6
+
+ ldy #6
+ jmp addysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Increment the stackpointer by 7
+;
+
+ .export incsp7
+ .import addysp
+
+.proc incsp7
+
+ ldy #7
+ jmp addysp
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Increment the stackpointer by 8
+;
+
+ .export incsp8
+ .import addysp
+
+.proc incsp8
+
+ ldy #8
+ jmp addysp
+
+.endproc
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Pop a from stack
+;
+
+ .export popa
+ .importzp sp
+
+.proc popa
+
+ ldy #0
+ lda (sp),y ; Read byte
+ inc sp
+ bne @L1
+ inc sp+1
+@L1: rts
+
+.endproc
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Return 0 in a/x
+;
+
+ .export return0
+
+.proc return0
+
+ lda #0
+ tax
+ rts
+
+.endproc
+
+
+
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Return 1 in a/x
+;
+
+ .export return1
+
+.proc return1
+
+ ldx #0
+ lda #1
+ rts
+
+.endproc
+
+
+
+
+
;
- .import ldai, ldaxi, pushax
- .importzp sp, tmp1, tmp2, tmp3, ptr1, ptr4
+ .import popax
+ .importzp tmp1, tmp2, tmp3, ptr4
-; Pop a from stack
- .export popa
-
-popa: ldy #0
- lda (sp),y ; Read byte
- inc sp
- bne *+4
- inc sp+1
- rts
-
-;
-; pop a from stack and load x with zero
-;
-
- .export popa0
-
-popa0: ldy #0
- lda (sp),y ; load low byte
- ldx #0
- beq incsp2
-
-;
-; pop a/x from stack. This function will run directly into incsp2
-;
-
- .export popax ; pop stack into AX
-
-popax: ldy #1
- lda (sp),y ; get hi byte
- tax ; into x
- dey
- lda (sp),y ; get lo byte
-
-;
-; routines for inc/dec'ing sp
-;
-
- .export addysp, addysp1
- .export incsp1, incsp2, incsp3, incsp4
- .export incsp5, incsp6, incsp7, incsp8
-
-; do this by hand, cause it gets used a lot
-
-incsp2: ldy sp ; 3
- iny ; 2
- beq @L1 ; 2
- iny ; 2
- beq @L2 ; 2
- sty sp ; 3
- rts
-
-@L1: iny ; 2
-@L2: sty sp ; 3
- inc sp+1 ; 5
- rts
-
-; Hand optimize this one also...
-
-incsp1: inc sp
- bne *+4
- inc sp+1
- rts
-
-incsp3: ldy #3
- bne addysp
-
-incsp4: ldy #4
- bne addysp
-
-incsp5: ldy #5
- bne addysp
-
-incsp6: ldy #6
- bne addysp
-
-incsp7: ldy #7
- bne addysp
-
-incsp8: ldy #8
- bne addysp
-
-addysp1:
- iny
-addysp: pha ; save A
- clc
- tya ; get the value
- adc sp ; add lo byte
- sta sp ; put it back
- bcc addysp_1 ; if no carry, we're done
- inc sp+1 ; inc hi byte
-addysp_1:
- pla ; get A back
- rts
-
-
-;
-;
- .export subysp ; sub Y from SP
- .export decsp1, decsp2, decsp3, decsp4
- .export decsp5, decsp6, decsp7, decsp8
-
-; Do this one by hand, cause it gets used a lot
-
-decsp2: ldy sp
- beq @L1
- dey
- beq @L2
- dey
- sty sp
- rts
-
-@L1: dey
-@L2: dey
- sty sp
- dec sp+1
- rts
-
-; Decrement by 1 also done as fast as possible
-
-decsp1: ldy sp
- bne *+4
- dec sp+1
- dec sp
- rts
-
-decsp3: ldy #3
- bne subysp
-
-decsp4: ldy #4
- bne subysp
-
-decsp5: ldy #5
- bne subysp
-
-decsp6: ldy #6
- bne subysp
-
-decsp7: ldy #7
- bne subysp
-
-decsp8: ldy #8
-; bne subysp
-
-subysp: pha ; save A
- sty tmp1 ; save the value
- lda sp ; get lo byte
- sec
- sbc tmp1 ; sub y val
- sta sp ; put it back
- bcs *+4
- dec sp+1
- pla ; get A back
- rts ; done
-
;
; Various kinds of store operators
;
sta (ptr4),y
rts
-; ax --> (sp),y
-
-
- .export staxspp ; store AX thru (sp), and pop
-staxspp:
- ldy #0
- pha
- lda (sp),y
- sta ptr1
- iny
- lda (sp),y
- sta ptr1+1
- txa
- sta (ptr1),y
- pla
- dey
- sta (ptr1),y
- jmp incsp2 ; Drop address
-
-
- .export staspp ; store A thru (sp), and pop
-staspp:
- ldy #1
- pha
- lda (sp),y
- sta ptr1+1
- dey
- lda (sp),y
- sta ptr1
- pla
- sta (ptr1),y
- jmp incsp2 ; Drop address
-
-
-;
-; Boolean function return entries.
-;
-
- .export return0, return1
-
-return1:
- ldx #0
- lda #1
- rts
-
-return0:
- lda #0
- tax
- rts
-
-;
-; random stuff
-;
-
-; (a/x) 16--> (--sp)
-
- .export pushwaxi
-pushwaxi: ; push word at (ax)
- jsr ldaxi
- jmp pushax
-
-; (a/x) 8--> (--sp)
-
- .export pushbaxi ; push byte at (ax)
-pushbaxi:
- jsr ldai
- jmp pushax
-
-
-
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Store a indirect into address at top of stack
+;
+
+ .export staspp
+ .import incsp2
+ .importzp sp, ptr1
+
+.proc staspp
+
+ ldy #1
+ pha
+ lda (sp),y
+ sta ptr1+1
+ dey
+ lda (sp),y
+ sta ptr1
+ pla
+ sta (ptr1),y
+ jmp incsp2 ; Drop address
+
+.endproc
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Store a/x indirect into address at top of stack
+;
+
+ .export staxspp
+ .import incsp2
+ .importzp sp, ptr1
+
+.proc staxspp
+
+ ldy #0
+ pha
+ lda (sp),y
+ sta ptr1
+ iny
+ lda (sp),y
+ sta ptr1+1
+ txa
+ sta (ptr1),y
+ pla
+ dey
+ sta (ptr1),y
+ jmp incsp2 ; Drop address
+
+.endproc
+
+
--- /dev/null
+;
+; Ullrich von Bassewitz, 25.10.2000
+;
+; CC65 runtime: Decrement the stackpointer by value in y
+;
+
+ .export subysp
+ .importzp sp, tmp1
+
+.proc subysp
+
+ pha ; Save A
+ sty tmp1 ; Save the value
+ lda sp ; Get lo byte
+ sec
+ sbc tmp1 ; Subtract y value
+ sta sp ; Put result back
+ bcs @L1
+ dec sp+1
+@L1: pla ; Restore A
+ rts ; Done
+
+.endproc
+
+
+
+
+