mirror of
https://github.com/irmen/prog8.git
synced 2024-11-26 11:49:22 +00:00
fix ubyte/uword to float conversion crashes on Commander X16
This commit is contained in:
parent
60e169bd87
commit
9120e1de88
@ -79,10 +79,10 @@ asmsub GIVUAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
||||
; ---- unsigned 16 bit word in A/Y (lo/hi) to fac1
|
||||
%asm {{
|
||||
phx
|
||||
sta P8ZP_SCRATCH_W2
|
||||
sta _tmp
|
||||
sty P8ZP_SCRATCH_B1
|
||||
tya
|
||||
ldy P8ZP_SCRATCH_W2
|
||||
ldy _tmp
|
||||
jsr GIVAYF ; load it as signed... correct afterwards
|
||||
lda P8ZP_SCRATCH_B1
|
||||
bpl +
|
||||
@ -91,6 +91,7 @@ asmsub GIVUAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
||||
jsr FADD
|
||||
+ plx
|
||||
rts
|
||||
_tmp .byte 0
|
||||
_flt65536 .byte 145,0,0,0,0 ; 65536.0
|
||||
}}
|
||||
}
|
||||
@ -128,6 +129,14 @@ asmsub GETADRAY () clobbers(X) -> uword @ AY {
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub FREADUY (ubyte value @Y) {
|
||||
; -- 8 bit unsigned Y -> float in fac1
|
||||
%asm {{
|
||||
lda #0
|
||||
jmp GIVAYF
|
||||
}}
|
||||
}
|
||||
|
||||
sub print_f (float value) {
|
||||
; ---- prints the floating point value (without a newline).
|
||||
%asm {{
|
||||
|
@ -3,67 +3,37 @@
|
||||
%import test_stack
|
||||
%zeropage dontuse
|
||||
|
||||
; TODO fix float conversion crashes on Cx16 (ubyte as float, uword as float)
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
uword total=0
|
||||
uword xx
|
||||
float fl
|
||||
float fltotal=0.0
|
||||
ubyte ub = 22
|
||||
|
||||
for xx in 0 to 100 {
|
||||
txt.print_uw(xx*xx)
|
||||
txt.chrout(',')
|
||||
}
|
||||
ub = 22
|
||||
fl = ub as float
|
||||
floats.print_f(fl)
|
||||
txt.nl()
|
||||
ub = 255
|
||||
fl = ub as float
|
||||
floats.print_f(fl)
|
||||
txt.nl()
|
||||
xx = 123
|
||||
fl = xx as float
|
||||
floats.print_f(fl)
|
||||
txt.nl()
|
||||
xx = 55555
|
||||
fl = xx as float
|
||||
floats.print_f(fl)
|
||||
txt.nl()
|
||||
|
||||
total = 0
|
||||
c64.SETTIM(0,0,0)
|
||||
repeat 5 {
|
||||
for xx in 1 to 255 {
|
||||
total += xx*xx
|
||||
}
|
||||
fltotal=0.0
|
||||
for xx in 1 to 255 {
|
||||
fl = xx as float
|
||||
fltotal = fl * fl
|
||||
}
|
||||
txt.print_uw(total)
|
||||
txt.nl()
|
||||
txt.print_uw(c64.RDTIM16())
|
||||
txt.nl()
|
||||
txt.nl()
|
||||
|
||||
test_stack.test()
|
||||
|
||||
; fltotal=0.0
|
||||
; c64.SETTIM(0,0,0)
|
||||
; repeat 5 {
|
||||
; for xx in 1 to 255 {
|
||||
; fl = xx as float
|
||||
; ; fl = ub as float
|
||||
; fltotal = fl * fl
|
||||
; }
|
||||
; }
|
||||
;
|
||||
; floats.print_f(fltotal)
|
||||
; txt.nl()
|
||||
; txt.print_uw(c64.RDTIM16())
|
||||
; txt.nl()
|
||||
; txt.nl()
|
||||
;
|
||||
; fltotal=0.0
|
||||
; c64.SETTIM(0,0,0)
|
||||
; repeat 5 {
|
||||
; for xx in 1 to 255 {
|
||||
; fl = xx as float
|
||||
; ; fl = ub as float
|
||||
; fltotal = fl ** 2
|
||||
; }
|
||||
; }
|
||||
;
|
||||
; floats.print_f(fltotal)
|
||||
; txt.nl()
|
||||
; txt.print_uw(c64.RDTIM16())
|
||||
; txt.nl()
|
||||
; txt.nl()
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user