fix float array assignment

This commit is contained in:
Irmen de Jong 2020-07-26 23:32:20 +02:00
parent f81aa0d867
commit 402827497e
3 changed files with 27 additions and 52 deletions

View File

@ -215,23 +215,13 @@ pop_float_to_indexed_var .proc
copy_float .proc copy_float .proc
; -- copies the 5 bytes of the mflt value pointed to by SCRATCH_ZPWORD1, ; -- copies the 5 bytes of the mflt value pointed to by SCRATCH_ZPWORD1,
; into the 5 bytes pointed to by A/Y. Clobbers A,Y. ; into the 5 bytes pointed to by A/Y. Clobbers A,Y.
sta c64.SCRATCH_ZPWORD2 sta _target+1
sty c64.SCRATCH_ZPWORD2+1 sty _target+2
ldy #0 ldy #4
lda (c64.SCRATCH_ZPWORD1),y _loop lda (c64.SCRATCH_ZPWORD1),y
sta (c64.SCRATCH_ZPWORD2),y _target sta $ffff,y ; modified
iny dey
lda (c64.SCRATCH_ZPWORD1),y bpl _loop
sta (c64.SCRATCH_ZPWORD2),y
iny
lda (c64.SCRATCH_ZPWORD1),y
sta (c64.SCRATCH_ZPWORD2),y
iny
lda (c64.SCRATCH_ZPWORD1),y
sta (c64.SCRATCH_ZPWORD2),y
iny
lda (c64.SCRATCH_ZPWORD1),y
sta (c64.SCRATCH_ZPWORD2),y
rts rts
.pend .pend
@ -772,7 +762,6 @@ set_array_float .proc
asl a asl a
clc clc
adc c64.ESTACK_LO,x adc c64.ESTACK_LO,x
clc
adc c64.SCRATCH_ZPWORD2 adc c64.SCRATCH_ZPWORD2
ldy c64.SCRATCH_ZPWORD2+1 ldy c64.SCRATCH_ZPWORD2+1
bcc + bcc +

View File

@ -573,8 +573,7 @@ internal class AssignmentAsmGen(private val program: Program, private val errors
sta $arrayVarName+$indexValue+4 sta $arrayVarName+$indexValue+4
""") """)
} else { } else {
// TODO the index in A below seems to be clobbered? asmgen.translateExpression(index)
asmgen.translateArrayIndexIntoA(targetArrayIdx)
asmgen.out(""" asmgen.out("""
lda #<${constFloat} lda #<${constFloat}
sta ${C64Zeropage.SCRATCH_W1} sta ${C64Zeropage.SCRATCH_W1}

View File

@ -7,43 +7,30 @@
main { main {
float[] fa = [1,2,3,4]
sub start() { sub start() {
float x = 9.9
ubyte wv fa[2] = 8.8
ubyte wv2
wv *= wv2 p()
wv += 10 ubyte b = 2
wv += 20 fa[b] = 9.8
wv += 30 p()
fa[b] = 9.9
p()
wv += 1 + wv2 }
wv += 2 + wv2
wv += 3 + wv2
wv += wv2 + 1 sub p() {
wv += wv2 + 2 byte i
wv += wv2 + 3 for i in 0 to len(fa)-1 {
c64flt.print_f(fa[i])
wv = wv + 1 + wv2 c64.CHROUT(',')
wv = wv + 2 + wv2 c64.CHROUT(' ')
wv = wv + 3 + wv2 }
c64.CHROUT('\n')
wv = 1 + wv2 + wv
wv = 2 + wv2 + wv
wv = 3 + wv2 + wv
wv = wv + wv2 + 1
wv = wv + wv2 + 2
wv = wv + wv2 + 3
wv = wv2 + 1 + wv
wv = wv2 + 2 + wv
wv = wv2 + 3 + wv
wv = wv2 + wv + 1
wv = wv2 + wv + 2
wv = wv2 + wv + 3
} }
} }