restore comment alignment
This commit is contained in:
@@ -75,11 +75,11 @@ start:
|
|||||||
lda MEMTOP
|
lda MEMTOP
|
||||||
sbc #<__RESERVED_MEMORY__
|
sbc #<__RESERVED_MEMORY__
|
||||||
sta APPMHI ; initialize our APPMHI value
|
sta APPMHI ; initialize our APPMHI value
|
||||||
sta c_sp ; set up runtime stack part 1
|
sta c_sp ; set up runtime stack part 1
|
||||||
lda MEMTOP+1
|
lda MEMTOP+1
|
||||||
sbc #>__RESERVED_MEMORY__
|
sbc #>__RESERVED_MEMORY__
|
||||||
sta APPMHI+1
|
sta APPMHI+1
|
||||||
sta c_sp+1 ; set up runtime stack part 2
|
sta c_sp+1 ; set up runtime stack part 2
|
||||||
|
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ freefnd:txa
|
|||||||
beq l2
|
beq l2
|
||||||
|
|
||||||
l1: ldy #0
|
l1: ldy #0
|
||||||
lda (c_sp),y ; get device
|
lda (c_sp),y ; get device
|
||||||
l2: sta fd_table+ft_dev,x ; set device
|
l2: sta fd_table+ft_dev,x ; set device
|
||||||
lda #1
|
lda #1
|
||||||
sta fd_table+ft_usa,x ; set usage counter
|
sta fd_table+ft_usa,x ; set usage counter
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ loop2: lda (ptr4),y
|
|||||||
cmp #'a'
|
cmp #'a'
|
||||||
bcc L1 ; Not lowercase
|
bcc L1 ; Not lowercase
|
||||||
and #$DF ; make upper case char, assume ASCII chars
|
and #$DF ; make upper case char, assume ASCII chars
|
||||||
sta (c_sp),y ; store back
|
sta (c_sp),y ; store back
|
||||||
L1:
|
L1:
|
||||||
iny
|
iny
|
||||||
bpl loop2 ; bpl: this way we only support a max. length of 127
|
bpl loop2 ; bpl: this way we only support a max. length of 127
|
||||||
@@ -93,7 +93,7 @@ copy_end:
|
|||||||
jsr subysp ; adjust stack pointer
|
jsr subysp ; adjust stack pointer
|
||||||
dey
|
dey
|
||||||
cpdev: lda __defdev,y
|
cpdev: lda __defdev,y
|
||||||
sta (c_sp),y ; insert device name, number and ':'
|
sta (c_sp),y ; insert device name, number and ':'
|
||||||
dey
|
dey
|
||||||
bpl cpdev
|
bpl cpdev
|
||||||
hasdev2:
|
hasdev2:
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ start:
|
|||||||
lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
||||||
ldx #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
ldx #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__)
|
||||||
sta c_sp
|
sta c_sp
|
||||||
stx c_sp+1 ; Set argument stack ptr
|
stx c_sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ L1: lda c_sp,x
|
|||||||
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
sta c_sp
|
sta c_sp
|
||||||
stx c_sp+1 ; Set argument stack ptr
|
stx c_sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ L1: lda c_sp,x
|
|||||||
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
||||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
||||||
sta c_sp
|
sta c_sp
|
||||||
stx c_sp+1 ; Set argument stack ptr
|
stx c_sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ L1: lda c_sp,x
|
|||||||
ldy #$80
|
ldy #$80
|
||||||
ldx #$00
|
ldx #$00
|
||||||
MemOk: stx c_sp
|
MemOk: stx c_sp
|
||||||
sty c_sp+1 ; set argument stack ptr
|
sty c_sp+1 ; set argument stack ptr
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ L1: lda c_sp,x
|
|||||||
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
sta c_sp
|
sta c_sp
|
||||||
stx c_sp+1 ; Set argument stack ptr
|
stx c_sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Switch to the second charset.
|
; Switch to the second charset.
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@
|
|||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
sta ptr1+1
|
sta ptr1+1
|
||||||
adc #0
|
adc #0
|
||||||
sta (c_sp),y ; ptr1 = buf++;
|
sta (c_sp),y ; ptr1 = buf++;
|
||||||
|
|
||||||
; Get the buffered character and place it as first character into the read
|
; Get the buffered character and place it as first character into the read
|
||||||
; buffer.
|
; buffer.
|
||||||
|
|||||||
@@ -74,6 +74,6 @@ memcpy_getparams: ; IMPORTANT! Function has to leave with Y=0!
|
|||||||
tax
|
tax
|
||||||
stx ptr2+1 ; save high byte of ptr2
|
stx ptr2+1 ; save high byte of ptr2
|
||||||
dey ; Y = 0
|
dey ; Y = 0
|
||||||
lda (c_sp),y ; Get ptr2 low
|
lda (c_sp),y ; Get ptr2 low
|
||||||
sta ptr2
|
sta ptr2
|
||||||
rts
|
rts
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ common: ; Fill value is in X!
|
|||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
sta ptr1+1 ; save high byte of ptr
|
sta ptr1+1 ; save high byte of ptr
|
||||||
dey ; Y = 0
|
dey ; Y = 0
|
||||||
lda (c_sp),y ; Get ptr
|
lda (c_sp),y ; Get ptr
|
||||||
sta ptr1
|
sta ptr1
|
||||||
|
|
||||||
lsr ptr3+1 ; divide number of
|
lsr ptr3+1 ; divide number of
|
||||||
|
|||||||
@@ -121,12 +121,12 @@ _vfprintf:
|
|||||||
; exactly as _printf expects it. Parameters will get dropped by _printf.
|
; exactly as _printf expects it. Parameters will get dropped by _printf.
|
||||||
|
|
||||||
ldy #2
|
ldy #2
|
||||||
lda (c_sp),y ; Low byte of f
|
lda (c_sp),y ; Low byte of f
|
||||||
sta ptr
|
sta ptr
|
||||||
lda #<outdesc
|
lda #<outdesc
|
||||||
sta (c_sp),y
|
sta (c_sp),y
|
||||||
iny
|
iny
|
||||||
lda (c_sp),y ; High byte of f
|
lda (c_sp),y ; High byte of f
|
||||||
sta ptr+1
|
sta ptr+1
|
||||||
lda #>outdesc
|
lda #>outdesc
|
||||||
sta (c_sp),y
|
sta (c_sp),y
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ _vscanf:
|
|||||||
; Move the format down
|
; Move the format down
|
||||||
|
|
||||||
ldy #2
|
ldy #2
|
||||||
lda (c_sp),y ; Load byte of format
|
lda (c_sp),y ; Load byte of format
|
||||||
ldy #0
|
ldy #0
|
||||||
sta (c_sp),y
|
sta (c_sp),y
|
||||||
ldy #3
|
ldy #3
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ init:
|
|||||||
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
sta c_sp
|
sta c_sp
|
||||||
stx c_sp+1 ; Set argument stack ptr
|
stx c_sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Switch to the lower/UPPER PetSCII charset.
|
; Switch to the lower/UPPER PetSCII charset.
|
||||||
|
|
||||||
|
|||||||
@@ -11,16 +11,16 @@
|
|||||||
|
|
||||||
_DbgMemDump:
|
_DbgMemDump:
|
||||||
ldy #0
|
ldy #0
|
||||||
lda (c_sp),y ; Get length
|
lda (c_sp),y ; Get length
|
||||||
sta tmp4
|
sta tmp4
|
||||||
iny
|
iny
|
||||||
lda (c_sp),y ; Get the string buffer
|
lda (c_sp),y ; Get the string buffer
|
||||||
sta ptr3
|
sta ptr3
|
||||||
iny
|
iny
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
sta ptr3+1
|
sta ptr3+1
|
||||||
iny
|
iny
|
||||||
lda (c_sp),y ; Get the address
|
lda (c_sp),y ; Get the address
|
||||||
sta ptr4
|
sta ptr4
|
||||||
iny
|
iny
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ start:
|
|||||||
lda #<(__SRAM_START__ + __SRAM_SIZE__)
|
lda #<(__SRAM_START__ + __SRAM_SIZE__)
|
||||||
ldx #>(__SRAM_START__ + __SRAM_SIZE__)
|
ldx #>(__SRAM_START__ + __SRAM_SIZE__)
|
||||||
sta c_sp
|
sta c_sp
|
||||||
stx c_sp+1 ; Set argument stack ptr
|
stx c_sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ memcpy_getparams:
|
|||||||
; (Direct stack access is six cycles faster [total cycle count].)
|
; (Direct stack access is six cycles faster [total cycle count].)
|
||||||
|
|
||||||
iny ; (Y=0 by popptr1, need '1' here) save dest
|
iny ; (Y=0 by popptr1, need '1' here) save dest
|
||||||
lda (c_sp),y ; get high byte
|
lda (c_sp),y ; get high byte
|
||||||
tax
|
tax
|
||||||
lda (c_sp) ; get low byte
|
lda (c_sp) ; get low byte
|
||||||
sta ptr2
|
sta ptr2
|
||||||
stx ptr2+1
|
stx ptr2+1
|
||||||
rts ; return dest address (for memmove)
|
rts ; return dest address (for memmove)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ L1: lda c_sp,x
|
|||||||
lda MEMSIZE
|
lda MEMSIZE
|
||||||
sta c_sp
|
sta c_sp
|
||||||
lda MEMSIZE+1
|
lda MEMSIZE+1
|
||||||
sta c_sp+1 ; Set argument stack ptr
|
sta c_sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|||||||
@@ -20,34 +20,34 @@ tosaddax:
|
|||||||
|
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||||
|
|
||||||
adc (c_sp) ; (7)
|
adc (c_sp) ; (7)
|
||||||
tay ; (9)
|
tay ; (9)
|
||||||
inc c_sp ; (14)
|
inc c_sp ; (14)
|
||||||
bne hiadd ; (17)
|
bne hiadd ; (17)
|
||||||
inc c_sp+1 ; (-1+5)
|
inc c_sp+1 ; (-1+5)
|
||||||
hiadd: txa ; (19)
|
hiadd: txa ; (19)
|
||||||
adc (c_sp) ; (24)
|
adc (c_sp) ; (24)
|
||||||
tax ; (26)
|
tax ; (26)
|
||||||
inc c_sp ; (31)
|
inc c_sp ; (31)
|
||||||
bne done ; (34)
|
bne done ; (34)
|
||||||
inc c_sp+1 ; (-1+5)
|
inc c_sp+1 ; (-1+5)
|
||||||
done: tya ; (36)
|
done: tya ; (36)
|
||||||
|
|
||||||
.else
|
.else
|
||||||
|
|
||||||
ldy #0 ; (4)
|
ldy #0 ; (4)
|
||||||
adc (c_sp),y ; (9) lo byte
|
adc (c_sp),y ; (9) lo byte
|
||||||
iny ; (11)
|
iny ; (11)
|
||||||
sta tmp1 ; (14) save it
|
sta tmp1 ; (14) save it
|
||||||
txa ; (16)
|
txa ; (16)
|
||||||
adc (c_sp),y ; (21) hi byte
|
adc (c_sp),y ; (21) hi byte
|
||||||
tax ; (23)
|
tax ; (23)
|
||||||
clc ; (25)
|
clc ; (25)
|
||||||
lda c_sp ; (28)
|
lda c_sp ; (28)
|
||||||
adc #2 ; (30)
|
adc #2 ; (30)
|
||||||
sta c_sp ; (33)
|
sta c_sp ; (33)
|
||||||
bcc L1 ; (36)
|
bcc L1 ; (36)
|
||||||
inc c_sp+1 ; (-1+5)
|
inc c_sp+1 ; (-1+5)
|
||||||
L1: lda tmp1 ; (39) restore low byte
|
L1: lda tmp1 ; (39) restore low byte
|
||||||
|
|
||||||
.endif
|
.endif
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ addysp1:
|
|||||||
addysp: pha ; Save A
|
addysp: pha ; Save A
|
||||||
clc
|
clc
|
||||||
tya ; Get the value
|
tya ; Get the value
|
||||||
adc c_sp ; Add low byte
|
adc c_sp ; Add low byte
|
||||||
sta c_sp ; Put it back
|
sta c_sp ; Put it back
|
||||||
bcc @L1 ; If no carry, we're done
|
bcc @L1 ; If no carry, we're done
|
||||||
inc c_sp+1 ; Inc high byte
|
inc c_sp+1 ; Inc high byte
|
||||||
@L1: pla ; Restore A
|
@L1: pla ; Restore A
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ tosanda0:
|
|||||||
ldx #$00
|
ldx #$00
|
||||||
tosandax:
|
tosandax:
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
and (c_sp) ; 65SC02 version, saves 2 cycles and 1 byte
|
and (c_sp) ; 65SC02 version, saves 2 cycles and 1 byte
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ enter: tya ; get arg size
|
|||||||
dec c_sp+1
|
dec c_sp+1
|
||||||
L1: dec c_sp
|
L1: dec c_sp
|
||||||
ldy #0
|
ldy #0
|
||||||
sta (c_sp),y ; Store the arg count
|
sta (c_sp),y ; Store the arg count
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ tosicmp:
|
|||||||
stx sreg+1 ; Save ax
|
stx sreg+1 ; Save ax
|
||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
lda (c_sp),y ; Get low byte
|
lda (c_sp),y ; Get low byte
|
||||||
tax
|
tax
|
||||||
inc c_sp ; 5
|
inc c_sp ; 5
|
||||||
bne @L1 ; 3
|
bne @L1 ; 3
|
||||||
inc c_sp+1 ; (5)
|
inc c_sp+1 ; (5)
|
||||||
@L1:
|
@L1:
|
||||||
lda (c_sp),y ; Get high byte
|
lda (c_sp),y ; Get high byte
|
||||||
inc c_sp ; 5
|
inc c_sp ; 5
|
||||||
bne @L2 ; 3
|
bne @L2 ; 3
|
||||||
inc c_sp+1 ; (5)
|
inc c_sp+1 ; (5)
|
||||||
|
|
||||||
; Do the compare.
|
; Do the compare.
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,13 @@
|
|||||||
.proc popax
|
.proc popax
|
||||||
|
|
||||||
ldy #1
|
ldy #1
|
||||||
lda (c_sp),y ; get hi byte
|
lda (c_sp),y ; get hi byte
|
||||||
tax ; into x
|
tax ; into x
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||||
lda (c_sp) ; get lo byte
|
lda (c_sp) ; get lo byte
|
||||||
.else
|
.else
|
||||||
dey
|
dey
|
||||||
lda (c_sp),y ; get lo byte
|
lda (c_sp),y ; get lo byte
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
@@ -29,14 +29,14 @@
|
|||||||
|
|
||||||
.proc incsp2
|
.proc incsp2
|
||||||
|
|
||||||
inc c_sp ; 5
|
inc c_sp ; 5
|
||||||
beq @L1 ; 2
|
beq @L1 ; 2
|
||||||
inc c_sp ; 5
|
inc c_sp ; 5
|
||||||
beq @L2 ; 2
|
beq @L2 ; 2
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@L1: inc c_sp ; 5
|
@L1: inc c_sp ; 5
|
||||||
@L2: inc c_sp+1 ; 5
|
@L2: inc c_sp+1 ; 5
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|||||||
@@ -20,24 +20,24 @@ tosadd0ax:
|
|||||||
tosaddeax:
|
tosaddeax:
|
||||||
clc
|
clc
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
adc (c_sp) ; 65SC02 version - saves 2 cycles
|
adc (c_sp) ; 65SC02 version - saves 2 cycles
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
adc (c_sp),y ; lo byte
|
adc (c_sp),y ; lo byte
|
||||||
iny
|
iny
|
||||||
.endif
|
.endif
|
||||||
sta tmp1 ; use as temp storage
|
sta tmp1 ; use as temp storage
|
||||||
txa
|
txa
|
||||||
adc (c_sp),y ; byte 1
|
adc (c_sp),y ; byte 1
|
||||||
tax
|
tax
|
||||||
iny
|
iny
|
||||||
lda sreg
|
lda sreg
|
||||||
adc (c_sp),y ; byte 2
|
adc (c_sp),y ; byte 2
|
||||||
sta sreg
|
sta sreg
|
||||||
iny
|
iny
|
||||||
lda sreg+1
|
lda sreg+1
|
||||||
adc (c_sp),y ; byte 3
|
adc (c_sp),y ; byte 3
|
||||||
sta sreg+1
|
sta sreg+1
|
||||||
lda tmp1 ; load byte 0
|
lda tmp1 ; load byte 0
|
||||||
jmp addysp1 ; drop TOS
|
jmp addysp1 ; drop TOS
|
||||||
|
|||||||
@@ -23,24 +23,24 @@ tosand0ax:
|
|||||||
|
|
||||||
tosandeax:
|
tosandeax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||||
and (c_sp) ; byte 0
|
and (c_sp) ; byte 0
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
and (c_sp),y ; byte 0
|
and (c_sp),y ; byte 0
|
||||||
iny
|
iny
|
||||||
.endif
|
.endif
|
||||||
sta tmp1
|
sta tmp1
|
||||||
txa
|
txa
|
||||||
and (c_sp),y ; byte 1
|
and (c_sp),y ; byte 1
|
||||||
tax
|
tax
|
||||||
iny
|
iny
|
||||||
lda sreg
|
lda sreg
|
||||||
and (c_sp),y ; byte 2
|
and (c_sp),y ; byte 2
|
||||||
sta sreg
|
sta sreg
|
||||||
iny
|
iny
|
||||||
lda sreg+1
|
lda sreg+1
|
||||||
and (c_sp),y ; byte 3
|
and (c_sp),y ; byte 3
|
||||||
sta sreg+1
|
sta sreg+1
|
||||||
|
|
||||||
lda tmp1
|
lda tmp1
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
ldax0sp:
|
ldax0sp:
|
||||||
ldy #1
|
ldy #1
|
||||||
ldaxysp:
|
ldaxysp:
|
||||||
lda (c_sp),y ; get high byte
|
lda (c_sp),y ; get high byte
|
||||||
tax ; and save it
|
tax ; and save it
|
||||||
dey ; point to lo byte
|
dey ; point to lo byte
|
||||||
lda (c_sp),y ; load low byte
|
lda (c_sp),y ; load low byte
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ leavey:
|
|||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||||
|
|
||||||
leave: tay ; save A a sec
|
leave: tay ; save A a sec
|
||||||
lda (c_sp) ; that's the pushed arg size
|
lda (c_sp) ; that's the pushed arg size
|
||||||
sec ; Count the byte, the count's stored in
|
sec ; Count the byte, the count's stored in
|
||||||
adc c_sp
|
adc c_sp
|
||||||
sta c_sp
|
sta c_sp
|
||||||
@@ -43,7 +43,7 @@ L1: tya ; Get return value back
|
|||||||
|
|
||||||
leave: pha ; save A a sec
|
leave: pha ; save A a sec
|
||||||
ldy #0
|
ldy #0
|
||||||
lda (c_sp),y ; that's the pushed arg size
|
lda (c_sp),y ; that's the pushed arg size
|
||||||
sec ; Count the byte, the count's stored in
|
sec ; Count the byte, the count's stored in
|
||||||
adc c_sp
|
adc c_sp
|
||||||
sta c_sp
|
sta c_sp
|
||||||
|
|||||||
@@ -27,20 +27,20 @@ tosoreax:
|
|||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
ora (c_sp),y ; byte 0
|
ora (c_sp),y ; byte 0
|
||||||
iny
|
iny
|
||||||
.endif
|
.endif
|
||||||
sta tmp1
|
sta tmp1
|
||||||
txa
|
txa
|
||||||
ora (c_sp),y ; byte 1
|
ora (c_sp),y ; byte 1
|
||||||
tax
|
tax
|
||||||
iny
|
iny
|
||||||
lda sreg
|
lda sreg
|
||||||
ora (c_sp),y ; byte 2
|
ora (c_sp),y ; byte 2
|
||||||
sta sreg
|
sta sreg
|
||||||
iny
|
iny
|
||||||
lda sreg+1
|
lda sreg+1
|
||||||
ora (c_sp),y ; byte 3
|
ora (c_sp),y ; byte 3
|
||||||
sta sreg+1
|
sta sreg+1
|
||||||
|
|
||||||
lda tmp1
|
lda tmp1
|
||||||
|
|||||||
@@ -31,20 +31,20 @@ tosrsubeax:
|
|||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
sbc (c_sp),y ; byte 0
|
sbc (c_sp),y ; byte 0
|
||||||
iny
|
iny
|
||||||
.endif
|
.endif
|
||||||
sta tmp1 ; use as temp storage
|
sta tmp1 ; use as temp storage
|
||||||
txa
|
txa
|
||||||
sbc (c_sp),y ; byte 1
|
sbc (c_sp),y ; byte 1
|
||||||
tax
|
tax
|
||||||
iny
|
iny
|
||||||
lda sreg
|
lda sreg
|
||||||
sbc (c_sp),y ; byte 2
|
sbc (c_sp),y ; byte 2
|
||||||
sta sreg
|
sta sreg
|
||||||
iny
|
iny
|
||||||
lda sreg+1
|
lda sreg+1
|
||||||
sbc (c_sp),y ; byte 3
|
sbc (c_sp),y ; byte 3
|
||||||
sta sreg+1
|
sta sreg+1
|
||||||
lda tmp1
|
lda tmp1
|
||||||
jmp addysp1 ; drop TOS
|
jmp addysp1 ; drop TOS
|
||||||
|
|||||||
@@ -27,17 +27,17 @@ tossubeax:
|
|||||||
sec
|
sec
|
||||||
eor #$FF
|
eor #$FF
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||||
adc (c_sp) ; 65SC02 version - saves 2 cycles
|
adc (c_sp) ; 65SC02 version - saves 2 cycles
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
adc (c_sp),y ; lo byte
|
adc (c_sp),y ; lo byte
|
||||||
iny
|
iny
|
||||||
.endif
|
.endif
|
||||||
pha ; Save low byte
|
pha ; Save low byte
|
||||||
txa
|
txa
|
||||||
eor #$FF
|
eor #$FF
|
||||||
adc (c_sp),y ; byte 1
|
adc (c_sp),y ; byte 1
|
||||||
tax
|
tax
|
||||||
iny
|
iny
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
|
|||||||
@@ -23,24 +23,24 @@ tosxor0ax:
|
|||||||
|
|
||||||
tosxoreax:
|
tosxoreax:
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||||
eor (c_sp) ; byte 0
|
eor (c_sp) ; byte 0
|
||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
eor (c_sp),y ; byte 0
|
eor (c_sp),y ; byte 0
|
||||||
iny
|
iny
|
||||||
.endif
|
.endif
|
||||||
sta tmp1
|
sta tmp1
|
||||||
txa
|
txa
|
||||||
eor (c_sp),y ; byte 1
|
eor (c_sp),y ; byte 1
|
||||||
tax
|
tax
|
||||||
iny
|
iny
|
||||||
lda sreg
|
lda sreg
|
||||||
eor (c_sp),y ; byte 2
|
eor (c_sp),y ; byte 2
|
||||||
sta sreg
|
sta sreg
|
||||||
iny
|
iny
|
||||||
lda sreg+1
|
lda sreg+1
|
||||||
eor (c_sp),y ; byte 3
|
eor (c_sp),y ; byte 3
|
||||||
sta sreg+1
|
sta sreg+1
|
||||||
|
|
||||||
lda tmp1
|
lda tmp1
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
.else
|
.else
|
||||||
ldy #0 ; (2)
|
ldy #0 ; (2)
|
||||||
lda (c_sp),y ; (7) Read byte
|
lda (c_sp),y ; (7) Read byte
|
||||||
.endif
|
.endif
|
||||||
inc c_sp ; (12)
|
inc c_sp ; (12)
|
||||||
beq @L1 ; (14)
|
beq @L1 ; (14)
|
||||||
rts ; (20)
|
rts ; (20)
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
.proc popptr1 ; 14 bytes (four usages = at least 2 bytes saved)
|
.proc popptr1 ; 14 bytes (four usages = at least 2 bytes saved)
|
||||||
ldy #1
|
ldy #1
|
||||||
lda (c_sp),y ; get hi byte
|
lda (c_sp),y ; get hi byte
|
||||||
sta ptr1+1 ; into ptr hi
|
sta ptr1+1 ; into ptr hi
|
||||||
dey ; dey even for for 65C02 here to have Y=0 at exit!
|
dey ; dey even for for 65C02 here to have Y=0 at exit!
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||||
lda (c_sp) ; get lo byte
|
lda (c_sp) ; get lo byte
|
||||||
.else
|
.else
|
||||||
lda (c_sp),y ; get lo byte
|
lda (c_sp),y ; get lo byte
|
||||||
.endif
|
.endif
|
||||||
sta ptr1 ; to ptr lo
|
sta ptr1 ; to ptr lo
|
||||||
jmp incsp2
|
jmp incsp2
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
popsreg:
|
popsreg:
|
||||||
pha ; save A
|
pha ; save A
|
||||||
ldy #1
|
ldy #1
|
||||||
lda (c_sp),y ; get hi byte
|
lda (c_sp),y ; get hi byte
|
||||||
sta sreg+1 ; store it
|
sta sreg+1 ; store it
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||||
lda (c_sp) ; get lo byte
|
lda (c_sp) ; get lo byte
|
||||||
.else
|
.else
|
||||||
dey
|
dey
|
||||||
lda (c_sp),y ; get lo byte
|
lda (c_sp),y ; get lo byte
|
||||||
.endif
|
.endif
|
||||||
sta sreg ; store it
|
sta sreg ; store it
|
||||||
pla ; get A back
|
pla ; get A back
|
||||||
|
|||||||
@@ -15,15 +15,15 @@ pusha0sp:
|
|||||||
ldy #$00
|
ldy #$00
|
||||||
pushaysp:
|
pushaysp:
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
pusha: ldy c_sp ; (3)
|
pusha: ldy c_sp ; (3)
|
||||||
beq @L1 ; (6)
|
beq @L1 ; (6)
|
||||||
dec c_sp ; (11)
|
dec c_sp ; (11)
|
||||||
ldy #0 ; (13)
|
ldy #0 ; (13)
|
||||||
sta (c_sp),y ; (19)
|
sta (c_sp),y ; (19)
|
||||||
rts ; (25)
|
rts ; (25)
|
||||||
|
|
||||||
@L1: dec c_sp+1 ; (11)
|
@L1: dec c_sp+1 ; (11)
|
||||||
dec c_sp ; (16)
|
dec c_sp ; (16)
|
||||||
sta (c_sp),y ; (22)
|
sta (c_sp),y ; (22)
|
||||||
rts ; (28)
|
rts ; (28)
|
||||||
|
|
||||||
|
|||||||
@@ -20,21 +20,21 @@ pusha0: ldx #0
|
|||||||
.proc pushax
|
.proc pushax
|
||||||
|
|
||||||
pha ; (3)
|
pha ; (3)
|
||||||
lda c_sp ; (6)
|
lda c_sp ; (6)
|
||||||
sec ; (8)
|
sec ; (8)
|
||||||
sbc #2 ; (10)
|
sbc #2 ; (10)
|
||||||
sta c_sp ; (13)
|
sta c_sp ; (13)
|
||||||
bcs @L1 ; (17)
|
bcs @L1 ; (17)
|
||||||
dec c_sp+1 ; (+5)
|
dec c_sp+1 ; (+5)
|
||||||
@L1: ldy #1 ; (19)
|
@L1: ldy #1 ; (19)
|
||||||
txa ; (21)
|
txa ; (21)
|
||||||
sta (c_sp),y ; (27)
|
sta (c_sp),y ; (27)
|
||||||
pla ; (31)
|
pla ; (31)
|
||||||
dey ; (33)
|
dey ; (33)
|
||||||
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
.if (.cpu .bitand ::CPU_ISET_65SC02)
|
||||||
sta (c_sp) ; (37)
|
sta (c_sp) ; (37)
|
||||||
.else
|
.else
|
||||||
sta (c_sp),y ; (38)
|
sta (c_sp),y ; (38)
|
||||||
.endif
|
.endif
|
||||||
rts ; (44/43)
|
rts ; (44/43)
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
pushbsp:
|
pushbsp:
|
||||||
ldy #0
|
ldy #0
|
||||||
pushbysp:
|
pushbysp:
|
||||||
lda (c_sp),y ; get lo byte
|
lda (c_sp),y ; get lo byte
|
||||||
jmp pusha0 ; promote to unsigned and push
|
jmp pusha0 ; promote to unsigned and push
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,20 +12,20 @@
|
|||||||
pushw0sp:
|
pushw0sp:
|
||||||
ldy #3
|
ldy #3
|
||||||
pushwysp:
|
pushwysp:
|
||||||
lda c_sp ; 3
|
lda c_sp ; 3
|
||||||
sub #2 ; 4
|
sub #2 ; 4
|
||||||
sta c_sp ; 3
|
sta c_sp ; 3
|
||||||
bcs @L1 ; 3(+1)
|
bcs @L1 ; 3(+1)
|
||||||
dec c_sp+1 ; (5)
|
dec c_sp+1 ; (5)
|
||||||
@L1: lda (c_sp),y ; 5 =16
|
@L1: lda (c_sp),y ; 5 =16
|
||||||
tax ; 2
|
tax ; 2
|
||||||
dey ; 2
|
dey ; 2
|
||||||
lda (c_sp),y ; 5
|
lda (c_sp),y ; 5
|
||||||
ldy #$00 ; 2
|
ldy #$00 ; 2
|
||||||
sta (c_sp),y ; 5
|
sta (c_sp),y ; 5
|
||||||
iny ; 2
|
iny ; 2
|
||||||
txa ; 2
|
txa ; 2
|
||||||
sta (c_sp),y ; 5
|
sta (c_sp),y ; 5
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
sta tmp1 ; Store count
|
sta tmp1 ; Store count
|
||||||
@L1: lda regbank,x ; Get old value
|
@L1: lda regbank,x ; Get old value
|
||||||
pha ; Save it
|
pha ; Save it
|
||||||
lda (c_sp),y ; Get stack loc
|
lda (c_sp),y ; Get stack loc
|
||||||
sta regbank,x ; Store new value
|
sta regbank,x ; Store new value
|
||||||
pla
|
pla
|
||||||
sta (c_sp),y ; Store old value
|
sta (c_sp),y ; Store old value
|
||||||
inx
|
inx
|
||||||
iny
|
iny
|
||||||
dec tmp1
|
dec tmp1
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
lda regbank,x ; Get old value
|
lda regbank,x ; Get old value
|
||||||
pha ; Save it
|
pha ; Save it
|
||||||
lda (c_sp),y ; Get stack loc
|
lda (c_sp),y ; Get stack loc
|
||||||
sta regbank,x ; Store new value
|
sta regbank,x ; Store new value
|
||||||
pla
|
pla
|
||||||
sta (c_sp),y ; Store old value
|
sta (c_sp),y ; Store old value
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|||||||
@@ -13,20 +13,20 @@
|
|||||||
|
|
||||||
lda regbank,x ; Get old value
|
lda regbank,x ; Get old value
|
||||||
pha ; Save it
|
pha ; Save it
|
||||||
lda (c_sp),y ; Get stack loc
|
lda (c_sp),y ; Get stack loc
|
||||||
sta regbank,x ; Store new value
|
sta regbank,x ; Store new value
|
||||||
pla
|
pla
|
||||||
sta (c_sp),y ; Store old value
|
sta (c_sp),y ; Store old value
|
||||||
|
|
||||||
; Second byte
|
; Second byte
|
||||||
|
|
||||||
iny
|
iny
|
||||||
lda regbank+1,x ; Get old value
|
lda regbank+1,x ; Get old value
|
||||||
pha ; Save it
|
pha ; Save it
|
||||||
lda (c_sp),y ; Get stack loc
|
lda (c_sp),y ; Get stack loc
|
||||||
sta regbank+1,x ; Store new value
|
sta regbank+1,x ; Store new value
|
||||||
pla
|
pla
|
||||||
sta (c_sp),y ; Store old value
|
sta (c_sp),y ; Store old value
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ tosrsubax:
|
|||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
sbc (c_sp),y ; lo byte
|
sbc (c_sp),y ; lo byte
|
||||||
iny
|
iny
|
||||||
.endif
|
.endif
|
||||||
sta tmp1 ; save lo byte
|
sta tmp1 ; save lo byte
|
||||||
txa
|
txa
|
||||||
sbc (c_sp),y ; hi byte
|
sbc (c_sp),y ; hi byte
|
||||||
tax
|
tax
|
||||||
lda tmp1
|
lda tmp1
|
||||||
jmp addysp1 ; drop TOS, set condition codes
|
jmp addysp1 ; drop TOS, set condition codes
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ tossubax:
|
|||||||
ldy #1
|
ldy #1
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
adc (c_sp),y ; Subtract low byte
|
adc (c_sp),y ; Subtract low byte
|
||||||
iny
|
iny
|
||||||
.endif
|
.endif
|
||||||
pha ; Save high byte
|
pha ; Save high byte
|
||||||
txa
|
txa
|
||||||
eor #$FF
|
eor #$FF
|
||||||
adc (c_sp),y ; Subtract high byte
|
adc (c_sp),y ; Subtract high byte
|
||||||
tax ; High byte into X
|
tax ; High byte into X
|
||||||
pla ; Restore low byte
|
pla ; Restore low byte
|
||||||
jmp addysp1 ; drop TOS
|
jmp addysp1 ; drop TOS
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
lda (c_sp)
|
lda (c_sp)
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
lda (c_sp),y ; c_sp+1
|
lda (c_sp),y ; c_sp+1
|
||||||
.endif
|
.endif
|
||||||
ldy #2
|
ldy #2
|
||||||
sta (c_sp),y
|
sta (c_sp),y
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ tosulong:
|
|||||||
ldy #2
|
ldy #2
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
sta (c_sp) ; 65C02 version
|
sta (c_sp) ; 65C02 version
|
||||||
iny ; Y = 3
|
iny ; Y = 3
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
@@ -44,7 +44,7 @@ toslong:
|
|||||||
ldy #2
|
ldy #2
|
||||||
lda (c_sp),y
|
lda (c_sp),y
|
||||||
.if (.cpu .bitand CPU_ISET_65SC02)
|
.if (.cpu .bitand CPU_ISET_65SC02)
|
||||||
sta (c_sp) ; 65C02 version
|
sta (c_sp) ; 65C02 version
|
||||||
iny ; Y = 3
|
iny ; Y = 3
|
||||||
.else
|
.else
|
||||||
ldy #0
|
ldy #0
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
.zeropage
|
.zeropage
|
||||||
|
|
||||||
c_sp: .res 2 ; Stack pointer
|
c_sp: .res 2 ; Stack pointer
|
||||||
sreg: .res 2 ; Secondary register/high 16 bit for longs
|
sreg: .res 2 ; Secondary register/high 16 bit for longs
|
||||||
regsave: .res 4 ; Slot to save/restore (E)AX into
|
regsave: .res 4 ; Slot to save/restore (E)AX into
|
||||||
ptr1: .res 2
|
ptr1: .res 2
|
||||||
|
|||||||
@@ -24,6 +24,6 @@
|
|||||||
.else
|
.else
|
||||||
.error Unknown CPU type.
|
.error Unknown CPU type.
|
||||||
.endif
|
.endif
|
||||||
.byte c_sp ; c_sp address
|
.byte c_sp ; c_sp address
|
||||||
.addr __MAIN_START__ ; load address
|
.addr __MAIN_START__ ; load address
|
||||||
.addr startup ; reset address
|
.addr startup ; reset address
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ reset:
|
|||||||
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||||
ldx #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
ldx #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
||||||
sta c_sp
|
sta c_sp
|
||||||
stx c_sp+1 ; Set argument stack ptr
|
stx c_sp+1 ; Set argument stack ptr
|
||||||
jsr initlib
|
jsr initlib
|
||||||
jsr _main
|
jsr _main
|
||||||
_exit: jsr donelib
|
_exit: jsr donelib
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ L1: lda c_sp,x
|
|||||||
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
lda #<(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
ldx #>(__MAIN_START__ + __MAIN_SIZE__)
|
||||||
sta c_sp
|
sta c_sp
|
||||||
stx c_sp+1 ; Set argument stack ptr
|
stx c_sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ L1: lda c_sp,x
|
|||||||
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
||||||
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
|
||||||
sta c_sp
|
sta c_sp
|
||||||
stx c_sp+1 ; Set argument stack ptr
|
stx c_sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Call the module constructors.
|
; Call the module constructors.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user