1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-28 19:29:53 +00:00

Runtime function improvements by Piotr Fusik

git-svn-id: svn://svn.cc65.org/cc65/trunk@2577 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-10-28 08:47:47 +00:00
parent 4319fd9cc7
commit 6d8cdae722
7 changed files with 86 additions and 90 deletions

View File

@ -1,5 +1,6 @@
;
; Ullrich von Bassewitz, 06.08.1998
; Piotr Fusik, 24.10.2003
; originally by Ullrich von Bassewitz
;
; CC65 runtime: Scale the primary register by 8
;
@ -8,17 +9,15 @@
.importzp tmp1
asrax3: stx tmp1
cpx #$80 ; Put bit 7 into carry
ror tmp1
ror a
cpx #$80 ; Put bit 7 into carry
ror tmp1
ror a
cpx #$80
ror tmp1
ror a
cpx #$80
ror tmp1
ror a
ldx tmp1
cpx #$80
ror tmp1
ror a
ldx tmp1
cpx #$80
ror tmp1
ror a
ldx tmp1
rts
rts

View File

@ -1,28 +1,26 @@
;
; Ullrich von Bassewitz, 25.07.2001
; Piotr Fusik, 24.10.2003
; originally by Ullrich von Bassewitz
;
; CC65 runtime: Scale the primary register by 16
;
.export asrax4
.importzp tmp1
.export asrax4
.importzp tmp1
asrax4: stx tmp1
cpx #$80 ; Put bit 7 into carry
ror tmp1
ror a
cpx #$80 ; Put bit 7 into carry
ror tmp1
ror a
cpx #$80
ror tmp1
ror a
cpx #$80
ror tmp1
ror a
cpx #$80
ror tmp1
ror a
ldx tmp1
cpx #$80
ror tmp1
ror a
ldx tmp1
cpx #$80
ror tmp1
ror a
ldx tmp1
cpx #$80
ror tmp1
ror a
ldx tmp1
rts
rts

View File

@ -1,15 +1,16 @@
;
; Ullrich von Bassewitz, 04.10.2001
; Piotr Fusik, 24.10.2003
; originally by Ullrich von Bassewitz
;
; CC65 runtime: Multiply the primary register
; CC65 runtime: Multiply the primary register by 10
;
.export mulax10
.export mulax10
.importzp ptr1
.proc mulax10
sta ptr1
sta ptr1
stx ptr1+1
asl a
rol ptr1+1
@ -17,14 +18,13 @@
rol ptr1+1
clc
adc ptr1
pha
sta ptr1
txa
adc ptr1+1
sta ptr1+1
pla
asl a
rol ptr1+1
ldx ptr1+1
asl ptr1
rol a
tax
lda ptr1
rts
.endproc

View File

@ -1,28 +1,28 @@
;
; Ullrich von Bassewitz, 16.03.2002
; Piotr Fusik, 24.10.2003
; originally by Ullrich von Bassewitz
;
; CC65 runtime: Multiply the primary register
; CC65 runtime: Multiply the primary register by 6
;
.export mulax6
.importzp ptr1
.export mulax6
.importzp ptr1
.proc mulax6
sta ptr1
sta ptr1
stx ptr1+1
asl a
rol ptr1+1
clc
adc ptr1
pha
sta ptr1
txa
adc ptr1+1
sta ptr1+1
pla
asl a
rol ptr1+1
ldx ptr1+1
asl ptr1
rol a
tax
lda ptr1
rts
.endproc

View File

@ -1,28 +1,29 @@
;
; Ullrich von Bassewitz, 16.03.2002
; Piotr Fusik, 24.10.2003
; originally by Ullrich von Bassewitz
;
; CC65 runtime: Multiply the primary register
; CC65 runtime: Multiply the primary register by 7
;
.export mulax7
.importzp ptr1, tmp1
.export mulax7
.importzp ptr1
.proc mulax7
sta ptr1
stx ptr1+1
stx tmp1
asl a
rol tmp1 ; * 2
asl a
rol tmp1 ; * 4
rol ptr1+1 ; * 2
asl a
rol tmp1 ; * 8
rol ptr1+1 ; * 4
asl a
rol ptr1+1 ; * 8
sec
sbc ptr1
pha
lda tmp1
sbc ptr1+1 ; * (8 - 1)
txa
eor #$ff
adc ptr1+1 ; * (8 - 1)
tax
pla
rts

View File

@ -1,27 +1,27 @@
;
; Ullrich von Bassewitz, 16.03.2002
; Piotr Fusik, 24.10.2003
; originally by Ullrich von Bassewitz
;
; CC65 runtime: Multiply the primary register
; CC65 runtime: Multiply the primary register by 9
;
.export mulax9
.importzp ptr1, tmp1
.export mulax9
.importzp ptr1
.proc mulax9
sta ptr1
stx ptr1+1
stx tmp1
asl a
rol tmp1 ; * 2
asl a
rol tmp1 ; * 4
asl a
rol tmp1 ; * 8
sta ptr1
stx ptr1+1
asl a
rol ptr1+1 ; * 2
asl a
rol ptr1+1 ; * 4
asl a
rol ptr1+1 ; * 8
clc
adc ptr1 ; * (8+1)
adc ptr1 ; * (8+1)
pha
lda tmp1
txa
adc ptr1+1
tax
pla

View File

@ -1,26 +1,24 @@
;
; Ullrich von Bassewitz, 25.10.2000
; Piotr Fusik, 24.10.2003
; originally by Ullrich von Bassewitz
;
; CC65 runtime: Decrement the stackpointer by value in y
;
.export subysp
.importzp sp, tmp1
.export subysp
.importzp sp
.proc subysp
sty tmp1 ; Save the value
lda sp ; Get lo byte
tya
eor #$ff
sec
sbc tmp1 ; Subtract y value
sta sp ; Put result back
adc sp
sta sp
bcs @L1
dec sp+1
@L1: rts ; Done
@L1: rts
.endproc