refer to ZP scratch constants from asm code via the global P8ZP constants as well

This commit is contained in:
Irmen de Jong 2020-08-25 19:44:08 +02:00
parent 8d8c066447
commit 78bdbde3ae
9 changed files with 1279 additions and 1286 deletions

View File

@ -4,47 +4,47 @@
ub2float .proc
; -- convert ubyte in SCRATCH_ZPB1 to float at address A/Y
; clobbers A, Y
stx c64.SCRATCH_ZPREGX
sta c64.SCRATCH_ZPWORD2
sty c64.SCRATCH_ZPWORD2+1
ldy c64.SCRATCH_ZPB1
stx P8ZP_SCRATCH_REG_X
sta P8ZP_SCRATCH_W2
sty P8ZP_SCRATCH_W2+1
ldy P8ZP_SCRATCH_B1
jsr FREADUY
_fac_to_mem ldx c64.SCRATCH_ZPWORD2
ldy c64.SCRATCH_ZPWORD2+1
_fac_to_mem ldx P8ZP_SCRATCH_W2
ldy P8ZP_SCRATCH_W2+1
jsr MOVMF
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
.pend
b2float .proc
; -- convert byte in SCRATCH_ZPB1 to float at address A/Y
; clobbers A, Y
stx c64.SCRATCH_ZPREGX
sta c64.SCRATCH_ZPWORD2
sty c64.SCRATCH_ZPWORD2+1
lda c64.SCRATCH_ZPB1
stx P8ZP_SCRATCH_REG_X
sta P8ZP_SCRATCH_W2
sty P8ZP_SCRATCH_W2+1
lda P8ZP_SCRATCH_B1
jsr FREADSA
jmp ub2float._fac_to_mem
.pend
uw2float .proc
; -- convert uword in SCRATCH_ZPWORD1 to float at address A/Y
stx c64.SCRATCH_ZPREGX
sta c64.SCRATCH_ZPWORD2
sty c64.SCRATCH_ZPWORD2+1
lda c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
stx P8ZP_SCRATCH_REG_X
sta P8ZP_SCRATCH_W2
sty P8ZP_SCRATCH_W2+1
lda P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
jsr GIVUAYFAY
jmp ub2float._fac_to_mem
.pend
w2float .proc
; -- convert word in SCRATCH_ZPWORD1 to float at address A/Y
stx c64.SCRATCH_ZPREGX
sta c64.SCRATCH_ZPWORD2
sty c64.SCRATCH_ZPWORD2+1
ldy c64.SCRATCH_ZPWORD1
lda c64.SCRATCH_ZPWORD1+1
stx P8ZP_SCRATCH_REG_X
sta P8ZP_SCRATCH_W2
sty P8ZP_SCRATCH_W2+1
ldy P8ZP_SCRATCH_W1
lda P8ZP_SCRATCH_W1+1
jsr GIVAYF
jmp ub2float._fac_to_mem
.pend
@ -52,8 +52,8 @@ w2float .proc
stack_b2float .proc
; -- b2float operating on the stack
inx
lda c64.ESTACK_LO,x
stx c64.SCRATCH_ZPREGX
lda P8ESTACK_LO,x
stx P8ZP_SCRATCH_REG_X
jsr FREADSA
jmp push_fac1_as_result
.pend
@ -61,9 +61,9 @@ stack_b2float .proc
stack_w2float .proc
; -- w2float operating on the stack
inx
ldy c64.ESTACK_LO,x
lda c64.ESTACK_HI,x
stx c64.SCRATCH_ZPREGX
ldy P8ESTACK_LO,x
lda P8ESTACK_HI,x
stx P8ZP_SCRATCH_REG_X
jsr GIVAYF
jmp push_fac1_as_result
.pend
@ -71,8 +71,8 @@ stack_w2float .proc
stack_ub2float .proc
; -- ub2float operating on the stack
inx
lda c64.ESTACK_LO,x
stx c64.SCRATCH_ZPREGX
lda P8ESTACK_LO,x
stx P8ZP_SCRATCH_REG_X
tay
jsr FREADUY
jmp push_fac1_as_result
@ -81,34 +81,34 @@ stack_ub2float .proc
stack_uw2float .proc
; -- uw2float operating on the stack
inx
lda c64.ESTACK_LO,x
ldy c64.ESTACK_HI,x
stx c64.SCRATCH_ZPREGX
lda P8ESTACK_LO,x
ldy P8ESTACK_HI,x
stx P8ZP_SCRATCH_REG_X
jsr GIVUAYFAY
jmp push_fac1_as_result
.pend
stack_float2w .proc ; also used for float2b
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr AYINT
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
lda $64
sta c64.ESTACK_HI,x
sta P8ESTACK_HI,x
lda $65
sta c64.ESTACK_LO,x
sta P8ESTACK_LO,x
dex
rts
.pend
stack_float2uw .proc ; also used for float2ub
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr GETADR
ldx c64.SCRATCH_ZPREGX
sta c64.ESTACK_HI,x
ldx P8ZP_SCRATCH_REG_X
sta P8ESTACK_HI,x
tya
sta c64.ESTACK_LO,x
sta P8ESTACK_LO,x
dex
rts
.pend
@ -116,39 +116,39 @@ stack_float2uw .proc ; also used for float2ub
push_float .proc
; ---- push mflpt5 in A/Y onto stack
; (taking 3 stack positions = 6 bytes of which 1 is padding)
sta c64.SCRATCH_ZPWORD1
sty c64.SCRATCH_ZPWORD1+1
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1
ldy #0
lda (c64.SCRATCH_ZPWORD1),y
sta c64.ESTACK_LO,x
lda (P8ZP_SCRATCH_W1),y
sta P8ESTACK_LO,x
iny
lda (c64.SCRATCH_ZPWORD1),y
sta c64.ESTACK_HI,x
lda (P8ZP_SCRATCH_W1),y
sta P8ESTACK_HI,x
dex
iny
lda (c64.SCRATCH_ZPWORD1),y
sta c64.ESTACK_LO,x
lda (P8ZP_SCRATCH_W1),y
sta P8ESTACK_LO,x
iny
lda (c64.SCRATCH_ZPWORD1),y
sta c64.ESTACK_HI,x
lda (P8ZP_SCRATCH_W1),y
sta P8ESTACK_HI,x
dex
iny
lda (c64.SCRATCH_ZPWORD1),y
sta c64.ESTACK_LO,x
lda (P8ZP_SCRATCH_W1),y
sta P8ESTACK_LO,x
dex
rts
.pend
func_rndf .proc
; -- put a random floating point value on the stack
stx c64.SCRATCH_ZPREG
stx P8ZP_SCRATCH_REG
lda #1
jsr FREADSA
jsr RND ; rng into fac1
ldx #<_rndf_rnum5
ldy #>_rndf_rnum5
jsr MOVMF ; fac1 to mem X/Y
ldx c64.SCRATCH_ZPREG
ldx P8ZP_SCRATCH_REG
lda #<_rndf_rnum5
ldy #>_rndf_rnum5
jmp push_float
@ -158,26 +158,26 @@ _rndf_rnum5 .byte 0,0,0,0,0
pop_float .proc
; ---- pops mflpt5 from stack to memory A/Y
; (frees 3 stack positions = 6 bytes of which 1 is padding)
sta c64.SCRATCH_ZPWORD1
sty c64.SCRATCH_ZPWORD1+1
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1
ldy #4
inx
lda c64.ESTACK_LO,x
sta (c64.SCRATCH_ZPWORD1),y
lda P8ESTACK_LO,x
sta (P8ZP_SCRATCH_W1),y
dey
inx
lda c64.ESTACK_HI,x
sta (c64.SCRATCH_ZPWORD1),y
lda P8ESTACK_HI,x
sta (P8ZP_SCRATCH_W1),y
dey
lda c64.ESTACK_LO,x
sta (c64.SCRATCH_ZPWORD1),y
lda P8ESTACK_LO,x
sta (P8ZP_SCRATCH_W1),y
dey
inx
lda c64.ESTACK_HI,x
sta (c64.SCRATCH_ZPWORD1),y
lda P8ESTACK_HI,x
sta (P8ZP_SCRATCH_W1),y
dey
lda c64.ESTACK_LO,x
sta (c64.SCRATCH_ZPWORD1),y
lda P8ESTACK_LO,x
sta (P8ZP_SCRATCH_W1),y
rts
.pend
@ -203,12 +203,12 @@ pop_float_fac2 .proc
pop_float_to_indexed_var .proc
; -- pop the float on the stack, to the memory in the array at A/Y indexed by the byte on stack
sta c64.SCRATCH_ZPWORD1
sty c64.SCRATCH_ZPWORD1+1
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1
jsr prog8_lib.pop_index_times_5
jsr prog8_lib.add_a_to_zpword
lda c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
lda P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
jmp pop_float
.pend
@ -218,7 +218,7 @@ copy_float .proc
sta _target+1
sty _target+2
ldy #4
_loop lda (c64.SCRATCH_ZPWORD1),y
_loop lda (P8ZP_SCRATCH_W1),y
_target sta $ffff,y ; modified
dey
bpl _loop
@ -227,35 +227,35 @@ _target sta $ffff,y ; modified
inc_var_f .proc
; -- add 1 to float pointed to by A/Y
sta c64.SCRATCH_ZPWORD1
sty c64.SCRATCH_ZPWORD1+1
stx c64.SCRATCH_ZPREGX
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1
stx P8ZP_SCRATCH_REG_X
jsr MOVFM
lda #<FL_FONE
ldy #>FL_FONE
jsr FADD
ldx c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
ldx P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
jsr MOVMF
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
.pend
dec_var_f .proc
; -- subtract 1 from float pointed to by A/Y
sta c64.SCRATCH_ZPWORD1
sty c64.SCRATCH_ZPWORD1+1
stx c64.SCRATCH_ZPREGX
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1
stx P8ZP_SCRATCH_REG_X
lda #<FL_FONE
ldy #>FL_FONE
jsr MOVFM
lda c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
lda P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
jsr FSUB
ldx c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
ldx P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
jsr MOVMF
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
.pend
@ -284,7 +284,7 @@ push_fac1_as_result .proc
jsr MOVMF
lda #<fmath_float1
ldy #>fmath_float1
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
jmp push_float
.pend
@ -296,21 +296,21 @@ pow_f .proc
lda #<fmath_float1
ldy #>fmath_float1
jsr pop_float
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda #<fmath_float1
ldy #>fmath_float1
jsr CONUPK ; fac2 = float1
lda #<fmath_float2
ldy #>fmath_float2
jsr FPWR
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
jmp push_fac1_as_result
.pend
div_f .proc
; -- push f1/f2 on stack
jsr pop_2_floats_f2_in_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda #<fmath_float1
ldy #>fmath_float1
jsr FDIV
@ -320,7 +320,7 @@ div_f .proc
add_f .proc
; -- push f1+f2 on stack
jsr pop_2_floats_f2_in_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda #<fmath_float1
ldy #>fmath_float1
jsr FADD
@ -330,7 +330,7 @@ add_f .proc
sub_f .proc
; -- push f1-f2 on stack
jsr pop_2_floats_f2_in_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda #<fmath_float1
ldy #>fmath_float1
jsr FSUB
@ -340,7 +340,7 @@ sub_f .proc
mul_f .proc
; -- push f1*f2 on stack
jsr pop_2_floats_f2_in_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda #<fmath_float1
ldy #>fmath_float1
jsr FMULT
@ -350,7 +350,7 @@ mul_f .proc
neg_f .proc
; -- push -flt back on stack
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr NEGOP
jmp push_fac1_as_result
.pend
@ -358,7 +358,7 @@ neg_f .proc
abs_f .proc
; -- push abs(float) on stack (as float)
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr ABS
jmp push_fac1_as_result
.pend
@ -369,24 +369,24 @@ equal_f .proc
inx
inx
inx
lda c64.ESTACK_LO-3,x
cmp c64.ESTACK_LO,x
lda P8ESTACK_LO-3,x
cmp P8ESTACK_LO,x
bne _equals_false
lda c64.ESTACK_LO-2,x
cmp c64.ESTACK_LO+1,x
lda P8ESTACK_LO-2,x
cmp P8ESTACK_LO+1,x
bne _equals_false
lda c64.ESTACK_LO-1,x
cmp c64.ESTACK_LO+2,x
lda P8ESTACK_LO-1,x
cmp P8ESTACK_LO+2,x
bne _equals_false
lda c64.ESTACK_HI-2,x
cmp c64.ESTACK_HI+1,x
lda P8ESTACK_HI-2,x
cmp P8ESTACK_HI+1,x
bne _equals_false
lda c64.ESTACK_HI-1,x
cmp c64.ESTACK_HI+2,x
lda P8ESTACK_HI-1,x
cmp P8ESTACK_HI+2,x
bne _equals_false
_equals_true lda #1
_equals_store inx
sta c64.ESTACK_LO+1,x
sta P8ESTACK_LO+1,x
rts
_equals_false lda #0
beq _equals_store
@ -396,7 +396,7 @@ notequal_f .proc
; -- are the two mflpt5 numbers on the stack different?
jsr equal_f
eor #1 ; invert the result
sta c64.ESTACK_LO+1,x
sta P8ESTACK_LO+1,x
rts
.pend
@ -449,12 +449,12 @@ compare_floats .proc
jsr MOVFM ; fac1 = flt1
lda #<fmath_float2
ldy #>fmath_float2
stx c64.SCRATCH_ZPREG
stx P8ZP_SCRATCH_REG
jsr FCOMP ; A = flt1 compared with flt2 (0=equal, 1=flt1>flt2, 255=flt1<flt2)
ldx c64.SCRATCH_ZPREG
ldx P8ZP_SCRATCH_REG
rts
_return_false lda #0
_return_result sta c64.ESTACK_LO,x
_return_result sta P8ESTACK_LO,x
dex
rts
_return_true lda #1
@ -464,7 +464,7 @@ _return_true lda #1
func_sin .proc
; -- push sin(f) back onto stack
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr SIN
jmp push_fac1_as_result
.pend
@ -472,7 +472,7 @@ func_sin .proc
func_cos .proc
; -- push cos(f) back onto stack
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr COS
jmp push_fac1_as_result
.pend
@ -480,7 +480,7 @@ func_cos .proc
func_tan .proc
; -- push tan(f) back onto stack
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr TAN
jmp push_fac1_as_result
.pend
@ -488,7 +488,7 @@ func_tan .proc
func_atan .proc
; -- push atan(f) back onto stack
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr ATN
jmp push_fac1_as_result
.pend
@ -496,7 +496,7 @@ func_atan .proc
func_ln .proc
; -- push ln(f) back onto stack
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr LOG
jmp push_fac1_as_result
.pend
@ -504,7 +504,7 @@ func_ln .proc
func_log2 .proc
; -- push log base 2, ln(f)/ln(2), back onto stack
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr LOG
jsr MOVEF
lda #<c64.FL_LOG2
@ -516,7 +516,7 @@ func_log2 .proc
func_sqrt .proc
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr SQR
jmp push_fac1_as_result
.pend
@ -524,7 +524,7 @@ func_sqrt .proc
func_rad .proc
; -- convert degrees to radians (d * pi / 180)
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda #<_pi_div_180
ldy #>_pi_div_180
jsr FMULT
@ -535,7 +535,7 @@ _pi_div_180 .byte 123, 14, 250, 53, 18 ; pi / 180
func_deg .proc
; -- convert radians to degrees (d * (1/ pi * 180))
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda #<_one_over_pi_div_180
ldy #>_one_over_pi_div_180
jsr FMULT
@ -545,7 +545,7 @@ _one_over_pi_div_180 .byte 134, 101, 46, 224, 211 ; 1 / (pi * 180)
func_round .proc
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr FADDH
jsr INT
jmp push_fac1_as_result
@ -553,7 +553,7 @@ func_round .proc
func_floor .proc
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr INT
jmp push_fac1_as_result
.pend
@ -561,7 +561,7 @@ func_floor .proc
func_ceil .proc
; -- ceil: tr = int(f); if tr==f -> return else return tr+1
jsr pop_float_fac1
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
ldx #<fmath_float1
ldy #>fmath_float1
jsr MOVMF
@ -579,45 +579,45 @@ func_ceil .proc
func_any_f .proc
inx
lda c64.ESTACK_LO,x ; array size
sta c64.SCRATCH_ZPB1
lda P8ESTACK_LO,x ; array size
sta P8ZP_SCRATCH_B1
asl a
asl a
clc
adc c64.SCRATCH_ZPB1 ; times 5 because of float
adc P8ZP_SCRATCH_B1 ; times 5 because of float
jmp prog8_lib.func_any_b._entry
.pend
func_all_f .proc
inx
jsr prog8_lib.peek_address
lda c64.ESTACK_LO,x ; array size
sta c64.SCRATCH_ZPB1
lda P8ESTACK_LO,x ; array size
sta P8ZP_SCRATCH_B1
asl a
asl a
clc
adc c64.SCRATCH_ZPB1 ; times 5 because of float
adc P8ZP_SCRATCH_B1 ; times 5 because of float
tay
dey
- lda (c64.SCRATCH_ZPWORD1),y
- lda (P8ZP_SCRATCH_W1),y
clc
dey
adc (c64.SCRATCH_ZPWORD1),y
adc (P8ZP_SCRATCH_W1),y
dey
adc (c64.SCRATCH_ZPWORD1),y
adc (P8ZP_SCRATCH_W1),y
dey
adc (c64.SCRATCH_ZPWORD1),y
adc (P8ZP_SCRATCH_W1),y
dey
adc (c64.SCRATCH_ZPWORD1),y
adc (P8ZP_SCRATCH_W1),y
dey
cmp #0
beq +
cpy #255
bne -
lda #1
sta c64.ESTACK_LO+1,x
sta P8ESTACK_LO+1,x
rts
+ sta c64.ESTACK_LO+1,x
+ sta P8ESTACK_LO+1,x
rts
.pend
@ -628,23 +628,23 @@ func_max_f .proc
ldy #>_largest_neg_float
_minmax_entry jsr MOVFM
jsr prog8_lib.pop_array_and_lengthmin1Y
stx c64.SCRATCH_ZPREGX
- sty c64.SCRATCH_ZPREG
lda c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
stx P8ZP_SCRATCH_REG_X
- sty P8ZP_SCRATCH_REG
lda P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
jsr FCOMP
_minmax_cmp cmp #255 ; modified
bne +
lda c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
lda P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
jsr MOVFM
+ lda c64.SCRATCH_ZPWORD1
+ lda P8ZP_SCRATCH_W1
clc
adc #5
sta c64.SCRATCH_ZPWORD1
sta P8ZP_SCRATCH_W1
bcc +
inc c64.SCRATCH_ZPWORD1+1
+ ldy c64.SCRATCH_ZPREG
inc P8ZP_SCRATCH_W1+1
+ ldy P8ZP_SCRATCH_REG
dey
cpy #255
bne -
@ -667,21 +667,21 @@ func_sum_f .proc
ldy #>FL_ZERO
jsr MOVFM
jsr prog8_lib.pop_array_and_lengthmin1Y
stx c64.SCRATCH_ZPREGX
- sty c64.SCRATCH_ZPREG
lda c64.SCRATCH_ZPWORD1
ldy c64.SCRATCH_ZPWORD1+1
stx P8ZP_SCRATCH_REG_X
- sty P8ZP_SCRATCH_REG
lda P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
jsr FADD
ldy c64.SCRATCH_ZPREG
ldy P8ZP_SCRATCH_REG
dey
cpy #255
beq +
lda c64.SCRATCH_ZPWORD1
lda P8ZP_SCRATCH_W1
clc
adc #5
sta c64.SCRATCH_ZPWORD1
sta P8ZP_SCRATCH_W1
bcc -
inc c64.SCRATCH_ZPWORD1+1
inc P8ZP_SCRATCH_W1+1
bne -
+ jmp push_fac1_as_result
.pend
@ -689,7 +689,7 @@ func_sum_f .proc
sign_f .proc
jsr pop_float_fac1
jsr SIGN
sta c64.ESTACK_LO,x
sta P8ESTACK_LO,x
dex
rts
.pend
@ -698,22 +698,22 @@ sign_f .proc
set_0_array_float .proc
; -- set a float in an array to zero (index on stack, array in SCRATCH_ZPWORD1)
inx
lda c64.ESTACK_LO,x
lda P8ESTACK_LO,x
asl a
asl a
clc
adc c64.ESTACK_LO,x
adc P8ESTACK_LO,x
tay
lda #0
sta (c64.SCRATCH_ZPWORD1),y
sta (P8ZP_SCRATCH_W1),y
iny
sta (c64.SCRATCH_ZPWORD1),y
sta (P8ZP_SCRATCH_W1),y
iny
sta (c64.SCRATCH_ZPWORD1),y
sta (P8ZP_SCRATCH_W1),y
iny
sta (c64.SCRATCH_ZPWORD1),y
sta (P8ZP_SCRATCH_W1),y
iny
sta (c64.SCRATCH_ZPWORD1),y
sta (P8ZP_SCRATCH_W1),y
rts
.pend
@ -721,13 +721,13 @@ set_0_array_float .proc
set_array_float .proc
; -- set a float in an array to a value (index on stack, float in SCRATCH_ZPWORD1, array in SCRATCH_ZPWORD2)
inx
lda c64.ESTACK_LO,x
lda P8ESTACK_LO,x
asl a
asl a
clc
adc c64.ESTACK_LO,x
adc c64.SCRATCH_ZPWORD2
ldy c64.SCRATCH_ZPWORD2+1
adc P8ESTACK_LO,x
adc P8ZP_SCRATCH_W2
ldy P8ZP_SCRATCH_W2+1
bcc +
iny
+ jmp copy_float
@ -739,12 +739,12 @@ set_array_float .proc
swap_floats .proc
; -- swap floats pointed to by SCRATCH_ZPWORD1, SCRATCH_ZPWORD2
ldy #4
- lda (c64.SCRATCH_ZPWORD1),y
- lda (P8ZP_SCRATCH_W1),y
pha
lda (c64.SCRATCH_ZPWORD2),y
sta (c64.SCRATCH_ZPWORD1),y
lda (P8ZP_SCRATCH_W2),y
sta (P8ZP_SCRATCH_W1),y
pla
sta (c64.SCRATCH_ZPWORD2),y
sta (P8ZP_SCRATCH_W2),y
dey
bpl -
rts

