mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 16:29:21 +00:00
optimize word array reads with indexvar
This commit is contained in:
parent
68539d6cc9
commit
9ea69c07b8
@ -88,8 +88,8 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
||||
assignRegisterpairWord(assign.target, RegisterOrPair.AY)
|
||||
} else {
|
||||
asmgen.loadScaledArrayIndexIntoRegister(value, elementDt, CpuRegister.Y)
|
||||
asmgen.out(" lda ${arrayVarName}_lsb,y | tax | lda ${arrayVarName}_msb,y | tay | txa")
|
||||
assignRegisterpairWord(assign.target, RegisterOrPair.AY)
|
||||
asmgen.out(" lda ${arrayVarName}_lsb,y | ldx ${arrayVarName}_msb,y")
|
||||
assignRegisterpairWord(assign.target, RegisterOrPair.AX)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -122,8 +122,8 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
||||
}
|
||||
in WordDatatypes -> {
|
||||
asmgen.loadScaledArrayIndexIntoRegister(value, elementDt, CpuRegister.Y)
|
||||
asmgen.out(" lda $arrayVarName,y | tax | lda $arrayVarName+1,y | tay | txa")
|
||||
assignRegisterpairWord(assign.target, RegisterOrPair.AY)
|
||||
asmgen.out(" lda $arrayVarName,y | ldx $arrayVarName+1,y")
|
||||
assignRegisterpairWord(assign.target, RegisterOrPair.AX)
|
||||
}
|
||||
DataType.FLOAT -> {
|
||||
asmgen.loadScaledArrayIndexIntoRegister(value, elementDt, CpuRegister.A)
|
||||
@ -2209,7 +2209,8 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
||||
else
|
||||
program.memsizer.memorySize(arrayDt!!, constIndex) // add arrayIndexExpr * elementsize to the address of the array variable.
|
||||
} else {
|
||||
TODO("address-of array element $sourceName with non-const index at ${target.position}")
|
||||
val eltSize = program.memsizer.memorySize(ArrayToElementTypes.getValue(arrayDt!!))
|
||||
TODO("address-of array element $sourceName size $eltSize with non-const index at ${target.position}")
|
||||
}
|
||||
} else 0
|
||||
|
||||
|
@ -1,13 +1,7 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
- optimize word array assignment to not use tax/tay etc but simply lda+ldx: (note: with and without @split!)
|
||||
uword pstep = w_array[index] ->
|
||||
ldy p8_index
|
||||
lda p8_w_array,y
|
||||
ldx p8_w_array+1,y
|
||||
sta p8_pstep
|
||||
stx p8_pstep+1
|
||||
- fix TODO "address-of array element" in assignAddressOf()
|
||||
|
||||
- gfx2: use vera auto in/decrement in the flood fill routine
|
||||
|
||||
|
@ -1,18 +1,33 @@
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
cx16.r1H = %00000001 ; enable auto-indent
|
||||
cx16.r2L = 4
|
||||
cx16.r2H = 80
|
||||
cx16.r3L = 8
|
||||
cx16.r3H = 11<<4 | 7; background_color<<4 | text_color
|
||||
cx16.r4 = 0
|
||||
cx16.r1L = 0
|
||||
cx16.rombank($d)
|
||||
%asm {{
|
||||
ldx #2
|
||||
ldy #64
|
||||
jmp $c006
|
||||
}}
|
||||
uword[] w_array = [1111,2222,3333,4444]
|
||||
uword[] @split split_array = [1111,2222,3333,4444]
|
||||
ubyte index = 2
|
||||
|
||||
uword value = 9999
|
||||
w_array[index] = value
|
||||
split_array[index] = value
|
||||
|
||||
uword pstep = w_array[index]
|
||||
uword psteps = split_array[index]
|
||||
;; uword @zp ptr = &w_array[index]
|
||||
|
||||
txt.print_uw(pstep)
|
||||
txt.nl()
|
||||
txt.print_uw(psteps)
|
||||
txt.nl()
|
||||
; txt.print_uw(peekw(ptr))
|
||||
; txt.nl()
|
||||
|
||||
w_array[index] += 10
|
||||
split_array[index] += 10
|
||||
txt.print_uw(w_array[index])
|
||||
txt.nl()
|
||||
txt.print_uw(split_array[index])
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user