mirror of
https://github.com/irmen/prog8.git
synced 2024-12-26 14:29:35 +00:00
float type improvements
This commit is contained in:
parent
d0f5a9789b
commit
548f4fc2c6
@ -643,9 +643,24 @@ class CodeGenerator:
|
||||
self.p("\t\tst{:s} {}".format(r_register[0].lower(), lv_string))
|
||||
self.p("\t\tst{:s} {}+1".format(r_register[1].lower(), lv_string))
|
||||
elif lv.datatype == DataType.FLOAT:
|
||||
# assigning a register to a float requires ROM routines
|
||||
# assigning a register to a float requires c64 ROM routines
|
||||
if r_register in REGISTER_WORDS:
|
||||
raise CodeError("cannot yet assign register pair to float", r_register) # XXX reg pair -> float
|
||||
def do_rom_calls():
|
||||
self.p("\t\tjsr c64util.GIVUAYF") # uword AY -> fac1
|
||||
self.p("\t\tldx #<" + lv_string)
|
||||
self.p("\t\tldy #>" + lv_string)
|
||||
self.p("\t\tjsr c64.FTOMEMXY") # fac1 -> memory XY
|
||||
if r_register == "AY":
|
||||
with self.preserving_registers({'A', 'X', 'Y'}):
|
||||
do_rom_calls()
|
||||
elif r_register == "AX":
|
||||
with self.preserving_registers({'A', 'X', 'Y'}):
|
||||
self.p("\t\tpha\n\t\ttxa\n\t\ttay\n\t\tpla") # X->Y (so we have AY now)
|
||||
do_rom_calls()
|
||||
else: # XY
|
||||
with self.preserving_registers({'A', 'X', 'Y'}):
|
||||
self.p("\t\ttxa") # X->A (so we have AY now)
|
||||
do_rom_calls()
|
||||
elif r_register in "AXY":
|
||||
|
||||
def do_rom_calls():
|
||||
|
@ -272,16 +272,16 @@ start
|
||||
memfloat = cword2
|
||||
|
||||
; @todo float assignments that require ROM functions or shims:
|
||||
; memfloat = Y
|
||||
; memfloat = XY
|
||||
; uninitfloat = Y
|
||||
; uninitfloat = XY
|
||||
; initfloat2 = Y
|
||||
; initfloat2 = XY
|
||||
; initfloat2 = initbyte2
|
||||
; initfloat2 = initword2
|
||||
; initfloat1 = uninitfloat
|
||||
; initfloat1 = initfloat2
|
||||
memfloat = Y
|
||||
memfloat = XY
|
||||
uninitfloat = Y
|
||||
uninitfloat = XY
|
||||
initfloat2 = Y
|
||||
initfloat2 = XY
|
||||
;initfloat2 = initbyte2 ; @todo support
|
||||
;initfloat2 = initword2 ; @todo support
|
||||
;initfloat1 = uninitfloat ; @todo support
|
||||
;initfloat1 = initfloat2 ; @todo support
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -136,11 +136,11 @@ start
|
||||
c64.FPRINTLN!()
|
||||
|
||||
reg_to_float
|
||||
c64.CHROUT!(13)
|
||||
c64.CHROUT!('\n')
|
||||
|
||||
A=34
|
||||
X=99
|
||||
Y=121
|
||||
A=33
|
||||
X=44
|
||||
Y=55
|
||||
|
||||
my_float = A
|
||||
c64.MOVFM(#my_float)
|
||||
@ -154,13 +154,18 @@ reg_to_float
|
||||
c64.MOVFM(#my_float)
|
||||
c64.FPRINTLN()
|
||||
|
||||
XY = 56789
|
||||
;my_float = XY ; @todo support
|
||||
XY = 11122
|
||||
my_float = XY
|
||||
c64.MOVFM(#my_float)
|
||||
c64.FPRINTLN()
|
||||
|
||||
AX = 33221
|
||||
;my_float = AX ; @todo support
|
||||
AX = 33344
|
||||
my_float = AX
|
||||
c64.MOVFM(#my_float)
|
||||
c64.FPRINTLN()
|
||||
|
||||
AY = 55566
|
||||
my_float = AY
|
||||
c64.MOVFM(#my_float)
|
||||
c64.FPRINTLN()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user