View File

@ -163,9 +163,9 @@ asmsub GIVUAYFAY (uword value @ AY) clobbers(A,X,Y) {
asmsub GIVAYFAY (uword value @ AY) clobbers(A,X,Y) {
; ---- signed 16 bit word in A/Y (lo/hi) to float in fac1
%asm {{
sta c64.SCRATCH_ZPREG
sta P8ZP_SCRATCH_REG
tya
ldy c64.SCRATCH_ZPREG
ldy P8ZP_SCRATCH_REG
jmp GIVAYF ; this uses the inverse order, Y/A
}}
}
@ -174,9 +174,9 @@ asmsub FTOSWRDAY () clobbers(X) -> uword @ AY {
; ---- fac1 to signed word in A/Y
%asm {{
jsr FTOSWORDYA ; note the inverse Y/A order
sta c64.SCRATCH_ZPREG
sta P8ZP_SCRATCH_REG
tya
ldy c64.SCRATCH_ZPREG
ldy P8ZP_SCRATCH_REG
rts
}}
}
@ -185,9 +185,9 @@ asmsub GETADRAY () clobbers(X) -> uword @ AY {
; ---- fac1 to unsigned word in A/Y
%asm {{
jsr GETADR ; this uses the inverse order, Y/A
sta c64.SCRATCH_ZPB1
sta P8ZP_SCRATCH_B1
tya
ldy c64.SCRATCH_ZPB1
ldy P8ZP_SCRATCH_B1
rts
}}
}
@ -195,13 +195,13 @@ asmsub GETADRAY () clobbers(X) -> uword @ AY {
sub print_f (float value) {
; ---- prints the floating point value (without a newline) using basic rom routines.
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda #<value
ldy #>value
jsr MOVFM ; load float into fac1
jsr FOUT ; fac1 to string in A/Y
jsr c64.STROUT ; print string in A/Y
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -209,12 +209,12 @@ sub print_f (float value) {
sub print_fln (float value) {
; ---- prints the floating point value (with a newline at the end) using basic rom routines
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda #<value
ldy #>value
jsr MOVFM ; load float into fac1
jsr FPRINTLN ; print fac1 with newline
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}

View File

@ -7,16 +7,6 @@
c64 {
; TODO get rid of those:
const uword ESTACK_LO = $ce00 ; evaluation stack (lsb)
const uword ESTACK_HI = $cf00 ; evaluation stack (msb)
&ubyte SCRATCH_ZPB1 = $02 ; scratch byte 1 in ZP
&ubyte SCRATCH_ZPREG = $03 ; scratch register in ZP
&ubyte SCRATCH_ZPREGX = $fa ; temp storage for X register (stack pointer)
&uword SCRATCH_ZPWORD1 = $fb ; scratch word in ZP ($fb/$fc)
&uword SCRATCH_ZPWORD2 = $fd ; scratch word in ZP ($fd/$fe)
&ubyte TIME_HI = $a0 ; software jiffy clock, hi byte
&ubyte TIME_MID = $a1 ; .. mid byte
&ubyte TIME_LO = $a2 ; .. lo byte. Updated by IRQ every 1/60 sec

View File

@ -59,9 +59,9 @@ asmsub uword2decimal (uword value @ AY) -> ubyte @Y, ubyte @A, ubyte @X {
ASCII_0_OFFSET = $30
temp = c64.SCRATCH_ZPB1 ; byte in zeropage
hexHigh = c64.SCRATCH_ZPWORD1 ; byte in zeropage
hexLow = c64.SCRATCH_ZPWORD1+1 ; byte in zeropage
temp = P8ZP_SCRATCH_B1 ; byte in zeropage
hexHigh = P8ZP_SCRATCH_W1 ; byte in zeropage
hexLow = P8ZP_SCRATCH_W1+1 ; byte in zeropage
HexToDec65535; SUBROUTINE
@ -221,7 +221,7 @@ asmsub byte2decimal (byte value @ A) -> ubyte @ Y, ubyte @ A, ubyte @ X {
asmsub ubyte2hex (ubyte value @ A) -> ubyte @ A, ubyte @ Y {
; ---- A to hex petscii string in AY (first hex char in A, second hex char in Y)
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
pha
and #$0f
tax
@ -233,7 +233,7 @@ asmsub ubyte2hex (ubyte value @ A) -> ubyte @ A, ubyte @ Y {
lsr a
tax
lda _hex_digits,x
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
_hex_digits .text "0123456789abcdef" ; can probably be reused for other stuff as well
@ -243,12 +243,12 @@ _hex_digits .text "0123456789abcdef" ; can probably be reused for other stuff as
asmsub uword2hex (uword value @ AY) clobbers(A,Y) {
; ---- convert 16 bit uword in A/Y into 4-character hexadecimal string 'uword2hex.output' (0-terminated)
%asm {{
sta c64.SCRATCH_ZPREG
sta P8ZP_SCRATCH_REG
tya
jsr ubyte2hex
sta output
sty output+1
lda c64.SCRATCH_ZPREG
lda P8ZP_SCRATCH_REG
jsr ubyte2hex
sta output+2
sty output+3
@ -262,7 +262,7 @@ asmsub str2uword(str string @ AY) -> uword @ AY {
; the number may NOT be preceded by a + sign and may NOT contain spaces
; (any non-digit character will terminate the number string that is parsed)
%asm {{
_result = c64.SCRATCH_ZPWORD2
_result = P8ZP_SCRATCH_W2
sta _mod+1
sty _mod+2
ldy #0
@ -293,16 +293,16 @@ _done ; return result
_result_times_10 ; (W*4 + W)*2
lda _result+1
sta c64.SCRATCH_ZPREG
sta P8ZP_SCRATCH_REG
lda _result
asl a
rol c64.SCRATCH_ZPREG
rol P8ZP_SCRATCH_REG
asl a
rol c64.SCRATCH_ZPREG
rol P8ZP_SCRATCH_REG
clc
adc _result
sta _result
lda c64.SCRATCH_ZPREG
lda P8ZP_SCRATCH_REG
adc _result+1
asl _result
rol a
@ -316,14 +316,14 @@ asmsub str2word(str string @ AY) -> word @ AY {
; the number may be preceded by a + or - sign but may NOT contain spaces
; (any non-digit character will terminate the number string that is parsed)
%asm {{
_result = c64.SCRATCH_ZPWORD2
sta c64.SCRATCH_ZPWORD1
sty c64.SCRATCH_ZPWORD1+1
_result = P8ZP_SCRATCH_W2
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1
ldy #0
sty _result
sty _result+1
sty _negative
lda (c64.SCRATCH_ZPWORD1),y
lda (P8ZP_SCRATCH_W1),y
cmp #'+'
bne +
iny
@ -331,7 +331,7 @@ _result = c64.SCRATCH_ZPWORD2
bne _parse
inc _negative
iny
_parse lda (c64.SCRATCH_ZPWORD1),y
_parse lda (P8ZP_SCRATCH_W1),y
sec
sbc #48
bpl _digit
@ -402,19 +402,19 @@ _irq_handler jsr _irq_handler_init
_irq_handler_init
; save all zp scratch registers and the X register as these might be clobbered by the irq routine
stx IRQ_X_REG
lda c64.SCRATCH_ZPB1
lda P8ZP_SCRATCH_B1
sta IRQ_SCRATCH_ZPB1
lda c64.SCRATCH_ZPREG
lda P8ZP_SCRATCH_REG
sta IRQ_SCRATCH_ZPREG
lda c64.SCRATCH_ZPREGX
lda P8ZP_SCRATCH_REG_X
sta IRQ_SCRATCH_ZPREGX
lda c64.SCRATCH_ZPWORD1
lda P8ZP_SCRATCH_W1
sta IRQ_SCRATCH_ZPWORD1
lda c64.SCRATCH_ZPWORD1+1
lda P8ZP_SCRATCH_W1+1
sta IRQ_SCRATCH_ZPWORD1+1
lda c64.SCRATCH_ZPWORD2
lda P8ZP_SCRATCH_W2
sta IRQ_SCRATCH_ZPWORD2
lda c64.SCRATCH_ZPWORD2+1
lda P8ZP_SCRATCH_W2+1
sta IRQ_SCRATCH_ZPWORD2+1
; stack protector; make sure we don't clobber the top of the evaluation stack
dex
@ -429,19 +429,19 @@ _irq_handler_init
_irq_handler_end
; restore all zp scratch registers and the X register
lda IRQ_SCRATCH_ZPB1
sta c64.SCRATCH_ZPB1
sta P8ZP_SCRATCH_B1
lda IRQ_SCRATCH_ZPREG
sta c64.SCRATCH_ZPREG
sta P8ZP_SCRATCH_REG
lda IRQ_SCRATCH_ZPREGX
sta c64.SCRATCH_ZPREGX
sta P8ZP_SCRATCH_REG_X
lda IRQ_SCRATCH_ZPWORD1
sta c64.SCRATCH_ZPWORD1
sta P8ZP_SCRATCH_W1
lda IRQ_SCRATCH_ZPWORD1+1
sta c64.SCRATCH_ZPWORD1+1
sta P8ZP_SCRATCH_W1+1
lda IRQ_SCRATCH_ZPWORD2
sta c64.SCRATCH_ZPWORD2
sta P8ZP_SCRATCH_W2
lda IRQ_SCRATCH_ZPWORD2+1
sta c64.SCRATCH_ZPWORD2+1
sta P8ZP_SCRATCH_W2+1
ldx IRQ_X_REG
rts
@ -595,7 +595,7 @@ asmsub scroll_left_full (ubyte alsocolors @ Pc) clobbers(A, Y) {
; Carry flag determines if screen color data must be scrolled too
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
bcs +
jmp _scroll_screen
@ -623,7 +623,7 @@ _scroll_screen ; scroll the screen memory
dey
bpl -
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -633,7 +633,7 @@ asmsub scroll_right_full (ubyte alsocolors @ Pc) clobbers(A) {
; contents of the leftmost column are unchanged, you should clear/refill this yourself
; Carry flag determines if screen color data must be scrolled too
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
bcs +
jmp _scroll_screen
@ -657,7 +657,7 @@ _scroll_screen ; scroll the screen memory
dex
bpl -
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -667,7 +667,7 @@ asmsub scroll_up_full (ubyte alsocolors @ Pc) clobbers(A) {
; contents of the bottom row are unchanged, you should refill/clear this yourself
; Carry flag determines if screen color data must be scrolled too
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
bcs +
jmp _scroll_screen
@ -691,7 +691,7 @@ _scroll_screen ; scroll the screen memory
dex
bpl -
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -701,7 +701,7 @@ asmsub scroll_down_full (ubyte alsocolors @ Pc) clobbers(A) {
; contents of the top row are unchanged, you should refill/clear this yourself
; Carry flag determines if screen color data must be scrolled too
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
bcs +
jmp _scroll_screen
@ -725,7 +725,7 @@ _scroll_screen ; scroll the screen memory
dex
bpl -
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -737,10 +737,10 @@ asmsub print (str text @ AY) clobbers(A,Y) {
; a call to this subroutine with a string argument of just one char,
; by just one call to c64.CHROUT of that single char.
%asm {{
sta c64.SCRATCH_ZPB1
sty c64.SCRATCH_ZPREG
sta P8ZP_SCRATCH_B1
sty P8ZP_SCRATCH_REG
ldy #0
- lda (c64.SCRATCH_ZPB1),y
- lda (P8ZP_SCRATCH_B1),y
beq +
jsr c64.CHROUT
iny
@ -752,7 +752,7 @@ asmsub print (str text @ AY) clobbers(A,Y) {
asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) {
; ---- print the ubyte in A in decimal form, with left padding 0s (3 positions total)
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr c64utils.ubyte2decimal
pha
tya
@ -761,7 +761,7 @@ asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) {
jsr c64.CHROUT
txa
jsr c64.CHROUT
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -769,7 +769,7 @@ asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) {
asmsub print_ub (ubyte value @ A) clobbers(A,Y) {
; ---- print the ubyte in A in decimal form, without left padding 0s
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr c64utils.ubyte2decimal
_print_byte_digits
pha
@ -786,7 +786,7 @@ _print_byte_digits
jsr c64.CHROUT
_ones txa
jsr c64.CHROUT
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -794,7 +794,7 @@ _ones txa
asmsub print_b (byte value @ A) clobbers(A,Y) {
; ---- print the byte in A in decimal form, without left padding 0s
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
pha
cmp #0
bpl +
@ -803,7 +803,7 @@ asmsub print_b (byte value @ A) clobbers(A,Y) {
+ pla
jsr c64utils.byte2decimal
jsr print_ub._print_byte_digits
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -811,7 +811,7 @@ asmsub print_b (byte value @ A) clobbers(A,Y) {
asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
; ---- print the ubyte in A in hex form (if Carry is set, a radix prefix '$' is printed as well)
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
bcc +
pha
lda #'$'
@ -821,7 +821,7 @@ asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
jsr c64.CHROUT
tya
jsr c64.CHROUT
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -829,20 +829,20 @@ asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
asmsub print_ubbin (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
; ---- print the ubyte in A in binary form (if Carry is set, a radix prefix '%' is printed as well)
%asm {{
stx c64.SCRATCH_ZPREGX
sta c64.SCRATCH_ZPB1
stx P8ZP_SCRATCH_REG_X
sta P8ZP_SCRATCH_B1
bcc +
lda #'%'
jsr c64.CHROUT
+ ldy #8
- lda #'0'
asl c64.SCRATCH_ZPB1
asl P8ZP_SCRATCH_B1
bcc +
lda #'1'
+ jsr c64.CHROUT
dey
bne -
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -875,7 +875,7 @@ asmsub print_uwhex (uword value @ AY, ubyte prefix @ Pc) clobbers(A,Y) {
asmsub print_uw0 (uword value @ AY) clobbers(A,Y) {
; ---- print the uword in A/Y in decimal form, with left padding 0s (5 positions total)
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr c64utils.uword2decimal
ldy #0
- lda c64utils.uword2decimal.decTenThousands,y
@ -883,7 +883,7 @@ asmsub print_uw0 (uword value @ AY) clobbers(A,Y) {
jsr c64.CHROUT
iny
bne -
+ ldx c64.SCRATCH_ZPREGX
+ ldx P8ZP_SCRATCH_REG_X
rts
}}
}
@ -891,9 +891,9 @@ asmsub print_uw0 (uword value @ AY) clobbers(A,Y) {
asmsub print_uw (uword value @ AY) clobbers(A,Y) {
; ---- print the uword in A/Y in decimal form, without left padding 0s
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
jsr c64utils.uword2decimal
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
ldy #0
- lda c64utils.uword2decimal.decTenThousands,y
beq _allzero
@ -940,17 +940,17 @@ asmsub input_chars (uword buffer @ AY) clobbers(A) -> ubyte @ Y {
; It assumes the keyboard is selected as I/O channel!
%asm {{
sta c64.SCRATCH_ZPWORD1
sty c64.SCRATCH_ZPWORD1+1
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1
ldy #0 ; char counter = 0
- jsr c64.CHRIN
cmp #$0d ; return (ascii 13) pressed?
beq + ; yes, end.
sta (c64.SCRATCH_ZPWORD1),y ; else store char in buffer
sta (P8ZP_SCRATCH_W1),y ; else store char in buffer
iny
bne -
+ lda #0
sta (c64.SCRATCH_ZPWORD1),y ; finish string with 0 byte
sta (P8ZP_SCRATCH_W1),y ; finish string with 0 byte
rts
}}
@ -959,18 +959,18 @@ asmsub input_chars (uword buffer @ AY) clobbers(A) -> ubyte @ Y {
asmsub setchr (ubyte col @Y, ubyte row @A) clobbers(A) {
; ---- set the character in SCRATCH_ZPB1 on the screen matrix at the given position
%asm {{
sty c64.SCRATCH_ZPREG
sty P8ZP_SCRATCH_REG
asl a
tay
lda _screenrows+1,y
sta _mod+2
lda _screenrows,y
clc
adc c64.SCRATCH_ZPREG
adc P8ZP_SCRATCH_REG
sta _mod+1
bcc +
inc _mod+2
+ lda c64.SCRATCH_ZPB1
+ lda P8ZP_SCRATCH_B1
_mod sta $ffff ; modified
rts
@ -981,14 +981,14 @@ _screenrows .word $0400 + range(0, 1000, 40)
asmsub getchr (ubyte col @Y, ubyte row @A) clobbers(Y) -> ubyte @ A {
; ---- get the character in the screen matrix at the given location
%asm {{
sty c64.SCRATCH_ZPB1
sty P8ZP_SCRATCH_B1
asl a
tay
lda setchr._screenrows+1,y
sta _mod+2
lda setchr._screenrows,y
clc
adc c64.SCRATCH_ZPB1
adc P8ZP_SCRATCH_B1
sta _mod+1
bcc _mod
inc _mod+2
@ -1000,18 +1000,18 @@ _mod lda $ffff ; modified
asmsub setclr (ubyte col @Y, ubyte row @A) clobbers(A) {
; ---- set the color in SCRATCH_ZPB1 on the screen matrix at the given position
%asm {{
sty c64.SCRATCH_ZPREG
sty P8ZP_SCRATCH_REG
asl a
tay
lda _colorrows+1,y
sta _mod+2
lda _colorrows,y
clc
adc c64.SCRATCH_ZPREG
adc P8ZP_SCRATCH_REG
sta _mod+1
bcc +
inc _mod+2
+ lda c64.SCRATCH_ZPB1
+ lda P8ZP_SCRATCH_B1
_mod sta $ffff ; modified
rts
@ -1022,14 +1022,14 @@ _colorrows .word $d800 + range(0, 1000, 40)
asmsub getclr (ubyte col @Y, ubyte row @A) clobbers(Y) -> ubyte @ A {
; ---- get the color in the screen color matrix at the given location
%asm {{
sty c64.SCRATCH_ZPB1
sty P8ZP_SCRATCH_B1
asl a
tay
lda setclr._colorrows+1,y
sta _mod+2
lda setclr._colorrows,y
clc
adc c64.SCRATCH_ZPB1
adc P8ZP_SCRATCH_B1
sta _mod+1
bcc _mod
inc _mod+2
@ -1067,11 +1067,11 @@ _colormod sta $ffff ; modified
asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) {
; ---- safe wrapper around PLOT kernel routine, to save the X register.
%asm {{
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
tax
clc
jsr c64.PLOT
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
}}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ internal class FunctionCallAsmGen(private val program: Program, private val asmg
val sub = stmt.target.targetSubroutine(program.namespace) ?: throw AssemblyError("undefined subroutine ${stmt.target}")
val saveX = CpuRegister.X in sub.asmClobbers || sub.regXasResult()
if(saveX)
asmgen.out(" stx c64.SCRATCH_ZPREGX") // we only save X for now (required! is the eval stack pointer), screw A and Y...
asmgen.out(" stx P8ZP_SCRATCH_REG_X") // we only save X for now (required! is the eval stack pointer), screw A and Y...
val subName = asmgen.asmIdentifierName(stmt.target)
if(stmt.args.isNotEmpty()) {
@ -57,7 +57,7 @@ internal class FunctionCallAsmGen(private val program: Program, private val asmg
asmgen.out(" jsr $subName")
if(saveX)
asmgen.out(" ldx c64.SCRATCH_ZPREGX") // restore X again
asmgen.out(" ldx P8ZP_SCRATCH_REG_X") // restore X again
}
private fun registerArgsViaStackEvaluation(stmt: IFunctionCall, sub: Subroutine) {

View File

@ -617,9 +617,9 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
// TODO what about the optimized routines?
asmgen.out("""
lda $name
sta c64.SCRATCH_ZPWORD1
sta P8ZP_SCRATCH_W1
lda $name+1
sta c64.SCRATCH_ZPWORD1+1
sta P8ZP_SCRATCH_W1+1
lda #<$value
ldy #>$value
jsr math.multiply_words
@ -801,7 +801,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
asmgen.translateExpression(value)
asmgen.out("""
inx
ldy c64.ESTACK_LO,x
ldy P8ESTACK_LO,x
beq +
- asl $name
rol $name+1
@ -814,7 +814,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
if(dt==DataType.UWORD) {
asmgen.out("""
inx
ldy c64.ESTACK_LO,x
ldy P8ESTACK_LO,x
beq +
- lsr $name+1
ror $name
@ -824,7 +824,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
else {
asmgen.out("""
inx
ldy c64.ESTACK_LO,x
ldy P8ESTACK_LO,x
beq +
- lda $name+1
asl a
@ -891,7 +891,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
asmgen.translateExpression(value)
asmgen.out("""
inx
ldy c64.ESTACK_LO,x
ldy P8ESTACK_LO,x
beq +
- asl $name
dey
@ -903,7 +903,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
if(dt==DataType.UBYTE) {
asmgen.out("""
inx
ldy c64.ESTACK_LO,x
ldy P8ESTACK_LO,x
beq +
- lsr $name
dey
@ -912,7 +912,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
} else {
asmgen.out("""
inx
ldy c64.ESTACK_LO,x
ldy P8ESTACK_LO,x
beq +
- lda $name
asl a

View File

@ -186,11 +186,11 @@ graphics {
asmsub plot(ubyte ploty @A) { ; plotx is 16 bits 0 to 319... doesn't fit in a register
%asm {{
tay
stx c64.SCRATCH_ZPREGX
stx P8ZP_SCRATCH_REG_X
lda plotx+1
sta c64.SCRATCH_ZPWORD2+1
sta P8ZP_SCRATCH_W2+1
lsr a ; 0
sta c64.SCRATCH_ZPWORD2
sta P8ZP_SCRATCH_W2
lda plotx
pha
and #7
@ -198,20 +198,20 @@ graphics {
lda _y_lookup_lo,y
clc
adc c64.SCRATCH_ZPWORD2
sta c64.SCRATCH_ZPWORD2
adc P8ZP_SCRATCH_W2
sta P8ZP_SCRATCH_W2
lda _y_lookup_hi,y
adc c64.SCRATCH_ZPWORD2+1
sta c64.SCRATCH_ZPWORD2+1
adc P8ZP_SCRATCH_W2+1
sta P8ZP_SCRATCH_W2+1
pla ; plotx
and #%11111000
tay
lda (c64.SCRATCH_ZPWORD2),y
lda (P8ZP_SCRATCH_W2),y
ora _ormask,x
sta (c64.SCRATCH_ZPWORD2),y
sta (P8ZP_SCRATCH_W2),y
ldx c64.SCRATCH_ZPREGX
ldx P8ZP_SCRATCH_REG_X
rts
_ormask .byte 128, 64, 32, 16, 8, 4, 2, 1