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
; -- 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.
sta c64.SCRATCH_ZPWORD2
sty c64.SCRATCH_ZPWORD2+1
ldy #0
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
iny
lda (c64.SCRATCH_ZPWORD1),y
sta (c64.SCRATCH_ZPWORD2),y
iny
lda (c64.SCRATCH_ZPWORD1),y
sta (c64.SCRATCH_ZPWORD2),y
sta _target+1
sty _target+2
ldy #4
_loop lda (c64.SCRATCH_ZPWORD1),y
_target sta $ffff,y ; modified
dey
bpl _loop
rts
.pend
@ -772,7 +762,6 @@ set_array_float .proc
asl a
clc
adc c64.ESTACK_LO,x
clc
adc c64.SCRATCH_ZPWORD2
ldy c64.SCRATCH_ZPWORD2+1
bcc +

View File

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

View File

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