fixed crash on cx16 in word to float conversion

This commit is contained in:
Irmen de Jong 2020-12-28 00:19:58 +01:00
parent 69780ecde9
commit 6c8b18ddbd
2 changed files with 10 additions and 9 deletions

View File

@ -99,9 +99,9 @@ _flt65536 .byte 145,0,0,0,0 ; 65536.0
asmsub GIVAYFAY (uword value @ AY) clobbers(A,X,Y) {
; ---- signed 16 bit word in A/Y (lo/hi) to float in fac1
%asm {{
sta P8ZP_SCRATCH_W2
sta P8ZP_SCRATCH_B1
tya
ldy P8ZP_SCRATCH_W2
ldy P8ZP_SCRATCH_B1
jmp GIVAYF ; this uses the inverse order, Y/A
}}
}
@ -110,9 +110,9 @@ asmsub FTOSWRDAY () clobbers(X) -> uword @ AY {
; ---- fac1 to signed word in A/Y
%asm {{
jsr FTOSWORDYA ; note the inverse Y/A order
sta P8ZP_SCRATCH_REG
sta P8ZP_SCRATCH_B1
tya
ldy P8ZP_SCRATCH_REG
ldy P8ZP_SCRATCH_B1
rts
}}
}

View File

@ -10,15 +10,16 @@ main {
sub start () {
word ww
float x_f = -300.0
float y_f
float fl
for ww in -300 to 300 { ; TODO fix crash if ww is not defined
;fl = ww as float ; TODO doesn't work???
y_f = cos(x_f/30.0)*60 - x_f/1.7
; gfx2.plot(ww + 320 as uword, (y_f + 240) as uword, 1)
x_f += 1.0
fl = ww as float
floats.print_f(fl)
txt.chrout(' ')
}
test_stack.test()
}