mirror of
https://github.com/irmen/prog8.git
synced 2025-02-09 07:31:34 +00:00
optimized slow evaluation of byte-to-wordarray assignment
This commit is contained in:
parent
123473dfc8
commit
bc726c6334
@ -1 +1 @@
|
|||||||
6.5-SNAPSHOT
|
6.5-BETA
|
||||||
|
@ -431,8 +431,8 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// give up, do it via eval stack
|
// give up, do it via eval stack
|
||||||
// TODO optimize typecasts for more special cases?
|
|
||||||
// note: cannot use assignTypeCastedValue because that is ourselves :P
|
// note: cannot use assignTypeCastedValue because that is ourselves :P
|
||||||
|
// TODO optimize typecasts for more special cases?
|
||||||
if(this.asmgen.options.slowCodegenWarnings)
|
if(this.asmgen.options.slowCodegenWarnings)
|
||||||
println("warning: slow stack evaluation used for typecast: $value into $targetDt (target=${target.kind} at ${value.position}")
|
println("warning: slow stack evaluation used for typecast: $value into $targetDt (target=${target.kind} at ${value.position}")
|
||||||
asmgen.translateExpression(origTypeCastExpression) // this performs the actual type cast in translateExpression(Typecast)
|
asmgen.translateExpression(origTypeCastExpression) // this performs the actual type cast in translateExpression(Typecast)
|
||||||
@ -1236,11 +1236,20 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
|
|||||||
""")
|
""")
|
||||||
}
|
}
|
||||||
TargetStorageKind.ARRAY -> {
|
TargetStorageKind.ARRAY -> {
|
||||||
// TODO optimize slow stack evaluation for this case, see assignVariableUByteIntoWord
|
if (wordtarget.constArrayIndexValue!=null) {
|
||||||
if(this.asmgen.options.slowCodegenWarnings)
|
val scaledIdx = wordtarget.constArrayIndexValue!! * 2
|
||||||
println("warning: slow stack evaluation used for sign-extend byte typecast at ${bytevar.position}")
|
asmgen.out(" lda $sourceName")
|
||||||
asmgen.translateExpression(wordtarget.origAssign.source.expression!!)
|
asmgen.signExtendAYlsb(DataType.BYTE)
|
||||||
assignStackValue(wordtarget)
|
asmgen.out(" sta ${wordtarget.asmVarname}+$scaledIdx | sty ${wordtarget.asmVarname}+$scaledIdx+1")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
asmgen.saveRegisterLocal(CpuRegister.X, wordtarget.scope!!)
|
||||||
|
asmgen.loadScaledArrayIndexIntoRegister(wordtarget.array!!, wordtarget.datatype, CpuRegister.X)
|
||||||
|
asmgen.out(" lda $sourceName")
|
||||||
|
asmgen.signExtendAYlsb(DataType.BYTE)
|
||||||
|
asmgen.out(" sta ${wordtarget.asmVarname},x | inx | tya | sta ${wordtarget.asmVarname},x")
|
||||||
|
asmgen.restoreRegisterLocal(CpuRegister.X)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TargetStorageKind.REGISTER -> {
|
TargetStorageKind.REGISTER -> {
|
||||||
when(wordtarget.register!!) {
|
when(wordtarget.register!!) {
|
||||||
|
@ -688,8 +688,8 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
sec
|
sec
|
||||||
sbc P8ZP_SCRATCH_B1
|
sbc P8ZP_SCRATCH_B1
|
||||||
sta $name""")
|
sta $name""")
|
||||||
// TODO: tuned code for more operators
|
|
||||||
}
|
}
|
||||||
|
// TODO: tuned code for more operators
|
||||||
else -> {
|
else -> {
|
||||||
inplaceModification_byte_value_to_variable(name, dt, operator, memread)
|
inplaceModification_byte_value_to_variable(name, dt, operator, memread)
|
||||||
}
|
}
|
||||||
@ -719,8 +719,8 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
bcc +
|
bcc +
|
||||||
dec $name+1
|
dec $name+1
|
||||||
+""")
|
+""")
|
||||||
// TODO: tuned code for more operators
|
|
||||||
}
|
}
|
||||||
|
// TODO: tuned code for more operators
|
||||||
else -> {
|
else -> {
|
||||||
inplaceModification_word_value_to_variable(name, dt, operator, memread)
|
inplaceModification_word_value_to_variable(name, dt, operator, memread)
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,30 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import floats
|
%zeropage basicsafe
|
||||||
%zeropage floatsafe
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
float f1 = 9.9999
|
uword[] uw_arr = [1111,2222,3333]
|
||||||
float f2 = 8.8888
|
word[] w_arr = [1111,2222,3333]
|
||||||
float f3 = 0.1111
|
|
||||||
|
|
||||||
uword fs
|
ubyte ub = 42
|
||||||
|
byte bb = -42
|
||||||
|
ubyte ix = 2
|
||||||
|
|
||||||
%asm {{
|
uw_arr[1] = ub
|
||||||
phx
|
w_arr[1] = bb
|
||||||
lda #<f1
|
|
||||||
ldy #>f1
|
|
||||||
jsr floats.MOVFM
|
|
||||||
jsr floats.NEGOP
|
|
||||||
jsr floats.FOUT
|
|
||||||
sta fs
|
|
||||||
sty fs+1
|
|
||||||
plx
|
|
||||||
}}
|
|
||||||
|
|
||||||
txt.print_uwhex(fs,1)
|
txt.print_uw(uw_arr[1])
|
||||||
txt.nl()
|
txt.nl()
|
||||||
txt.print(fs)
|
txt.print_w(w_arr[1])
|
||||||
txt.nl()
|
txt.nl()
|
||||||
|
|
||||||
txt.print("ok!\n")
|
uw_arr[ix] = ub
|
||||||
sys.wait(2*60)
|
w_arr[ix] = bb
|
||||||
|
|
||||||
|
txt.print_uw(uw_arr[1])
|
||||||
|
txt.nl()
|
||||||
|
txt.print_w(w_arr[1])
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user