From dd0ddc94e341d0646b5a65edcb3248dc0cf38ebb Mon Sep 17 00:00:00 2001 From: cuz Date: Wed, 25 Oct 2000 19:53:22 +0000 Subject: [PATCH] More module splits git-svn-id: svn://svn.cc65.org/cc65/trunk@393 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/runtime/Makefile | 33 +++++- libsrc/runtime/addysp.s | 21 ++++ libsrc/runtime/decsp1.s | 23 ++++ libsrc/runtime/decsp2.s | 31 ++++++ libsrc/runtime/decsp3.s | 20 ++++ libsrc/runtime/decsp4.s | 20 ++++ libsrc/runtime/decsp5.s | 20 ++++ libsrc/runtime/decsp6.s | 20 ++++ libsrc/runtime/decsp7.s | 20 ++++ libsrc/runtime/decsp8.s | 20 ++++ libsrc/runtime/incsp1.s | 22 ++++ libsrc/runtime/incsp2.s | 44 ++++++++ libsrc/runtime/incsp3.s | 20 ++++ libsrc/runtime/incsp4.s | 20 ++++ libsrc/runtime/incsp5.s | 20 ++++ libsrc/runtime/incsp6.s | 20 ++++ libsrc/runtime/incsp7.s | 20 ++++ libsrc/runtime/incsp8.s | 17 +++ libsrc/runtime/popa.s | 21 ++++ libsrc/runtime/return0.s | 20 ++++ libsrc/runtime/return1.s | 20 ++++ libsrc/runtime/runtime.s | 228 +-------------------------------------- libsrc/runtime/staspp.s | 26 +++++ libsrc/runtime/staxspp.s | 29 +++++ libsrc/runtime/subysp.s | 28 +++++ 25 files changed, 552 insertions(+), 231 deletions(-) create mode 100644 libsrc/runtime/addysp.s create mode 100644 libsrc/runtime/decsp1.s create mode 100644 libsrc/runtime/decsp2.s create mode 100644 libsrc/runtime/decsp3.s create mode 100644 libsrc/runtime/decsp4.s create mode 100644 libsrc/runtime/decsp5.s create mode 100644 libsrc/runtime/decsp6.s create mode 100644 libsrc/runtime/decsp7.s create mode 100644 libsrc/runtime/decsp8.s create mode 100644 libsrc/runtime/incsp1.s create mode 100644 libsrc/runtime/incsp2.s create mode 100644 libsrc/runtime/incsp3.s create mode 100644 libsrc/runtime/incsp4.s create mode 100644 libsrc/runtime/incsp5.s create mode 100644 libsrc/runtime/incsp6.s create mode 100644 libsrc/runtime/incsp7.s create mode 100644 libsrc/runtime/incsp8.s create mode 100644 libsrc/runtime/popa.s create mode 100644 libsrc/runtime/return0.s create mode 100644 libsrc/runtime/return1.s create mode 100644 libsrc/runtime/staspp.s create mode 100644 libsrc/runtime/staxspp.s create mode 100644 libsrc/runtime/subysp.s diff --git a/libsrc/runtime/Makefile b/libsrc/runtime/Makefile index 6b7fc18a8..ebf386ba7 100644 --- a/libsrc/runtime/Makefile +++ b/libsrc/runtime/Makefile @@ -14,6 +14,7 @@ OBJS = add.o \ addeqsp.o \ + addysp.o \ and.o \ aslax1.o \ aslax2.o \ @@ -33,6 +34,14 @@ OBJS = add.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 \ @@ -40,6 +49,14 @@ OBJS = add.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 \ @@ -84,7 +101,7 @@ OBJS = add.o \ lsubeqsp.o \ lswap.o \ lswitch.o \ - lt.o \ + lt.o \ ltest.o \ ludiv.o \ luge.o \ @@ -96,15 +113,18 @@ OBJS = add.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 \ @@ -116,10 +136,13 @@ OBJS = add.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 \ @@ -136,6 +159,6 @@ OBJS = add.o \ all: $(OBJS) clean: - @rm -f *~ $(COBJS:.o=.s) $(OBJS) $(LOBJS) + @rm -f *~ $(COBJS:.o=.s) $(OBJS) diff --git a/libsrc/runtime/addysp.s b/libsrc/runtime/addysp.s new file mode 100644 index 000000000..b5069f10a --- /dev/null +++ b/libsrc/runtime/addysp.s @@ -0,0 +1,21 @@ +; +; 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 + diff --git a/libsrc/runtime/decsp1.s b/libsrc/runtime/decsp1.s new file mode 100644 index 000000000..ab31a49b0 --- /dev/null +++ b/libsrc/runtime/decsp1.s @@ -0,0 +1,23 @@ +; +; 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 + + + + + diff --git a/libsrc/runtime/decsp2.s b/libsrc/runtime/decsp2.s new file mode 100644 index 000000000..86536c83d --- /dev/null +++ b/libsrc/runtime/decsp2.s @@ -0,0 +1,31 @@ +; +; 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 + + + + + diff --git a/libsrc/runtime/decsp3.s b/libsrc/runtime/decsp3.s new file mode 100644 index 000000000..0b81bea7c --- /dev/null +++ b/libsrc/runtime/decsp3.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Decrement the stackpointer by 3 +; + + .export decsp3 + .import subysp + +.proc decsp3 + + ldy #3 + jmp subysp + +.endproc + + + + + diff --git a/libsrc/runtime/decsp4.s b/libsrc/runtime/decsp4.s new file mode 100644 index 000000000..e2220bf74 --- /dev/null +++ b/libsrc/runtime/decsp4.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Decrement the stackpointer by 4 +; + + .export decsp4 + .import subysp + +.proc decsp4 + + ldy #4 + jmp subysp + +.endproc + + + + + diff --git a/libsrc/runtime/decsp5.s b/libsrc/runtime/decsp5.s new file mode 100644 index 000000000..bece7415c --- /dev/null +++ b/libsrc/runtime/decsp5.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Decrement the stackpointer by 5 +; + + .export decsp5 + .import subysp + +.proc decsp5 + + ldy #5 + jmp subysp + +.endproc + + + + + diff --git a/libsrc/runtime/decsp6.s b/libsrc/runtime/decsp6.s new file mode 100644 index 000000000..964320b40 --- /dev/null +++ b/libsrc/runtime/decsp6.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Decrement the stackpointer by 6 +; + + .export decsp6 + .import subysp + +.proc decsp6 + + ldy #6 + jmp subysp + +.endproc + + + + + diff --git a/libsrc/runtime/decsp7.s b/libsrc/runtime/decsp7.s new file mode 100644 index 000000000..080c9b0c5 --- /dev/null +++ b/libsrc/runtime/decsp7.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Decrement the stackpointer by 7 +; + + .export decsp7 + .import subysp + +.proc decsp7 + + ldy #7 + jmp subysp + +.endproc + + + + + diff --git a/libsrc/runtime/decsp8.s b/libsrc/runtime/decsp8.s new file mode 100644 index 000000000..54192fd51 --- /dev/null +++ b/libsrc/runtime/decsp8.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Decrement the stackpointer by 8 +; + + .export decsp8 + .import subysp + +.proc decsp8 + + ldy #8 + jmp subysp + +.endproc + + + + + diff --git a/libsrc/runtime/incsp1.s b/libsrc/runtime/incsp1.s new file mode 100644 index 000000000..a85092d23 --- /dev/null +++ b/libsrc/runtime/incsp1.s @@ -0,0 +1,22 @@ +; +; 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 + + + + + diff --git a/libsrc/runtime/incsp2.s b/libsrc/runtime/incsp2.s new file mode 100644 index 000000000..959294326 --- /dev/null +++ b/libsrc/runtime/incsp2.s @@ -0,0 +1,44 @@ +; +; 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 + + + + + diff --git a/libsrc/runtime/incsp3.s b/libsrc/runtime/incsp3.s new file mode 100644 index 000000000..90dca0b96 --- /dev/null +++ b/libsrc/runtime/incsp3.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Increment the stackpointer by 3 +; + + .export incsp3 + .import addysp + +.proc incsp3 + + ldy #3 + jmp addysp + +.endproc + + + + + diff --git a/libsrc/runtime/incsp4.s b/libsrc/runtime/incsp4.s new file mode 100644 index 000000000..125c533e7 --- /dev/null +++ b/libsrc/runtime/incsp4.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Increment the stackpointer by 4 +; + + .export incsp4 + .import addysp + +.proc incsp4 + + ldy #4 + jmp addysp + +.endproc + + + + + diff --git a/libsrc/runtime/incsp5.s b/libsrc/runtime/incsp5.s new file mode 100644 index 000000000..df239cf21 --- /dev/null +++ b/libsrc/runtime/incsp5.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Increment the stackpointer by 5 +; + + .export incsp5 + .import addysp + +.proc incsp5 + + ldy #5 + jmp addysp + +.endproc + + + + + diff --git a/libsrc/runtime/incsp6.s b/libsrc/runtime/incsp6.s new file mode 100644 index 000000000..a7ab932dd --- /dev/null +++ b/libsrc/runtime/incsp6.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Increment the stackpointer by 6 +; + + .export incsp6 + .import addysp + +.proc incsp6 + + ldy #6 + jmp addysp + +.endproc + + + + + diff --git a/libsrc/runtime/incsp7.s b/libsrc/runtime/incsp7.s new file mode 100644 index 000000000..417700fe9 --- /dev/null +++ b/libsrc/runtime/incsp7.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Increment the stackpointer by 7 +; + + .export incsp7 + .import addysp + +.proc incsp7 + + ldy #7 + jmp addysp + +.endproc + + + + + diff --git a/libsrc/runtime/incsp8.s b/libsrc/runtime/incsp8.s new file mode 100644 index 000000000..3ec15202e --- /dev/null +++ b/libsrc/runtime/incsp8.s @@ -0,0 +1,17 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Increment the stackpointer by 8 +; + + .export incsp8 + .import addysp + +.proc incsp8 + + ldy #8 + jmp addysp + +.endproc + + diff --git a/libsrc/runtime/popa.s b/libsrc/runtime/popa.s new file mode 100644 index 000000000..6c7c9308b --- /dev/null +++ b/libsrc/runtime/popa.s @@ -0,0 +1,21 @@ +; +; 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 + + diff --git a/libsrc/runtime/return0.s b/libsrc/runtime/return0.s new file mode 100644 index 000000000..37c260804 --- /dev/null +++ b/libsrc/runtime/return0.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Return 0 in a/x +; + + .export return0 + +.proc return0 + + lda #0 + tax + rts + +.endproc + + + + + diff --git a/libsrc/runtime/return1.s b/libsrc/runtime/return1.s new file mode 100644 index 000000000..2987de30c --- /dev/null +++ b/libsrc/runtime/return1.s @@ -0,0 +1,20 @@ +; +; Ullrich von Bassewitz, 25.10.2000 +; +; CC65 runtime: Return 1 in a/x +; + + .export return1 + +.proc return1 + + ldx #0 + lda #1 + rts + +.endproc + + + + + diff --git a/libsrc/runtime/runtime.s b/libsrc/runtime/runtime.s index 095da2588..db7137345 100644 --- a/libsrc/runtime/runtime.s +++ b/libsrc/runtime/runtime.s @@ -3,164 +3,10 @@ ; - .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 ; @@ -193,73 +39,3 @@ staspic: 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 - - - diff --git a/libsrc/runtime/staspp.s b/libsrc/runtime/staspp.s new file mode 100644 index 000000000..a664dde9b --- /dev/null +++ b/libsrc/runtime/staspp.s @@ -0,0 +1,26 @@ +; +; 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 + + diff --git a/libsrc/runtime/staxspp.s b/libsrc/runtime/staxspp.s new file mode 100644 index 000000000..35926fd76 --- /dev/null +++ b/libsrc/runtime/staxspp.s @@ -0,0 +1,29 @@ +; +; 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 + + diff --git a/libsrc/runtime/subysp.s b/libsrc/runtime/subysp.s new file mode 100644 index 000000000..b173daf69 --- /dev/null +++ b/libsrc/runtime/subysp.s @@ -0,0 +1,28 @@ +; +; 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 + + + + + -- 2.39.5