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