tosadda0:
ldx #0
tosaddax:
- ldy #0
- clc
- adc (sp),y ; lo byte
+ clc
+.ifpc02
+ adc (sp) ; 65C02 version - saves 2 cycles
+ ldy #1
+.else
+ ldy #0
+ adc (sp),y ; lo byte
+ iny
+.endif
pha ; save it
- txa
- iny
- adc (sp),y ; hi byte
+ txa
+ adc (sp),y ; hi byte
tax
clc
lda sp
tosanda0:
ldx #$00
tosandax:
- ldy #0
+.ifpc02
+ and (sp) ; 65C02 version, saves 2 cycles and 1 byte
+ ldy #1
+.else
+ ldy #0
and (sp),y
- sta ptr4
- iny
- txa
- and (sp),y
+ iny
+.endif
+ pha
+ txa
+ and (sp),y
tax
- lda ptr4
+ pla
jmp addysp1 ; drop TOS, set condition codes
; libinit and libdone call condes with the predefined module constructor and
; destructor tables, they must be called from the platform specific startup
; code.
+
;
; The function does also export jmpvec as general purpose jump vector that
; lies in the data segment so it's address may be patched at runtime.
sta jmpvec+1
sty index
jsr jmpvec
- jmp loop
+.ifpc02
+ bra loop
+.else
+ jmp loop
+.endif
done: rts
.proc incax1
- add #1
- bcc @L9
+.ifpc02
+ ina ; 65C02 version
+ bne @L9
+.else
+ add #1
+ bcc @L9
+.endif
inx
@L9: rts
lda (sp),y
sta ptr1
ldx #0
- lda (ptr1,x)
+.ifpc02
+ lda (ptr1) ; Save one cycle for the C02
+.else
+ lda (ptr1,x)
+.endif
rts
.export inceaxy
.importzp ptr4, sreg
-inceaxy:
+.proc inceaxy
+
sty ptr4
clc
adc ptr4
- bcc inceax9
+ bcc @L9
inx
- bne inceax9
+ bne @L9
inc sreg
- bne inceax9
+ bne @L9
inc sreg+1
-inceax9:
- rts
+@L9: rts
+
+.endproc
beq @L2
dey
@L0: sty sp
- ldy #0 ; get index
- sta (sp),y ; store lo byte
- pha ; save it
- txa ; get hi byte
- iny ; bump idx
+.ifpc02
+ sta (sp) ; 65C02 version - saves 2 cycles and one byte
+ ldy #1 ; get hi index
+.else
+ ldy #0 ; get index
+ sta (sp),y ; store lo byte
+ iny ; bump idx
+.endif
+ pha ; save it
+ txa ; get hi byte
sta (sp),y ; store hi byte
pla ; get A back
rts ; done
@L1: dey
@L2: dey
dec sp+1
+.ifpc02
+ bra @L0
+.else
jmp @L0
+.endif
+
-
.export pushb, pushbidx
.import pushax
- .importzp ptr1
+ .importzp ptr1
pushbidx:
sty ptr1
pushb: sta ptr1
stx ptr1+1
ldx #0 ; Load index/high byte
- lda (ptr1,x)
+.ifpc02
+ lda (ptr1) ; Save one cycle for the C02
+.else
+ lda (ptr1,x)
+.endif
bpl L1
dex ; Make high byte FF
L1: jmp pushax
-;
+;
; Ullrich von Bassewitz, 25.10.2000
;
; CC65 runtime: Store a/x indirect into address at top of stack
.proc staxspp
- ldy #0
+.ifpc02
pha
- lda (sp),y
- sta ptr1
- iny
- lda (sp),y
- sta ptr1+1
- txa
- sta (ptr1),y
- pla
- dey
- sta (ptr1),y
+ lda (sp)
+ sta ptr1
+ ldy #1
+ lda (sp),y
+ sta ptr1+1
+ txa
+ sta (ptr1),y
+ pla
+ sta (ptr1)
+.else
+ pha
+ ldy #0
+ lda (sp),y
+ sta ptr1
+ iny
+ lda (sp),y
+ sta ptr1+1
+ txa
+ sta (ptr1),y
+ pla
+ dey
+ sta (ptr1),y
+.endif
jmp incsp2 ; Drop address
.endproc
; Convert TOS from long to int by cutting of the high 16bit
-tosint: pha
- ldy #0
- lda (sp),y ; sp+1
- ldy #2
- sta (sp),y
- ldy #1
- lda (sp),y
- ldy #3
- sta (sp),y
+.proc tosint
+
+ pha
+.ifpc02
+ lda (sp)
+.else
+ ldy #0
+ lda (sp),y ; sp+1
+.endif
+ ldy #2
+ sta (sp),y
+ dey
+ lda (sp),y
+ ldy #3
+ sta (sp),y
pla
jmp incsp2 ; Drop 16 bit
+.endproc
tosulong:
pha
jsr decsp2 ; Make room
- ldy #2
- lda (sp),y
- ldy #0
+ ldy #2
+ lda (sp),y
+.ifpc02
+ sta (sp) ; 65C02 version
+ iny ; Y = 3
+.else
+ ldy #0
sta (sp),y
- ldy #3
- lda (sp),y
- ldy #1
- sta (sp),y
- lda #0 ; Zero extend
+ ldy #3
+.endif
+ lda (sp),y
+ ldy #1
+ sta (sp),y
+ lda #0 ; Zero extend
toslong2:
- iny
- sta (sp),y
- iny
- sta (sp),y
- pla
- rts
+ iny
+ sta (sp),y
+ iny
+ sta (sp),y
+ pla
+ rts
toslong:
pha
- jsr decsp2 ; Make room
- ldy #2
- lda (sp),y
- ldy #0
+ jsr decsp2 ; Make room
+ ldy #2
+ lda (sp),y
+.ifpc02
+ sta (sp) ; 65C02 version
+ iny ; Y = 3
+.else
+ ldy #0
sta (sp),y
- ldy #3
- lda (sp),y
- bmi toslong1
- ldy #1
- sta (sp),y
- lda #$00 ; Positive, high word is zero
- bne toslong2
+ ldy #3
+.endif
+ lda (sp),y
+ bmi toslong1
+ ldy #1
+ sta (sp),y
+ lda #$00 ; Positive, high word is zero
+ bne toslong2
toslong1:
- ldy #1
- sta (sp),y
- lda #$FF
- bne toslong2
+ ldy #1
+ sta (sp),y
+ lda #$FF
+ bne toslong2