mirror of
https://github.com/cc65/cc65.git
synced 2026-04-20 17:20:49 +00:00
Removed (pretty inconsistently used) tab chars from source code base.
This commit is contained in:
+21
-21
@@ -7,33 +7,33 @@
|
||||
; Make this as fast as possible, even if it needs more space since it's
|
||||
; called a lot!
|
||||
|
||||
.export tosadda0, tosaddax
|
||||
.importzp sp
|
||||
.export tosadda0, tosaddax
|
||||
.importzp sp
|
||||
|
||||
.macpack cpu
|
||||
|
||||
tosadda0:
|
||||
ldx #0
|
||||
ldx #0
|
||||
tosaddax:
|
||||
clc
|
||||
clc
|
||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||
adc (sp) ; 65SC02 version - saves 2 cycles
|
||||
ldy #1
|
||||
adc (sp) ; 65SC02 version - saves 2 cycles
|
||||
ldy #1
|
||||
.else
|
||||
ldy #0
|
||||
adc (sp),y ; lo byte
|
||||
iny
|
||||
ldy #0
|
||||
adc (sp),y ; lo byte
|
||||
iny
|
||||
.endif
|
||||
pha ; save it
|
||||
txa
|
||||
adc (sp),y ; hi byte
|
||||
tax
|
||||
clc
|
||||
lda sp
|
||||
adc #2
|
||||
sta sp
|
||||
bcc L1
|
||||
inc sp+1
|
||||
L1: pla ; Restore low byte
|
||||
rts
|
||||
pha ; save it
|
||||
txa
|
||||
adc (sp),y ; hi byte
|
||||
tax
|
||||
clc
|
||||
lda sp
|
||||
adc #2
|
||||
sta sp
|
||||
bcc L1
|
||||
inc sp+1
|
||||
L1: pla ; Restore low byte
|
||||
rts
|
||||
|
||||
|
||||
+14
-14
@@ -4,21 +4,21 @@
|
||||
; CC65 runtime: += operator for ints on the stack
|
||||
;
|
||||
|
||||
.export addeq0sp, addeqysp
|
||||
.importzp sp
|
||||
.export addeq0sp, addeqysp
|
||||
.importzp sp
|
||||
|
||||
addeq0sp:
|
||||
ldy #0
|
||||
ldy #0
|
||||
addeqysp:
|
||||
clc
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
pha
|
||||
iny
|
||||
txa
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
tax
|
||||
pla
|
||||
rts
|
||||
clc
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
pha
|
||||
iny
|
||||
txa
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
tax
|
||||
pla
|
||||
rts
|
||||
|
||||
|
||||
+12
-12
@@ -4,18 +4,18 @@
|
||||
; CC65 runtime: Increment the stackpointer by value in y
|
||||
;
|
||||
|
||||
.export addysp1, addysp
|
||||
.importzp sp
|
||||
.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
|
||||
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
|
||||
|
||||
|
||||
+12
-12
@@ -4,21 +4,21 @@
|
||||
; CC65 runtime: Convert char in ax into a long
|
||||
;
|
||||
|
||||
.export aulong, along
|
||||
.importzp sreg
|
||||
.export aulong, along
|
||||
.importzp sreg
|
||||
|
||||
; Convert A from char to long in EAX
|
||||
|
||||
aulong: ldx #0
|
||||
stx sreg
|
||||
stx sreg+1
|
||||
rts
|
||||
aulong: ldx #0
|
||||
stx sreg
|
||||
stx sreg+1
|
||||
rts
|
||||
|
||||
along: cmp #$80 ; Positive?
|
||||
bcc aulong ; Yes, handle like unsigned type
|
||||
ldx #$ff
|
||||
stx sreg
|
||||
stx sreg+1
|
||||
rts
|
||||
along: cmp #$80 ; Positive?
|
||||
bcc aulong ; Yes, handle like unsigned type
|
||||
ldx #$ff
|
||||
stx sreg
|
||||
stx sreg+1
|
||||
rts
|
||||
|
||||
|
||||
|
||||
+15
-15
@@ -4,27 +4,27 @@
|
||||
; CC65 runtime: and on ints
|
||||
;
|
||||
|
||||
.export tosanda0, tosandax
|
||||
.import addysp1
|
||||
.importzp sp, ptr4
|
||||
.export tosanda0, tosandax
|
||||
.import addysp1
|
||||
.importzp sp, ptr4
|
||||
|
||||
.macpack cpu
|
||||
|
||||
tosanda0:
|
||||
ldx #$00
|
||||
ldx #$00
|
||||
tosandax:
|
||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||
and (sp) ; 65SC02 version, saves 2 cycles and 1 byte
|
||||
ldy #1
|
||||
and (sp) ; 65SC02 version, saves 2 cycles and 1 byte
|
||||
ldy #1
|
||||
.else
|
||||
ldy #0
|
||||
and (sp),y
|
||||
iny
|
||||
ldy #0
|
||||
and (sp),y
|
||||
iny
|
||||
.endif
|
||||
pha
|
||||
txa
|
||||
and (sp),y
|
||||
tax
|
||||
pla
|
||||
jmp addysp1 ; drop TOS, set condition codes
|
||||
pha
|
||||
txa
|
||||
and (sp),y
|
||||
tax
|
||||
pla
|
||||
jmp addysp1 ; drop TOS, set condition codes
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
; CC65 runtime: Scale the primary register
|
||||
;
|
||||
|
||||
.export aslax1, shlax1
|
||||
.importzp tmp1
|
||||
|
||||
.export aslax1, shlax1
|
||||
.importzp tmp1
|
||||
|
||||
aslax1:
|
||||
shlax1: stx tmp1
|
||||
asl A
|
||||
rol tmp1
|
||||
ldx tmp1
|
||||
rts
|
||||
shlax1: stx tmp1
|
||||
asl A
|
||||
rol tmp1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Scale the primary register by 4
|
||||
;
|
||||
|
||||
.export aslax2, shlax2
|
||||
.importzp tmp1
|
||||
.export aslax2, shlax2
|
||||
.importzp tmp1
|
||||
|
||||
aslax2:
|
||||
shlax2: stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
ldx tmp1
|
||||
rts
|
||||
shlax2: stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+11
-11
@@ -4,17 +4,17 @@
|
||||
; CC65 runtime: Scale the primary register by 8
|
||||
;
|
||||
|
||||
.export aslax3, shlax3
|
||||
.importzp tmp1
|
||||
.export aslax3, shlax3
|
||||
.importzp tmp1
|
||||
|
||||
aslax3:
|
||||
shlax3: stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
ldx tmp1
|
||||
rts
|
||||
shlax3: stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+13
-13
@@ -4,19 +4,19 @@
|
||||
; CC65 runtime: Scale the primary register by 16
|
||||
;
|
||||
|
||||
.export aslax4, shlax4
|
||||
.importzp tmp1
|
||||
.export aslax4, shlax4
|
||||
.importzp tmp1
|
||||
|
||||
aslax4:
|
||||
shlax4: stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
ldx tmp1
|
||||
rts
|
||||
shlax4: stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
; CC65 runtime: Scale the 32 bit primary register by 2
|
||||
;
|
||||
|
||||
.export asleax1, shleax1
|
||||
.importzp sreg, tmp1
|
||||
.export asleax1, shleax1
|
||||
.importzp sreg, tmp1
|
||||
|
||||
asleax1:
|
||||
shleax1:
|
||||
stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
ldx tmp1
|
||||
rts
|
||||
stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+13
-13
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Scale the 32 bit primary register by 4
|
||||
;
|
||||
|
||||
.export asleax2, shleax2
|
||||
.importzp sreg, tmp1
|
||||
.export asleax2, shleax2
|
||||
.importzp sreg, tmp1
|
||||
|
||||
asleax2:
|
||||
shleax2:
|
||||
stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
ldx tmp1
|
||||
rts
|
||||
stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+17
-17
@@ -4,24 +4,24 @@
|
||||
; CC65 runtime: Scale the 32 bit primary register by 8
|
||||
;
|
||||
|
||||
.export asleax3, shleax3
|
||||
.importzp sreg, tmp1
|
||||
.export asleax3, shleax3
|
||||
.importzp sreg, tmp1
|
||||
|
||||
asleax3:
|
||||
shleax3:
|
||||
stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
ldx tmp1
|
||||
rts
|
||||
stx tmp1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+12
-12
@@ -4,19 +4,19 @@
|
||||
; CC65 runtime: Scale the 32 bit primary register by 16
|
||||
;
|
||||
|
||||
.export asleax4, shleax4
|
||||
.importzp sreg, tmp1
|
||||
.export asleax4, shleax4
|
||||
.importzp sreg, tmp1
|
||||
|
||||
asleax4:
|
||||
shleax4:
|
||||
stx tmp1
|
||||
ldx #4
|
||||
@L1: asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
dex
|
||||
bne @L1
|
||||
ldx tmp1
|
||||
rts
|
||||
stx tmp1
|
||||
ldx #4
|
||||
@L1: asl a
|
||||
rol tmp1
|
||||
rol sreg
|
||||
rol sreg+1
|
||||
dex
|
||||
bne @L1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
;
|
||||
|
||||
|
||||
.export tosasrax, asraxy
|
||||
.import popax
|
||||
.importzp tmp1
|
||||
.export tosasrax, asraxy
|
||||
.import popax
|
||||
.importzp tmp1
|
||||
|
||||
tosasrax:
|
||||
sta tmp1 ; Save shift count
|
||||
@@ -69,10 +69,10 @@ L7: cpx #$80 ; Sign bit into carry
|
||||
ror tmp1
|
||||
ror a
|
||||
dey
|
||||
bne L7
|
||||
bne L7
|
||||
|
||||
; Done with shift
|
||||
|
||||
ldx tmp1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
; CC65 runtime: Scale the primary register
|
||||
;
|
||||
|
||||
.export asrax1
|
||||
.importzp tmp1
|
||||
.export asrax1
|
||||
.importzp tmp1
|
||||
|
||||
asrax1: stx tmp1
|
||||
cpx #$80 ; Put bit 7 into carry
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
asrax1: stx tmp1
|
||||
cpx #$80 ; Put bit 7 into carry
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+11
-11
@@ -4,16 +4,16 @@
|
||||
; CC65 runtime: Scale the primary register by 4
|
||||
;
|
||||
|
||||
.export asrax2
|
||||
.importzp tmp1
|
||||
.export asrax2
|
||||
.importzp tmp1
|
||||
|
||||
asrax2: stx tmp1
|
||||
cpx #$80 ; Put bit 7 into carry
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
asrax2: stx tmp1
|
||||
cpx #$80 ; Put bit 7 into carry
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+14
-14
@@ -5,19 +5,19 @@
|
||||
; CC65 runtime: Scale the primary register by 8
|
||||
;
|
||||
|
||||
.export asrax3
|
||||
.importzp tmp1
|
||||
.export asrax3
|
||||
.importzp tmp1
|
||||
|
||||
asrax3: stx tmp1
|
||||
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
|
||||
rts
|
||||
asrax3: stx tmp1
|
||||
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
|
||||
rts
|
||||
|
||||
|
||||
+17
-17
@@ -5,22 +5,22 @@
|
||||
; 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
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
asrax4: stx tmp1
|
||||
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
|
||||
rts
|
||||
|
||||
|
||||
+11
-11
@@ -4,17 +4,17 @@
|
||||
; CC65 runtime: Scale the primary register
|
||||
;
|
||||
|
||||
.export asreax1
|
||||
.importzp sreg, tmp1
|
||||
.export asreax1
|
||||
.importzp sreg, tmp1
|
||||
|
||||
asreax1:
|
||||
stx tmp1
|
||||
ldx sreg+1
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
stx tmp1
|
||||
ldx sreg+1
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+16
-16
@@ -4,22 +4,22 @@
|
||||
; CC65 runtime: Scale the 32 bit primary register by 4
|
||||
;
|
||||
|
||||
.export asreax2
|
||||
.importzp sreg, tmp1
|
||||
.export asreax2
|
||||
.importzp sreg, tmp1
|
||||
|
||||
asreax2:
|
||||
stx tmp1
|
||||
ldx sreg+1
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
stx tmp1
|
||||
ldx sreg+1
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+21
-21
@@ -4,27 +4,27 @@
|
||||
; CC65 runtime: Scale the 32 bit primary register by 8
|
||||
;
|
||||
|
||||
.export asreax3
|
||||
.importzp sreg, tmp1
|
||||
.export asreax3
|
||||
.importzp sreg, tmp1
|
||||
|
||||
asreax3:
|
||||
stx tmp1
|
||||
ldx sreg+1
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
stx tmp1
|
||||
ldx sreg+1
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+14
-14
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Scale the 32 bit primary register by 16
|
||||
;
|
||||
|
||||
.export asreax4
|
||||
.importzp sreg, tmp1
|
||||
.export asreax4
|
||||
.importzp sreg, tmp1
|
||||
|
||||
asreax4:
|
||||
stx tmp1
|
||||
ldx sreg+1
|
||||
ldy #4
|
||||
@L1: cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
dey
|
||||
bne @L1
|
||||
ldx tmp1
|
||||
rts
|
||||
stx tmp1
|
||||
ldx sreg+1
|
||||
ldy #4
|
||||
@L1: cpx #$80 ; Get bit 7 into carry
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror tmp1
|
||||
ror a
|
||||
dey
|
||||
bne @L1
|
||||
ldx tmp1
|
||||
rts
|
||||
|
||||
|
||||
+12
-12
@@ -4,23 +4,23 @@
|
||||
; CC65 runtime: Convert int in ax into a long
|
||||
;
|
||||
|
||||
.export axulong, axlong
|
||||
.importzp sreg
|
||||
.export axulong, axlong
|
||||
.importzp sreg
|
||||
|
||||
; Convert AX from int to long in EAX
|
||||
|
||||
axulong:
|
||||
ldy #0
|
||||
sty sreg
|
||||
sty sreg+1
|
||||
rts
|
||||
ldy #0
|
||||
sty sreg
|
||||
sty sreg+1
|
||||
rts
|
||||
|
||||
axlong: cpx #$80 ; Positive?
|
||||
bcc axulong ; Yes, handle like unsigned type
|
||||
ldy #$ff
|
||||
sty sreg
|
||||
sty sreg+1
|
||||
rts
|
||||
axlong: cpx #$80 ; Positive?
|
||||
bcc axulong ; Yes, handle like unsigned type
|
||||
ldy #$ff
|
||||
sty sreg
|
||||
sty sreg+1
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
+11
-11
@@ -4,17 +4,17 @@
|
||||
; CC65 runtime: boolean negation
|
||||
;
|
||||
|
||||
.export bnega, bnegax
|
||||
.import return0, return1
|
||||
.export bnega, bnegax
|
||||
.import return0, return1
|
||||
|
||||
bnegax: cpx #0
|
||||
bne L0
|
||||
bnega: tax
|
||||
bne L0
|
||||
L1: lda #1 ; Zero already in X
|
||||
rts
|
||||
bnegax: cpx #0
|
||||
bne L0
|
||||
bnega: tax
|
||||
bne L0
|
||||
L1: lda #1 ; Zero already in X
|
||||
rts
|
||||
|
||||
L0: ldx #0
|
||||
txa
|
||||
rts
|
||||
L0: ldx #0
|
||||
txa
|
||||
rts
|
||||
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Load a from stack slot and push as byte
|
||||
;
|
||||
|
||||
.export bpushbsp, bpushbysp
|
||||
.import pusha
|
||||
.importzp sp
|
||||
.export bpushbsp, bpushbysp
|
||||
.import pusha
|
||||
.importzp sp
|
||||
|
||||
bpushbsp:
|
||||
ldy #0
|
||||
ldy #0
|
||||
bpushbysp:
|
||||
lda (sp),y
|
||||
jmp pusha
|
||||
lda (sp),y
|
||||
jmp pusha
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
; CC65 runtime: call function via pointer in ax
|
||||
;
|
||||
|
||||
.export callax
|
||||
.importzp ptr1
|
||||
.export callax
|
||||
.importzp ptr1
|
||||
|
||||
callax: sta ptr1
|
||||
stx ptr1+1
|
||||
jmp (ptr1) ; jump there
|
||||
callax: sta ptr1
|
||||
stx ptr1+1
|
||||
jmp (ptr1) ; jump there
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
;
|
||||
|
||||
|
||||
.export callmain
|
||||
.export __argc, __argv
|
||||
.export callmain
|
||||
.export __argc, __argv
|
||||
|
||||
.import _main, pushax
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
ldx __argv+1
|
||||
jsr pushax ; Push argv
|
||||
|
||||
ldy #4 ; Argument size
|
||||
ldy #4 ; Argument size
|
||||
jmp _main
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
; CC65 runtime: integer complement
|
||||
;
|
||||
|
||||
.export complax
|
||||
.export complax
|
||||
|
||||
complax:
|
||||
eor #$FF ; Not A
|
||||
pha
|
||||
txa
|
||||
eor #$FF ; Not X
|
||||
tax
|
||||
pla
|
||||
rts
|
||||
eor #$FF ; Not A
|
||||
pha
|
||||
txa
|
||||
eor #$FF ; Not X
|
||||
tax
|
||||
pla
|
||||
rts
|
||||
|
||||
|
||||
+24
-24
@@ -13,10 +13,10 @@
|
||||
; code.
|
||||
|
||||
|
||||
.export initlib, donelib, condes
|
||||
.export initlib, donelib, condes
|
||||
|
||||
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
|
||||
.import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
|
||||
.import __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
|
||||
.import __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
|
||||
|
||||
.macpack cpu
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
|
||||
.segment "INIT"
|
||||
|
||||
.proc initlib
|
||||
.proc initlib
|
||||
|
||||
ldy #<(__CONSTRUCTOR_COUNT__*2)
|
||||
beq exit
|
||||
lda #<__CONSTRUCTOR_TABLE__
|
||||
ldx #>__CONSTRUCTOR_TABLE__
|
||||
ldy #<(__CONSTRUCTOR_COUNT__*2)
|
||||
beq exit
|
||||
lda #<__CONSTRUCTOR_TABLE__
|
||||
ldx #>__CONSTRUCTOR_TABLE__
|
||||
jmp condes
|
||||
exit: rts
|
||||
|
||||
@@ -42,13 +42,13 @@ exit: rts
|
||||
|
||||
.code
|
||||
|
||||
.proc donelib
|
||||
.proc donelib
|
||||
|
||||
ldy #<(__DESTRUCTOR_COUNT__*2)
|
||||
beq exit
|
||||
lda #<__DESTRUCTOR_TABLE__
|
||||
ldx #>__DESTRUCTOR_TABLE__
|
||||
jmp condes
|
||||
ldy #<(__DESTRUCTOR_COUNT__*2)
|
||||
beq exit
|
||||
lda #<__DESTRUCTOR_TABLE__
|
||||
ldx #>__DESTRUCTOR_TABLE__
|
||||
jmp condes
|
||||
exit: rts
|
||||
|
||||
.endproc
|
||||
@@ -61,22 +61,22 @@ exit: rts
|
||||
|
||||
.data
|
||||
|
||||
.proc condes
|
||||
.proc condes
|
||||
|
||||
sta fetch1+1
|
||||
stx fetch1+2
|
||||
sta fetch2+1
|
||||
stx fetch2+2
|
||||
sta fetch1+1
|
||||
stx fetch1+2
|
||||
sta fetch2+1
|
||||
stx fetch2+2
|
||||
loop: dey
|
||||
fetch1: lda $FFFF,y ; Patched at runtime
|
||||
sta jmpvec+2
|
||||
dey
|
||||
dey
|
||||
fetch2: lda $FFFF,y ; Patched at runtime
|
||||
sta jmpvec+1
|
||||
sty index+1
|
||||
jmpvec: jsr $FFFF ; Patched at runtime
|
||||
index: ldy #$FF ; Patched at runtime
|
||||
bne loop
|
||||
sty index+1
|
||||
jmpvec: jsr $FFFF ; Patched at runtime
|
||||
index: ldy #$FF ; Patched at runtime
|
||||
bne loop
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Decrement ax by 1
|
||||
;
|
||||
|
||||
.export decax1
|
||||
.export decax1
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc decax1
|
||||
.proc decax1
|
||||
|
||||
sub #1
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
sub #1
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Decrement ax by 2
|
||||
;
|
||||
|
||||
.export decax2
|
||||
.export decax2
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc decax2
|
||||
.proc decax2
|
||||
|
||||
sub #2
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
sub #2
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Decrement ax by 3
|
||||
;
|
||||
|
||||
.export decax3
|
||||
.export decax3
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc decax3
|
||||
.proc decax3
|
||||
|
||||
sub #3
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
sub #3
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Decrement ax by 4
|
||||
;
|
||||
|
||||
.export decax4
|
||||
.export decax4
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc decax4
|
||||
.proc decax4
|
||||
|
||||
sub #4
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
sub #4
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Decrement ax by 5
|
||||
;
|
||||
|
||||
.export decax5
|
||||
.export decax5
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc decax5
|
||||
.proc decax5
|
||||
|
||||
sub #5
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
sub #5
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Decrement ax by 6
|
||||
;
|
||||
|
||||
.export decax6
|
||||
.export decax6
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc decax6
|
||||
.proc decax6
|
||||
|
||||
sub #6
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
sub #6
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Decrement ax by 7
|
||||
;
|
||||
|
||||
.export decax7
|
||||
.export decax7
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc decax7
|
||||
.proc decax7
|
||||
|
||||
sub #7
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
sub #7
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Decrement ax by 8
|
||||
;
|
||||
|
||||
.export decax8
|
||||
.export decax8
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc decax8
|
||||
.proc decax8
|
||||
|
||||
sub #8
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
sub #8
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,18 +4,18 @@
|
||||
; CC65 runtime: Decrement ax by value in Y
|
||||
;
|
||||
|
||||
.export decaxy
|
||||
.importzp tmp1
|
||||
.export decaxy
|
||||
.importzp tmp1
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc decaxy
|
||||
.proc decaxy
|
||||
|
||||
sty tmp1
|
||||
sub tmp1
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
sty tmp1
|
||||
sub tmp1
|
||||
bcs @L9
|
||||
dex
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Decrement the stackpointer by 1
|
||||
;
|
||||
|
||||
.export decsp1
|
||||
.importzp sp
|
||||
.export decsp1
|
||||
.importzp sp
|
||||
|
||||
.proc decsp1
|
||||
.proc decsp1
|
||||
|
||||
ldy sp
|
||||
bne @L1
|
||||
dec sp+1
|
||||
@L1: dec sp
|
||||
rts
|
||||
ldy sp
|
||||
bne @L1
|
||||
dec sp+1
|
||||
@L1: dec sp
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+11
-11
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Decrement the stackpointer by 2
|
||||
;
|
||||
|
||||
.export decsp2
|
||||
.importzp sp
|
||||
.export decsp2
|
||||
.importzp sp
|
||||
|
||||
.proc decsp2
|
||||
.proc decsp2
|
||||
|
||||
lda sp
|
||||
sec
|
||||
sbc #2
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
lda sp
|
||||
sec
|
||||
sbc #2
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
+11
-11
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Decrement the stackpointer by 3
|
||||
;
|
||||
|
||||
.export decsp3
|
||||
.importzp sp
|
||||
.export decsp3
|
||||
.importzp sp
|
||||
|
||||
.proc decsp3
|
||||
.proc decsp3
|
||||
|
||||
lda sp
|
||||
sec
|
||||
sbc #3
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
lda sp
|
||||
sec
|
||||
sbc #3
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
+11
-11
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Decrement the stackpointer by 4
|
||||
;
|
||||
|
||||
.export decsp4
|
||||
.importzp sp
|
||||
.export decsp4
|
||||
.importzp sp
|
||||
|
||||
.proc decsp4
|
||||
.proc decsp4
|
||||
|
||||
lda sp
|
||||
sec
|
||||
sbc #4
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
lda sp
|
||||
sec
|
||||
sbc #4
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
+11
-11
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Decrement the stackpointer by 5
|
||||
;
|
||||
|
||||
.export decsp5
|
||||
.importzp sp
|
||||
.export decsp5
|
||||
.importzp sp
|
||||
|
||||
.proc decsp5
|
||||
.proc decsp5
|
||||
|
||||
lda sp
|
||||
sec
|
||||
sbc #5
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
lda sp
|
||||
sec
|
||||
sbc #5
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
+11
-11
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Decrement the stackpointer by 6
|
||||
;
|
||||
|
||||
.export decsp6
|
||||
.importzp sp
|
||||
.export decsp6
|
||||
.importzp sp
|
||||
|
||||
.proc decsp6
|
||||
.proc decsp6
|
||||
|
||||
lda sp
|
||||
sec
|
||||
sbc #6
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
lda sp
|
||||
sec
|
||||
sbc #6
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
+11
-11
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Decrement the stackpointer by 7
|
||||
;
|
||||
|
||||
.export decsp7
|
||||
.importzp sp
|
||||
.export decsp7
|
||||
.importzp sp
|
||||
|
||||
.proc decsp7
|
||||
.proc decsp7
|
||||
|
||||
lda sp
|
||||
sec
|
||||
sbc #7
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
lda sp
|
||||
sec
|
||||
sbc #7
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
+11
-11
@@ -4,20 +4,20 @@
|
||||
; CC65 runtime: Decrement the stackpointer by 8
|
||||
;
|
||||
|
||||
.export decsp8
|
||||
.importzp sp
|
||||
.export decsp8
|
||||
.importzp sp
|
||||
|
||||
.proc decsp8
|
||||
.proc decsp8
|
||||
|
||||
lda sp
|
||||
sec
|
||||
sbc #8
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
lda sp
|
||||
sec
|
||||
sbc #8
|
||||
sta sp
|
||||
bcc @L1
|
||||
rts
|
||||
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
@L1: dec sp+1
|
||||
rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
; When negating values, we will ignore the possibility here, that one of the
|
||||
; values if $8000, in which case the negate will fail.
|
||||
|
||||
.export tosdiva0, tosdivax
|
||||
.import popsargs, udiv16, negax
|
||||
.importzp sreg, tmp1, tmp2
|
||||
.export tosdiva0, tosdivax
|
||||
.import popsargs, udiv16, negax
|
||||
.importzp sreg, tmp1, tmp2
|
||||
|
||||
tosdiva0:
|
||||
ldx #0
|
||||
ldx #0
|
||||
tosdivax:
|
||||
jsr popsargs ; Get arguments from stack, adjust sign
|
||||
jsr udiv16 ; Do the division
|
||||
jsr popsargs ; Get arguments from stack, adjust sign
|
||||
jsr udiv16 ; Do the division
|
||||
ldx sreg+1 ; Load high byte of result
|
||||
|
||||
; Adjust the sign of the result. tmp1 contains the high byte of the left
|
||||
|
||||
+10
-10
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: function prologue
|
||||
;
|
||||
|
||||
.export enter
|
||||
.importzp sp
|
||||
.export enter
|
||||
.importzp sp
|
||||
|
||||
enter: tya ; get arg size
|
||||
ldy sp
|
||||
bne L1
|
||||
dec sp+1
|
||||
L1: dec sp
|
||||
ldy #0
|
||||
sta (sp),y ; Store the arg count
|
||||
rts
|
||||
enter: tya ; get arg size
|
||||
ldy sp
|
||||
bne L1
|
||||
dec sp+1
|
||||
L1: dec sp
|
||||
ldy #0
|
||||
sta (sp),y ; Store the arg count
|
||||
rts
|
||||
|
||||
|
||||
+7
-7
@@ -4,14 +4,14 @@
|
||||
; CC65 runtime: Compare == for ints
|
||||
;
|
||||
|
||||
.export toseq00, toseqa0, toseqax
|
||||
.import tosicmp, booleq
|
||||
.importzp sp, tmp1
|
||||
.export toseq00, toseqa0, toseqax
|
||||
.import tosicmp, booleq
|
||||
.importzp sp, tmp1
|
||||
|
||||
toseq00:
|
||||
lda #$00
|
||||
lda #$00
|
||||
toseqa0:
|
||||
ldx #$00
|
||||
ldx #$00
|
||||
toseqax:
|
||||
jsr tosicmp ; Set flags
|
||||
jmp booleq ; Convert to boolean
|
||||
jsr tosicmp ; Set flags
|
||||
jmp booleq ; Convert to boolean
|
||||
|
||||
+6
-6
@@ -4,14 +4,14 @@
|
||||
; CC65 runtime: Compare >= for signed ints
|
||||
;
|
||||
|
||||
.export tosge00, tosgea0, tosgeax
|
||||
.import tosicmp, boolge
|
||||
.export tosge00, tosgea0, tosgeax
|
||||
.import tosicmp, boolge
|
||||
|
||||
|
||||
tosge00:
|
||||
lda #$00
|
||||
lda #$00
|
||||
tosgea0:
|
||||
ldx #$00
|
||||
ldx #$00
|
||||
tosgeax:
|
||||
jsr tosicmp ; Set flags
|
||||
jmp boolge ; Convert to boolean
|
||||
jsr tosicmp ; Set flags
|
||||
jmp boolge ; Convert to boolean
|
||||
|
||||
+6
-6
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Compare > for signed ints
|
||||
;
|
||||
|
||||
.export tosgt00, tosgta0, tosgtax
|
||||
.import tosicmp, boolgt
|
||||
.export tosgt00, tosgta0, tosgtax
|
||||
.import tosicmp, boolgt
|
||||
|
||||
|
||||
tosgt00:
|
||||
lda #$00
|
||||
lda #$00
|
||||
tosgta0:
|
||||
ldx #$00
|
||||
ldx #$00
|
||||
tosgtax:
|
||||
jsr tosicmp ; Set the flags
|
||||
jmp boolgt ; Convert to boolean
|
||||
jsr tosicmp ; Set the flags
|
||||
jmp boolgt ; Convert to boolean
|
||||
|
||||
|
||||
+26
-26
@@ -5,43 +5,43 @@
|
||||
; Integer compare function - used by the compare operators
|
||||
;
|
||||
|
||||
.export tosicmp, tosicmp0
|
||||
.importzp sp, sreg
|
||||
.export tosicmp, tosicmp0
|
||||
.importzp sp, sreg
|
||||
|
||||
|
||||
tosicmp0:
|
||||
ldx #$00
|
||||
|
||||
tosicmp:
|
||||
sta sreg
|
||||
stx sreg+1 ; Save ax
|
||||
sta sreg
|
||||
stx sreg+1 ; Save ax
|
||||
|
||||
ldy #$00
|
||||
lda (sp),y ; Get low byte
|
||||
tax
|
||||
inc sp ; 5
|
||||
bne @L1 ; 3
|
||||
inc sp+1 ; (5)
|
||||
ldy #$00
|
||||
lda (sp),y ; Get low byte
|
||||
tax
|
||||
inc sp ; 5
|
||||
bne @L1 ; 3
|
||||
inc sp+1 ; (5)
|
||||
@L1:
|
||||
lda (sp),y ; Get high byte
|
||||
inc sp ; 5
|
||||
bne @L2 ; 3
|
||||
inc sp+1 ; (5)
|
||||
lda (sp),y ; Get high byte
|
||||
inc sp ; 5
|
||||
bne @L2 ; 3
|
||||
inc sp+1 ; (5)
|
||||
|
||||
; Do the compare.
|
||||
|
||||
@L2: sec
|
||||
sbc sreg+1 ; Compare high byte
|
||||
bne @L4
|
||||
cpx sreg ; Compare low byte
|
||||
beq @L3
|
||||
adc #$FF ; If the C flag is set then clear the N flag
|
||||
ora #$01 ; else set the N flag
|
||||
@L3: rts
|
||||
@L2: sec
|
||||
sbc sreg+1 ; Compare high byte
|
||||
bne @L4
|
||||
cpx sreg ; Compare low byte
|
||||
beq @L3
|
||||
adc #$FF ; If the C flag is set then clear the N flag
|
||||
ora #$01 ; else set the N flag
|
||||
@L3: rts
|
||||
|
||||
@L4: bvc @L3
|
||||
eor #$FF ; Fix the N flag if overflow
|
||||
ora #$01 ; Clear the Z flag
|
||||
rts
|
||||
@L4: bvc @L3
|
||||
eor #$FF ; Fix the N flag if overflow
|
||||
ora #$01 ; Clear the Z flag
|
||||
rts
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
;
|
||||
|
||||
.export idiv32by16r16
|
||||
.import negax, udiv32by16r16m
|
||||
.import negax, udiv32by16r16m
|
||||
|
||||
.include "zeropage.inc"
|
||||
|
||||
|
||||
@@ -4,21 +4,21 @@
|
||||
; CC65 runtime: Increment ax by 1
|
||||
;
|
||||
|
||||
.export incax1
|
||||
.export incax1
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
.macpack cpu
|
||||
|
||||
.proc incax1
|
||||
.proc incax1
|
||||
|
||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||
ina ; 65C02 version
|
||||
bne @L9
|
||||
ina ; 65C02 version
|
||||
bne @L9
|
||||
.else
|
||||
add #1
|
||||
bcc @L9
|
||||
add #1
|
||||
bcc @L9
|
||||
.endif
|
||||
inx
|
||||
@L9: rts
|
||||
inx
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
; CC65 runtime: Increment ax by 2
|
||||
;
|
||||
|
||||
.export incax2
|
||||
.export incax2
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
.proc incax2
|
||||
.proc incax2
|
||||
|
||||
add #2
|
||||
bcc @L9
|
||||
inx
|
||||
@L9: rts
|
||||
add #2
|
||||
bcc @L9
|
||||
inx
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
; CC65 runtime: Increment ax by 3
|
||||
;
|
||||
|
||||
.export incax3
|
||||
.import incaxy
|
||||
.export incax3
|
||||
.import incaxy
|
||||
|
||||
.proc incax3
|
||||
.proc incax3
|
||||
|
||||
ldy #3
|
||||
jmp incaxy
|
||||
ldy #3
|
||||
jmp incaxy
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
; CC65 runtime: Increment ax by 5
|
||||
;
|
||||
|
||||
.export incax5
|
||||
.import incaxy
|
||||
.export incax5
|
||||
.import incaxy
|
||||
|
||||
.proc incax5
|
||||
.proc incax5
|
||||
|
||||
ldy #5
|
||||
jmp incaxy
|
||||
ldy #5
|
||||
jmp incaxy
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
; CC65 runtime: Increment ax by 6
|
||||
;
|
||||
|
||||
.export incax6
|
||||
.import incaxy
|
||||
.export incax6
|
||||
.import incaxy
|
||||
|
||||
.proc incax6
|
||||
.proc incax6
|
||||
|
||||
ldy #6
|
||||
jmp incaxy
|
||||
ldy #6
|
||||
jmp incaxy
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
; CC65 runtime: Increment ax by 7
|
||||
;
|
||||
|
||||
.export incax7
|
||||
.import incaxy
|
||||
.export incax7
|
||||
.import incaxy
|
||||
|
||||
.proc incax7
|
||||
.proc incax7
|
||||
|
||||
ldy #7
|
||||
jmp incaxy
|
||||
ldy #7
|
||||
jmp incaxy
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
; CC65 runtime: Increment ax by 8
|
||||
;
|
||||
|
||||
.export incax8
|
||||
.import incaxy
|
||||
.export incax8
|
||||
.import incaxy
|
||||
|
||||
.proc incax8
|
||||
.proc incax8
|
||||
|
||||
ldy #8
|
||||
jmp incaxy
|
||||
ldy #8
|
||||
jmp incaxy
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
; CC65 runtime: Increment ax by valie in y
|
||||
;
|
||||
|
||||
.export incaxy, incax4
|
||||
.importzp tmp1
|
||||
.macpack generic
|
||||
.export incaxy, incax4
|
||||
.importzp tmp1
|
||||
.macpack generic
|
||||
|
||||
incax4: ldy #4
|
||||
incaxy: sty tmp1
|
||||
add tmp1
|
||||
bcc @L9
|
||||
inx
|
||||
@L9: rts
|
||||
incax4: ldy #4
|
||||
incaxy: sty tmp1
|
||||
add tmp1
|
||||
bcc @L9
|
||||
inx
|
||||
@L9: rts
|
||||
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
; CC65 runtime: Increment the stackpointer by 1
|
||||
;
|
||||
|
||||
.export incsp1
|
||||
.importzp sp
|
||||
.export incsp1
|
||||
.importzp sp
|
||||
|
||||
.proc incsp1
|
||||
.proc incsp1
|
||||
|
||||
inc sp
|
||||
bne @L1
|
||||
inc sp+1
|
||||
@L1: rts
|
||||
inc sp
|
||||
bne @L1
|
||||
inc sp+1
|
||||
@L1: rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+11
-11
@@ -2,32 +2,32 @@
|
||||
; Ullrich von Bassewitz, 25.10.2000
|
||||
;
|
||||
; CC65 runtime: Increment the stackpointer by 2. For performance reasons,
|
||||
; this modules does also contain the popax function.
|
||||
; this modules does also contain the popax function.
|
||||
|
||||
.export popax, incsp2
|
||||
.importzp sp
|
||||
.export popax, incsp2
|
||||
.importzp sp
|
||||
|
||||
.macpack cpu
|
||||
|
||||
; Pop a/x from stack. This function will run directly into incsp2
|
||||
|
||||
.proc popax
|
||||
.proc popax
|
||||
|
||||
ldy #1
|
||||
lda (sp),y ; get hi byte
|
||||
tax ; into x
|
||||
ldy #1
|
||||
lda (sp),y ; get hi byte
|
||||
tax ; into x
|
||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||
lda (sp) ; get lo byte
|
||||
lda (sp) ; get lo byte
|
||||
.else
|
||||
dey
|
||||
lda (sp),y ; get lo byte
|
||||
dey
|
||||
lda (sp),y ; get lo byte
|
||||
.endif
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
.proc incsp2
|
||||
.proc incsp2
|
||||
|
||||
inc sp ; 5
|
||||
beq @L1 ; 2
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
; CC65 runtime: Increment the stackpointer by 3
|
||||
;
|
||||
|
||||
.export incsp3
|
||||
.import addysp
|
||||
.export incsp3
|
||||
.import addysp
|
||||
|
||||
.proc incsp3
|
||||
.proc incsp3
|
||||
|
||||
ldy #3
|
||||
jmp addysp
|
||||
ldy #3
|
||||
jmp addysp
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
; CC65 runtime: Increment the stackpointer by 4
|
||||
;
|
||||
|
||||
.export incsp4
|
||||
.import addysp
|
||||
.export incsp4
|
||||
.import addysp
|
||||
|
||||
.proc incsp4
|
||||
.proc incsp4
|
||||
|
||||
ldy #4
|
||||
jmp addysp
|
||||
ldy #4
|
||||
jmp addysp
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
; CC65 runtime: Increment the stackpointer by 5
|
||||
;
|
||||
|
||||
.export incsp5
|
||||
.import addysp
|
||||
.export incsp5
|
||||
.import addysp
|
||||
|
||||
.proc incsp5
|
||||
.proc incsp5
|
||||
|
||||
ldy #5
|
||||
jmp addysp
|
||||
ldy #5
|
||||
jmp addysp
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
; CC65 runtime: Increment the stackpointer by 6
|
||||
;
|
||||
|
||||
.export incsp6
|
||||
.import addysp
|
||||
.export incsp6
|
||||
.import addysp
|
||||
|
||||
.proc incsp6
|
||||
.proc incsp6
|
||||
|
||||
ldy #6
|
||||
jmp addysp
|
||||
ldy #6
|
||||
jmp addysp
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
; CC65 runtime: Increment the stackpointer by 7
|
||||
;
|
||||
|
||||
.export incsp7
|
||||
.import addysp
|
||||
.export incsp7
|
||||
.import addysp
|
||||
|
||||
.proc incsp7
|
||||
.proc incsp7
|
||||
|
||||
ldy #7
|
||||
jmp addysp
|
||||
ldy #7
|
||||
jmp addysp
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
; CC65 runtime: Increment the stackpointer by 8
|
||||
;
|
||||
|
||||
.export incsp8
|
||||
.import addysp
|
||||
.export incsp8
|
||||
.import addysp
|
||||
|
||||
.proc incsp8
|
||||
.proc incsp8
|
||||
|
||||
ldy #8
|
||||
jmp addysp
|
||||
ldy #8
|
||||
jmp addysp
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
; may be patched at runtime.
|
||||
;
|
||||
|
||||
.export jmpvec
|
||||
.export jmpvec
|
||||
|
||||
.data
|
||||
|
||||
jmpvec: jmp $FFFF
|
||||
jmpvec: jmp $FFFF
|
||||
|
||||
|
||||
|
||||
+23
-23
@@ -4,9 +4,9 @@
|
||||
; CC65 runtime: long add
|
||||
;
|
||||
|
||||
.export tosadd0ax, tosaddeax
|
||||
.import addysp1
|
||||
.importzp sp, sreg, tmp1
|
||||
.export tosadd0ax, tosaddeax
|
||||
.import addysp1
|
||||
.importzp sp, sreg, tmp1
|
||||
|
||||
.macpack cpu
|
||||
|
||||
@@ -18,27 +18,27 @@ tosadd0ax:
|
||||
sty sreg+1
|
||||
|
||||
tosaddeax:
|
||||
clc
|
||||
clc
|
||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||
adc (sp) ; 65SC02 version - saves 2 cycles
|
||||
ldy #1
|
||||
adc (sp) ; 65SC02 version - saves 2 cycles
|
||||
ldy #1
|
||||
.else
|
||||
ldy #0
|
||||
adc (sp),y ; lo byte
|
||||
iny
|
||||
ldy #0
|
||||
adc (sp),y ; lo byte
|
||||
iny
|
||||
.endif
|
||||
sta tmp1 ; use as temp storage
|
||||
txa
|
||||
adc (sp),y ; byte 1
|
||||
tax
|
||||
iny
|
||||
lda sreg
|
||||
adc (sp),y ; byte 2
|
||||
sta sreg
|
||||
iny
|
||||
lda sreg+1
|
||||
adc (sp),y ; byte 3
|
||||
sta sreg+1
|
||||
lda tmp1 ; load byte 0
|
||||
jmp addysp1 ; drop TOS
|
||||
sta tmp1 ; use as temp storage
|
||||
txa
|
||||
adc (sp),y ; byte 1
|
||||
tax
|
||||
iny
|
||||
lda sreg
|
||||
adc (sp),y ; byte 2
|
||||
sta sreg
|
||||
iny
|
||||
lda sreg+1
|
||||
adc (sp),y ; byte 3
|
||||
sta sreg+1
|
||||
lda tmp1 ; load byte 0
|
||||
jmp addysp1 ; drop TOS
|
||||
|
||||
|
||||
+29
-29
@@ -7,47 +7,47 @@
|
||||
; in ptr1, the high byte is in Y, and the increment is in eax.
|
||||
;
|
||||
|
||||
.export laddeq1, laddeqa, laddeq
|
||||
.importzp sreg, ptr1, tmp1
|
||||
.export laddeq1, laddeqa, laddeq
|
||||
.importzp sreg, ptr1, tmp1
|
||||
|
||||
|
||||
laddeq1:
|
||||
lda #$01
|
||||
lda #$01
|
||||
|
||||
laddeqa:
|
||||
ldx #$00
|
||||
stx sreg
|
||||
stx sreg+1
|
||||
ldx #$00
|
||||
stx sreg
|
||||
stx sreg+1
|
||||
|
||||
laddeq: sty ptr1+1 ; Store high byte of address
|
||||
ldy #$00 ; Address low byte
|
||||
clc
|
||||
laddeq: sty ptr1+1 ; Store high byte of address
|
||||
ldy #$00 ; Address low byte
|
||||
clc
|
||||
|
||||
adc (ptr1),y
|
||||
sta (ptr1),y
|
||||
pha ; Save byte 0 of result for later
|
||||
adc (ptr1),y
|
||||
sta (ptr1),y
|
||||
pha ; Save byte 0 of result for later
|
||||
|
||||
iny ; Address byte 1
|
||||
txa
|
||||
adc (ptr1),y ; Load byte 1
|
||||
sta (ptr1),y
|
||||
tax
|
||||
iny ; Address byte 1
|
||||
txa
|
||||
adc (ptr1),y ; Load byte 1
|
||||
sta (ptr1),y
|
||||
tax
|
||||
|
||||
iny ; Address byte 2
|
||||
lda sreg
|
||||
adc (ptr1),y
|
||||
sta (ptr1),y
|
||||
sta sreg
|
||||
iny ; Address byte 2
|
||||
lda sreg
|
||||
adc (ptr1),y
|
||||
sta (ptr1),y
|
||||
sta sreg
|
||||
|
||||
iny ; Address byte 3
|
||||
lda sreg+1
|
||||
adc (ptr1),y
|
||||
sta (ptr1),y
|
||||
sta sreg+1
|
||||
iny ; Address byte 3
|
||||
lda sreg+1
|
||||
adc (ptr1),y
|
||||
sta (ptr1),y
|
||||
sta sreg+1
|
||||
|
||||
pla ; Retrieve byte 0 of result
|
||||
pla ; Retrieve byte 0 of result
|
||||
|
||||
rts ; Done
|
||||
rts ; Done
|
||||
|
||||
|
||||
|
||||
|
||||
+24
-24
@@ -4,31 +4,31 @@
|
||||
; CC65 runtime: += operator for longs on the stack
|
||||
;
|
||||
|
||||
.export laddeq0sp, laddeqysp
|
||||
.importzp sp, sreg
|
||||
.export laddeq0sp, laddeqysp
|
||||
.importzp sp, sreg
|
||||
|
||||
laddeq0sp:
|
||||
ldy #0
|
||||
ldy #0
|
||||
laddeqysp:
|
||||
clc
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
pha
|
||||
iny
|
||||
txa
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
tax
|
||||
iny
|
||||
lda sreg
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
sta sreg
|
||||
iny
|
||||
lda sreg+1
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
sta sreg+1
|
||||
pla
|
||||
rts
|
||||
clc
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
pha
|
||||
iny
|
||||
txa
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
tax
|
||||
iny
|
||||
lda sreg
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
sta sreg
|
||||
iny
|
||||
lda sreg+1
|
||||
adc (sp),y
|
||||
sta (sp),y
|
||||
sta sreg+1
|
||||
pla
|
||||
rts
|
||||
|
||||
|
||||
+20
-20
@@ -4,9 +4,9 @@
|
||||
; CC65 runtime: and on longs
|
||||
;
|
||||
|
||||
.export tosand0ax, tosandeax
|
||||
.import addysp1
|
||||
.importzp sp, sreg, tmp1
|
||||
.export tosand0ax, tosandeax
|
||||
.import addysp1
|
||||
.importzp sp, sreg, tmp1
|
||||
|
||||
|
||||
tosand0ax:
|
||||
@@ -15,22 +15,22 @@ tosand0ax:
|
||||
sty sreg+1
|
||||
|
||||
tosandeax:
|
||||
ldy #0
|
||||
and (sp),y ; byte 0
|
||||
sta tmp1
|
||||
iny
|
||||
txa
|
||||
and (sp),y ; byte 1
|
||||
tax
|
||||
iny
|
||||
lda sreg
|
||||
and (sp),y ; byte 2
|
||||
sta sreg
|
||||
iny
|
||||
lda sreg+1
|
||||
and (sp),y ; byte 3
|
||||
sta sreg+1
|
||||
ldy #0
|
||||
and (sp),y ; byte 0
|
||||
sta tmp1
|
||||
iny
|
||||
txa
|
||||
and (sp),y ; byte 1
|
||||
tax
|
||||
iny
|
||||
lda sreg
|
||||
and (sp),y ; byte 2
|
||||
sta sreg
|
||||
iny
|
||||
lda sreg+1
|
||||
and (sp),y ; byte 3
|
||||
sta sreg+1
|
||||
|
||||
lda tmp1
|
||||
jmp addysp1
|
||||
lda tmp1
|
||||
jmp addysp1
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
;
|
||||
|
||||
|
||||
.export tosasreax
|
||||
.import popeax
|
||||
.importzp sreg, tmp1
|
||||
.export tosasreax
|
||||
.import popeax
|
||||
.importzp sreg, tmp1
|
||||
|
||||
|
||||
tosasreax:
|
||||
@@ -35,7 +35,7 @@ L2: cpx #$80 ; Copy bit 31 into the carry
|
||||
ror tmp1
|
||||
ror a
|
||||
dey
|
||||
bne L2
|
||||
bne L2
|
||||
|
||||
; Shift done
|
||||
|
||||
|
||||
+12
-12
@@ -4,19 +4,19 @@
|
||||
; CC65 runtime: boolean negation for longs
|
||||
;
|
||||
|
||||
.export bnegeax
|
||||
.importzp sreg, tmp1
|
||||
.export bnegeax
|
||||
.importzp sreg, tmp1
|
||||
|
||||
bnegeax:
|
||||
stx tmp1
|
||||
ldx #0 ; High byte of result
|
||||
ora tmp1
|
||||
ora sreg
|
||||
ora sreg+1
|
||||
bne @L0
|
||||
lda #1
|
||||
rts
|
||||
stx tmp1
|
||||
ldx #0 ; High byte of result
|
||||
ora tmp1
|
||||
ora sreg
|
||||
ora sreg+1
|
||||
bne @L0
|
||||
lda #1
|
||||
rts
|
||||
|
||||
@L0: txa ; X is zero
|
||||
rts
|
||||
@L0: txa ; X is zero
|
||||
rts
|
||||
|
||||
|
||||
+37
-37
@@ -5,52 +5,52 @@
|
||||
; Long int compare function - used by the compare operators
|
||||
;
|
||||
|
||||
.export toslcmp
|
||||
.import incsp4
|
||||
.importzp sp, sreg, ptr1
|
||||
.export toslcmp
|
||||
.import incsp4
|
||||
.importzp sp, sreg, ptr1
|
||||
|
||||
|
||||
toslcmp:
|
||||
sta ptr1
|
||||
stx ptr1+1 ; EAX now in sreg:ptr1
|
||||
sta ptr1
|
||||
stx ptr1+1 ; EAX now in sreg:ptr1
|
||||
|
||||
ldy #$03
|
||||
lda (sp),y
|
||||
sec
|
||||
sbc sreg+1
|
||||
bne L4
|
||||
ldy #$03
|
||||
lda (sp),y
|
||||
sec
|
||||
sbc sreg+1
|
||||
bne L4
|
||||
|
||||
dey
|
||||
lda (sp),y
|
||||
cmp sreg
|
||||
bne L1
|
||||
dey
|
||||
lda (sp),y
|
||||
cmp sreg
|
||||
bne L1
|
||||
|
||||
dey
|
||||
lda (sp),y
|
||||
cmp ptr1+1
|
||||
bne L1
|
||||
dey
|
||||
lda (sp),y
|
||||
cmp ptr1+1
|
||||
bne L1
|
||||
|
||||
dey
|
||||
lda (sp),y
|
||||
cmp ptr1
|
||||
dey
|
||||
lda (sp),y
|
||||
cmp ptr1
|
||||
|
||||
L1: php ; Save flags
|
||||
jsr incsp4 ; Drop TOS
|
||||
plp ; Restore the flags
|
||||
beq L2
|
||||
bcs L3
|
||||
lda #$FF ; Set the N flag
|
||||
L2: rts
|
||||
L1: php ; Save flags
|
||||
jsr incsp4 ; Drop TOS
|
||||
plp ; Restore the flags
|
||||
beq L2
|
||||
bcs L3
|
||||
lda #$FF ; Set the N flag
|
||||
L2: rts
|
||||
|
||||
L3: lda #$01 ; Clear the N flag
|
||||
rts
|
||||
L3: lda #$01 ; Clear the N flag
|
||||
rts
|
||||
|
||||
L4: bvc L5
|
||||
eor #$FF ; Fix the N flag if overflow
|
||||
ora #$01 ; Clear the Z flag
|
||||
L5: php ; Save flags
|
||||
jsr incsp4 ; Drop TOS
|
||||
plp ; Restore flags
|
||||
rts
|
||||
L4: bvc L5
|
||||
eor #$FF ; Fix the N flag if overflow
|
||||
ora #$01 ; Clear the Z flag
|
||||
L5: php ; Save flags
|
||||
jsr incsp4 ; Drop TOS
|
||||
plp ; Restore flags
|
||||
rts
|
||||
|
||||
|
||||
|
||||
+15
-15
@@ -4,23 +4,23 @@
|
||||
; CC65 runtime: long complement
|
||||
;
|
||||
|
||||
.export compleax
|
||||
.importzp sreg
|
||||
.export compleax
|
||||
.importzp sreg
|
||||
|
||||
; eax = ~eax
|
||||
|
||||
compleax:
|
||||
eor #$FF
|
||||
pha
|
||||
txa
|
||||
eor #$FF
|
||||
tax
|
||||
lda sreg
|
||||
eor #$FF
|
||||
sta sreg
|
||||
lda sreg+1
|
||||
eor #$FF
|
||||
sta sreg+1
|
||||
pla
|
||||
rts
|
||||
eor #$FF
|
||||
pha
|
||||
txa
|
||||
eor #$FF
|
||||
tax
|
||||
lda sreg
|
||||
eor #$FF
|
||||
sta sreg
|
||||
lda sreg+1
|
||||
eor #$FF
|
||||
sta sreg+1
|
||||
pla
|
||||
rts
|
||||
|
||||
|
||||
+10
-10
@@ -4,16 +4,16 @@
|
||||
; CC65 runtime: Load a indirect from address in ax
|
||||
;
|
||||
|
||||
.export ldaidx
|
||||
.importzp ptr1
|
||||
.export ldaidx
|
||||
.importzp ptr1
|
||||
|
||||
.proc ldaidx
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldx #$00
|
||||
lda (ptr1),y
|
||||
bpl @L1
|
||||
dex
|
||||
@L1: rts
|
||||
.proc ldaidx
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldx #$00
|
||||
lda (ptr1),y
|
||||
bpl @L1
|
||||
dex
|
||||
@L1: rts
|
||||
.endproc
|
||||
|
||||
|
||||
+12
-12
@@ -4,24 +4,24 @@
|
||||
; CC65 runtime: Load an unsigned char indirect from pointer somewhere in stack
|
||||
;
|
||||
|
||||
.export ldau00sp, ldau0ysp
|
||||
.importzp sp, ptr1
|
||||
.export ldau00sp, ldau0ysp
|
||||
.importzp sp, ptr1
|
||||
|
||||
.macpack cpu
|
||||
|
||||
ldau00sp:
|
||||
ldy #1
|
||||
ldy #1
|
||||
ldau0ysp:
|
||||
lda (sp),y
|
||||
sta ptr1+1
|
||||
dey
|
||||
lda (sp),y
|
||||
sta ptr1
|
||||
ldx #0
|
||||
lda (sp),y
|
||||
sta ptr1+1
|
||||
dey
|
||||
lda (sp),y
|
||||
sta ptr1
|
||||
ldx #0
|
||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||
lda (ptr1) ; Save one cycle for the C02
|
||||
lda (ptr1) ; Save one cycle for the C02
|
||||
.else
|
||||
lda (ptr1,x)
|
||||
lda (ptr1,x)
|
||||
.endif
|
||||
rts
|
||||
rts
|
||||
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
; CC65 runtime: Load a unsigned indirect from address in ax
|
||||
;
|
||||
|
||||
.export ldauidx
|
||||
.importzp ptr1
|
||||
.export ldauidx
|
||||
.importzp ptr1
|
||||
|
||||
.proc ldauidx
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldx #0
|
||||
lda (ptr1),y
|
||||
rts
|
||||
.proc ldauidx
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
ldx #0
|
||||
lda (ptr1),y
|
||||
rts
|
||||
.endproc
|
||||
|
||||
+14
-14
@@ -4,21 +4,21 @@
|
||||
; CC65 runtime: Load an unsigned char indirect from pointer somewhere in stack
|
||||
;
|
||||
|
||||
.export ldaui0sp, ldauiysp
|
||||
.importzp sp, ptr1
|
||||
.export ldaui0sp, ldauiysp
|
||||
.importzp sp, ptr1
|
||||
|
||||
ldaui0sp:
|
||||
ldy #1
|
||||
ldy #1
|
||||
ldauiysp:
|
||||
lda (sp),y
|
||||
sta ptr1+1
|
||||
dey
|
||||
lda (sp),y
|
||||
sta ptr1
|
||||
txa
|
||||
tay
|
||||
ldx #0
|
||||
lda (ptr1),y
|
||||
rts
|
||||
lda (sp),y
|
||||
sta ptr1+1
|
||||
dey
|
||||
lda (sp),y
|
||||
sta ptr1
|
||||
txa
|
||||
tay
|
||||
ldx #0
|
||||
lda (ptr1),y
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
+10
-10
@@ -4,16 +4,16 @@
|
||||
; CC65 runtime: Load ax indirect from address in ax
|
||||
;
|
||||
|
||||
.export ldaxi, ldaxidx
|
||||
.importzp ptr1
|
||||
.export ldaxi, ldaxidx
|
||||
.importzp ptr1
|
||||
|
||||
ldaxi: ldy #1
|
||||
ldaxi: ldy #1
|
||||
ldaxidx:
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
lda (ptr1),y
|
||||
tax
|
||||
dey
|
||||
lda (ptr1),y
|
||||
rts
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
lda (ptr1),y
|
||||
tax
|
||||
dey
|
||||
lda (ptr1),y
|
||||
rts
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
; CC65 runtime: Load ax from offset in stack
|
||||
;
|
||||
|
||||
.export ldax0sp, ldaxysp
|
||||
.importzp sp
|
||||
.export ldax0sp, ldaxysp
|
||||
.importzp sp
|
||||
|
||||
; Beware: The optimizer knows about the value in Y after return!
|
||||
|
||||
ldax0sp:
|
||||
ldy #1
|
||||
ldy #1
|
||||
ldaxysp:
|
||||
lda (sp),y ; get high byte
|
||||
tax ; and save it
|
||||
dey ; point to lo byte
|
||||
lda (sp),y ; load low byte
|
||||
rts
|
||||
lda (sp),y ; get high byte
|
||||
tax ; and save it
|
||||
dey ; point to lo byte
|
||||
lda (sp),y ; load low byte
|
||||
rts
|
||||
|
||||
|
||||
+16
-16
@@ -4,22 +4,22 @@
|
||||
; CC65 runtime: Load eax indirect from address in ax
|
||||
;
|
||||
|
||||
.export ldeaxidx, ldeaxi
|
||||
.importzp sreg, ptr1
|
||||
.export ldeaxidx, ldeaxi
|
||||
.importzp sreg, ptr1
|
||||
|
||||
ldeaxi: ldy #3
|
||||
ldeaxi: ldy #3
|
||||
ldeaxidx:
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
lda (ptr1),y
|
||||
dey
|
||||
sta sreg+1
|
||||
lda (ptr1),y
|
||||
dey
|
||||
sta sreg
|
||||
lda (ptr1),y
|
||||
dey
|
||||
tax
|
||||
lda (ptr1),y
|
||||
rts
|
||||
sta ptr1
|
||||
stx ptr1+1
|
||||
lda (ptr1),y
|
||||
dey
|
||||
sta sreg+1
|
||||
lda (ptr1),y
|
||||
dey
|
||||
sta sreg
|
||||
lda (ptr1),y
|
||||
dey
|
||||
tax
|
||||
lda (ptr1),y
|
||||
rts
|
||||
|
||||
|
||||
+15
-15
@@ -4,25 +4,25 @@
|
||||
; CC65 runtime: Load a long from somewhere in the stack
|
||||
;
|
||||
; Beware: The optimizer knows about the register contents after calling
|
||||
; this function!
|
||||
; this function!
|
||||
;
|
||||
|
||||
|
||||
.export ldeax0sp, ldeaxysp
|
||||
.importzp sreg, sp
|
||||
.export ldeax0sp, ldeaxysp
|
||||
.importzp sreg, sp
|
||||
|
||||
ldeax0sp:
|
||||
ldy #3
|
||||
ldy #3
|
||||
ldeaxysp:
|
||||
lda (sp),y
|
||||
sta sreg+1
|
||||
dey
|
||||
lda (sp),y
|
||||
sta sreg
|
||||
dey
|
||||
lda (sp),y
|
||||
tax
|
||||
dey
|
||||
lda (sp),y
|
||||
rts
|
||||
lda (sp),y
|
||||
sta sreg+1
|
||||
dey
|
||||
lda (sp),y
|
||||
sta sreg
|
||||
dey
|
||||
lda (sp),y
|
||||
tax
|
||||
dey
|
||||
lda (sp),y
|
||||
rts
|
||||
|
||||
|
||||
+17
-17
@@ -4,23 +4,23 @@
|
||||
; CC65 runtime: Decrement eax by value in Y
|
||||
;
|
||||
|
||||
.export deceaxy
|
||||
.importzp sreg, tmp1
|
||||
.export deceaxy
|
||||
.importzp sreg, tmp1
|
||||
|
||||
deceaxy:
|
||||
sty tmp1
|
||||
sec
|
||||
sbc tmp1
|
||||
sta tmp1
|
||||
txa
|
||||
sbc #0
|
||||
tax
|
||||
lda sreg
|
||||
sbc #0
|
||||
sta sreg
|
||||
lda sreg+1
|
||||
sbc #0
|
||||
sta sreg+1
|
||||
lda tmp1
|
||||
rts
|
||||
sty tmp1
|
||||
sec
|
||||
sbc tmp1
|
||||
sta tmp1
|
||||
txa
|
||||
sbc #0
|
||||
tax
|
||||
lda sreg
|
||||
sbc #0
|
||||
sta sreg
|
||||
lda sreg+1
|
||||
sbc #0
|
||||
sta sreg+1
|
||||
lda tmp1
|
||||
rts
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
; When negating values, we will ignore the possibility here, that one of the
|
||||
; values if $80000000, in which case the negate will fail.
|
||||
|
||||
.export tosdiv0ax, tosdiveax
|
||||
.import poplsargs, udiv32, negeax
|
||||
.importzp sreg, ptr1, tmp1, tmp2
|
||||
.export tosdiv0ax, tosdiveax
|
||||
.import poplsargs, udiv32, negeax
|
||||
.importzp sreg, ptr1, tmp1, tmp2
|
||||
|
||||
tosdiv0ax:
|
||||
ldy #$00
|
||||
@@ -17,8 +17,8 @@ tosdiv0ax:
|
||||
sty sreg+1
|
||||
|
||||
tosdiveax:
|
||||
jsr poplsargs ; Get arguments from stack, adjust sign
|
||||
jsr udiv32 ; Do the division, result is in (ptr1:sreg)
|
||||
jsr poplsargs ; Get arguments from stack, adjust sign
|
||||
jsr udiv32 ; Do the division, result is in (ptr1:sreg)
|
||||
ldx ptr1+1 ; Load byte 1 of result
|
||||
|
||||
; Adjust the sign of the result
|
||||
@@ -29,8 +29,8 @@ tosdiveax:
|
||||
|
||||
; Result is negative
|
||||
|
||||
lda ptr1 ; Load byte 0
|
||||
jmp negeax ; Negate value
|
||||
lda ptr1 ; Load byte 0
|
||||
jmp negeax ; Negate value
|
||||
|
||||
; Result is positive
|
||||
|
||||
|
||||
+6
-6
@@ -4,14 +4,14 @@
|
||||
; CC65 runtime: Compare <= for signed ints
|
||||
;
|
||||
|
||||
.export tosle00, toslea0, tosleax
|
||||
.import tosicmp, boolle
|
||||
.export tosle00, toslea0, tosleax
|
||||
.import tosicmp, boolle
|
||||
|
||||
tosle00:
|
||||
lda #$00
|
||||
lda #$00
|
||||
toslea0:
|
||||
ldx #$00
|
||||
ldx #$00
|
||||
tosleax:
|
||||
jsr tosicmp ; Set flags
|
||||
jmp boolle ; Convert to boolean
|
||||
jsr tosicmp ; Set flags
|
||||
jmp boolle ; Convert to boolean
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
; CC65 runtime: Load effective address with offset in A/X relative to SP
|
||||
;
|
||||
|
||||
.export leaaxsp, leaa0sp
|
||||
.importzp sp
|
||||
.export leaaxsp, leaa0sp
|
||||
.importzp sp
|
||||
|
||||
leaa0sp:
|
||||
ldx #$00
|
||||
|
||||
+20
-20
@@ -8,30 +8,30 @@
|
||||
; flavours that provide default values for the return val, or drop a local
|
||||
; stack frame with size in y.
|
||||
|
||||
.export leave00, leave0, leavey00, leavey0, leavey
|
||||
.export leave
|
||||
.import addysp
|
||||
.importzp sp
|
||||
.export leave00, leave0, leavey00, leavey0, leavey
|
||||
.export leave
|
||||
.import addysp
|
||||
.importzp sp
|
||||
|
||||
leave00:
|
||||
lda #0
|
||||
leave0: ldx #0
|
||||
beq leave
|
||||
lda #0
|
||||
leave0: ldx #0
|
||||
beq leave
|
||||
|
||||
leavey00:
|
||||
lda #0 ; "return 0"
|
||||
lda #0 ; "return 0"
|
||||
leavey0:
|
||||
ldx #0 ; return < 256
|
||||
ldx #0 ; return < 256
|
||||
leavey:
|
||||
jsr addysp ; drop stack frame
|
||||
leave: pha ; save A a sec
|
||||
ldy #0
|
||||
lda (sp),y ; that's the pushed arg size
|
||||
sec ; Count the byte, the count's stored in
|
||||
adc sp
|
||||
sta sp
|
||||
bcc L1
|
||||
inc sp+1
|
||||
L1: pla ; Get return value back
|
||||
rts
|
||||
jsr addysp ; drop stack frame
|
||||
leave: pha ; save A a sec
|
||||
ldy #0
|
||||
lda (sp),y ; that's the pushed arg size
|
||||
sec ; Count the byte, the count's stored in
|
||||
adc sp
|
||||
sta sp
|
||||
bcc L1
|
||||
inc sp+1
|
||||
L1: pla ; Get return value back
|
||||
rts
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
; CC65 runtime: long equal
|
||||
;
|
||||
|
||||
.export toseqeax
|
||||
.import toslcmp, booleq
|
||||
.export toseqeax
|
||||
.import toslcmp, booleq
|
||||
|
||||
toseqeax:
|
||||
jsr toslcmp ; Set flags
|
||||
jmp booleq ; Convert to boolean
|
||||
toseqeax:
|
||||
jsr toslcmp ; Set flags
|
||||
jmp booleq ; Convert to boolean
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
; CC65 runtime: Compare >= for long ints
|
||||
;
|
||||
|
||||
.export tosgeeax
|
||||
.import toslcmp, boolge
|
||||
.export tosgeeax
|
||||
.import toslcmp, boolge
|
||||
|
||||
tosgeeax:
|
||||
jsr toslcmp ; Set the flags
|
||||
jmp boolge ; Convert to boolean
|
||||
jsr toslcmp ; Set the flags
|
||||
jmp boolge ; Convert to boolean
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
; CC65 runtime: Compare > for long ints
|
||||
;
|
||||
|
||||
.export tosgteax
|
||||
.import toslcmp, boolgt
|
||||
.export tosgteax
|
||||
.import toslcmp, boolgt
|
||||
|
||||
tosgteax:
|
||||
jsr toslcmp ; Set the flags
|
||||
jmp boolgt ; Convert to boolean
|
||||
jsr toslcmp ; Set the flags
|
||||
jmp boolgt ; Convert to boolean
|
||||
|
||||
|
||||
|
||||
+13
-13
@@ -4,21 +4,21 @@
|
||||
; CC65 runtime: Increment eax by value in Y
|
||||
;
|
||||
|
||||
.export inceaxy
|
||||
.importzp ptr4, sreg
|
||||
.export inceaxy
|
||||
.importzp ptr4, sreg
|
||||
|
||||
.proc inceaxy
|
||||
.proc inceaxy
|
||||
|
||||
sty ptr4
|
||||
clc
|
||||
adc ptr4
|
||||
bcc @L9
|
||||
inx
|
||||
bne @L9
|
||||
inc sreg
|
||||
bne @L9
|
||||
inc sreg+1
|
||||
@L9: rts
|
||||
sty ptr4
|
||||
clc
|
||||
adc ptr4
|
||||
bcc @L9
|
||||
inx
|
||||
bne @L9
|
||||
inc sreg
|
||||
bne @L9
|
||||
inc sreg+1
|
||||
@L9: rts
|
||||
|
||||
.endproc
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
; CC65 runtime: Compare <= for long ints
|
||||
;
|
||||
|
||||
.export tosleeax
|
||||
.import toslcmp, boolle
|
||||
.export tosleeax
|
||||
.import toslcmp, boolle
|
||||
|
||||
tosleeax:
|
||||
jsr toslcmp ; Set the flags
|
||||
jmp boolle ; Convert to boolean
|
||||
jsr toslcmp ; Set the flags
|
||||
jmp boolle ; Convert to boolean
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
; CC65 runtime: Compare < for long ints
|
||||
;
|
||||
|
||||
.export toslteax
|
||||
.import toslcmp, boollt
|
||||
.export toslteax
|
||||
.import toslcmp, boollt
|
||||
|
||||
toslteax:
|
||||
jsr toslcmp ; Set the flags
|
||||
jmp boollt ; Convert to boolean
|
||||
jsr toslcmp ; Set the flags
|
||||
jmp boollt ; Convert to boolean
|
||||
|
||||
+10
-10
@@ -7,9 +7,9 @@
|
||||
; When negating values, we will ignore the possibility here, that one of the
|
||||
; values if $8000, in which case the negate will fail.
|
||||
|
||||
.export tosmod0ax, tosmodeax
|
||||
.import poplsargs, udiv32, negeax
|
||||
.importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4
|
||||
.export tosmod0ax, tosmodeax
|
||||
.import poplsargs, udiv32, negeax
|
||||
.importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4
|
||||
|
||||
tosmod0ax:
|
||||
ldy #$00
|
||||
@@ -17,17 +17,17 @@ tosmod0ax:
|
||||
sty sreg+1
|
||||
|
||||
tosmodeax:
|
||||
jsr poplsargs ; Get arguments from stack, adjust sign
|
||||
jsr udiv32 ; Do the division, remainder is in (ptr2:tmp3:tmp4)
|
||||
jsr poplsargs ; Get arguments from stack, adjust sign
|
||||
jsr udiv32 ; Do the division, remainder is in (ptr2:tmp3:tmp4)
|
||||
|
||||
; Load the result
|
||||
|
||||
lda ptr2
|
||||
ldx ptr2+1
|
||||
ldy tmp3
|
||||
sty sreg
|
||||
ldy tmp4
|
||||
sty sreg+1
|
||||
ldx ptr2+1
|
||||
ldy tmp3
|
||||
sty sreg
|
||||
ldy tmp4
|
||||
sty sreg+1
|
||||
|
||||
; Check the sign of the result. It is the sign of the left operand.
|
||||
|
||||
|
||||
+50
-50
@@ -4,9 +4,9 @@
|
||||
; CC65 runtime: multiplication for long (unsigned) ints
|
||||
;
|
||||
|
||||
.export tosumul0ax, tosumuleax, tosmul0ax, tosmuleax
|
||||
.import addysp1
|
||||
.importzp sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4
|
||||
.export tosumul0ax, tosumuleax, tosmul0ax, tosmuleax
|
||||
.import addysp1
|
||||
.importzp sp, sreg, tmp1, tmp2, tmp3, tmp4, ptr1, ptr3, ptr4
|
||||
|
||||
tosmul0ax:
|
||||
tosumul0ax:
|
||||
@@ -16,54 +16,54 @@ tosumul0ax:
|
||||
|
||||
tosmuleax:
|
||||
tosumuleax:
|
||||
mul32: sta ptr1
|
||||
stx ptr1+1 ; op2 now in ptr1/sreg
|
||||
ldy #0
|
||||
lda (sp),y
|
||||
sta ptr3
|
||||
iny
|
||||
lda (sp),y
|
||||
sta ptr3+1
|
||||
iny
|
||||
lda (sp),y
|
||||
sta ptr4
|
||||
iny
|
||||
lda (sp),y
|
||||
sta ptr4+1 ; op1 in pre3/ptr4
|
||||
jsr addysp1 ; Drop TOS
|
||||
mul32: sta ptr1
|
||||
stx ptr1+1 ; op2 now in ptr1/sreg
|
||||
ldy #0
|
||||
lda (sp),y
|
||||
sta ptr3
|
||||
iny
|
||||
lda (sp),y
|
||||
sta ptr3+1
|
||||
iny
|
||||
lda (sp),y
|
||||
sta ptr4
|
||||
iny
|
||||
lda (sp),y
|
||||
sta ptr4+1 ; op1 in pre3/ptr4
|
||||
jsr addysp1 ; Drop TOS
|
||||
|
||||
; Do (ptr1:sreg)*(ptr3:ptr4) --> EAX.
|
||||
|
||||
lda #0
|
||||
sta tmp4
|
||||
sta tmp3
|
||||
sta tmp2
|
||||
ldy #32
|
||||
L0: lsr tmp4
|
||||
ror tmp3
|
||||
ror tmp2
|
||||
ror a
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror ptr1+1
|
||||
ror ptr1
|
||||
bcc L1
|
||||
clc
|
||||
adc ptr3
|
||||
pha
|
||||
lda ptr3+1
|
||||
adc tmp2
|
||||
sta tmp2
|
||||
lda ptr4
|
||||
adc tmp3
|
||||
sta tmp3
|
||||
lda ptr4+1
|
||||
adc tmp4
|
||||
sta tmp4
|
||||
pla
|
||||
L1: dey
|
||||
bpl L0
|
||||
lda ptr1 ; Load the low result word
|
||||
ldx ptr1+1
|
||||
rts
|
||||
lda #0
|
||||
sta tmp4
|
||||
sta tmp3
|
||||
sta tmp2
|
||||
ldy #32
|
||||
L0: lsr tmp4
|
||||
ror tmp3
|
||||
ror tmp2
|
||||
ror a
|
||||
ror sreg+1
|
||||
ror sreg
|
||||
ror ptr1+1
|
||||
ror ptr1
|
||||
bcc L1
|
||||
clc
|
||||
adc ptr3
|
||||
pha
|
||||
lda ptr3+1
|
||||
adc tmp2
|
||||
sta tmp2
|
||||
lda ptr4
|
||||
adc tmp3
|
||||
sta tmp3
|
||||
lda ptr4+1
|
||||
adc tmp4
|
||||
sta tmp4
|
||||
pla
|
||||
L1: dey
|
||||
bpl L0
|
||||
lda ptr1 ; Load the low result word
|
||||
ldx ptr1+1
|
||||
rts
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
; CC65 runtime: long not equal
|
||||
;
|
||||
|
||||
.export tosneeax
|
||||
.import toslcmp, boolne
|
||||
.export tosneeax
|
||||
.import toslcmp, boolne
|
||||
|
||||
tosneeax:
|
||||
jsr toslcmp ; Set flags
|
||||
jmp boolne ; Convert to boolean
|
||||
jsr toslcmp ; Set flags
|
||||
jmp boolne ; Convert to boolean
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user