2000-10-25 07:06:55 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 25.10.2000
|
|
|
|
;
|
|
|
|
; CC65 runtime: Convert tos from int to long
|
|
|
|
;
|
|
|
|
|
|
|
|
.export tosulong, toslong
|
|
|
|
.import decsp2
|
|
|
|
.importzp sp
|
|
|
|
|
|
|
|
; Convert TOS from int to long
|
|
|
|
|
|
|
|
tosulong:
|
|
|
|
pha
|
|
|
|
jsr decsp2 ; Make room
|
2000-11-27 22:59:03 +00:00
|
|
|
ldy #2
|
|
|
|
lda (sp),y
|
|
|
|
.ifpc02
|
|
|
|
sta (sp) ; 65C02 version
|
|
|
|
iny ; Y = 3
|
|
|
|
.else
|
|
|
|
ldy #0
|
2000-10-25 07:06:55 +00:00
|
|
|
sta (sp),y
|
2000-11-27 22:59:03 +00:00
|
|
|
ldy #3
|
|
|
|
.endif
|
|
|
|
lda (sp),y
|
2000-12-06 21:11:06 +00:00
|
|
|
toslong1:
|
2000-11-27 22:59:03 +00:00
|
|
|
ldy #1
|
|
|
|
sta (sp),y
|
|
|
|
lda #0 ; Zero extend
|
2000-10-25 07:06:55 +00:00
|
|
|
toslong2:
|
2000-11-27 22:59:03 +00:00
|
|
|
iny
|
|
|
|
sta (sp),y
|
|
|
|
iny
|
|
|
|
sta (sp),y
|
|
|
|
pla
|
|
|
|
rts
|
2000-10-25 07:06:55 +00:00
|
|
|
|
|
|
|
toslong:
|
|
|
|
pha
|
2000-11-27 22:59:03 +00:00
|
|
|
jsr decsp2 ; Make room
|
|
|
|
ldy #2
|
|
|
|
lda (sp),y
|
|
|
|
.ifpc02
|
|
|
|
sta (sp) ; 65C02 version
|
|
|
|
iny ; Y = 3
|
|
|
|
.else
|
|
|
|
ldy #0
|
2000-10-25 07:06:55 +00:00
|
|
|
sta (sp),y
|
2000-11-27 22:59:03 +00:00
|
|
|
ldy #3
|
|
|
|
.endif
|
|
|
|
lda (sp),y
|
2000-12-06 21:11:06 +00:00
|
|
|
bpl toslong1 ; Jump if positive, high word is zero
|
2000-11-27 22:59:03 +00:00
|
|
|
ldy #1
|
|
|
|
sta (sp),y
|
|
|
|
lda #$FF
|
2000-12-06 21:11:06 +00:00
|
|
|
bne toslong2 ; Branch always
|
2000-10-25 07:06:55 +00:00
|
|
|
|