mirror of
https://github.com/irmen/prog8.git
synced 2025-02-04 02:30:19 +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
|
||||
// TODO optimize typecasts for more special cases?
|
||||
// note: cannot use assignTypeCastedValue because that is ourselves :P
|
||||
// TODO optimize typecasts for more special cases?
|
||||
if(this.asmgen.options.slowCodegenWarnings)
|
||||
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)
|
||||
@ -1236,11 +1236,20 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
|
||||
""")
|
||||
}
|
||||
TargetStorageKind.ARRAY -> {
|
||||
// TODO optimize slow stack evaluation for this case, see assignVariableUByteIntoWord
|
||||
if(this.asmgen.options.slowCodegenWarnings)
|
||||
println("warning: slow stack evaluation used for sign-extend byte typecast at ${bytevar.position}")
|
||||
asmgen.translateExpression(wordtarget.origAssign.source.expression!!)
|
||||
assignStackValue(wordtarget)
|
||||
if (wordtarget.constArrayIndexValue!=null) {
|
||||
val scaledIdx = wordtarget.constArrayIndexValue!! * 2
|
||||
asmgen.out(" lda $sourceName")
|
||||
asmgen.signExtendAYlsb(DataType.BYTE)
|
||||
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 -> {
|
||||
when(wordtarget.register!!) {
|
||||
|
@ -688,8 +688,8 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
sec
|
||||
sbc P8ZP_SCRATCH_B1
|
||||
sta $name""")
|
||||
// TODO: tuned code for more operators
|
||||
}
|
||||
// TODO: tuned code for more operators
|
||||
else -> {
|
||||
inplaceModification_byte_value_to_variable(name, dt, operator, memread)
|
||||
}
|
||||
@ -719,8 +719,8 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
||||
bcc +
|
||||
dec $name+1
|
||||
+""")
|
||||
// TODO: tuned code for more operators
|
||||
}
|
||||
// TODO: tuned code for more operators
|
||||
else -> {
|
||||
inplaceModification_word_value_to_variable(name, dt, operator, memread)
|
||||
}
|
||||
|
@ -1,34 +1,30 @@
|
||||
%import textio
|
||||
%import floats
|
||||
%zeropage floatsafe
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
|
||||
sub start() {
|
||||
float f1 = 9.9999
|
||||
float f2 = 8.8888
|
||||
float f3 = 0.1111
|
||||
uword[] uw_arr = [1111,2222,3333]
|
||||
word[] w_arr = [1111,2222,3333]
|
||||
|
||||
uword fs
|
||||
ubyte ub = 42
|
||||
byte bb = -42
|
||||
ubyte ix = 2
|
||||
|
||||
%asm {{
|
||||
phx
|
||||
lda #<f1
|
||||
ldy #>f1
|
||||
jsr floats.MOVFM
|
||||
jsr floats.NEGOP
|
||||
jsr floats.FOUT
|
||||
sta fs
|
||||
sty fs+1
|
||||
plx
|
||||
}}
|
||||
uw_arr[1] = ub
|
||||
w_arr[1] = bb
|
||||
|
||||
txt.print_uwhex(fs,1)
|
||||
txt.print_uw(uw_arr[1])
|
||||
txt.nl()
|
||||
txt.print(fs)
|
||||
txt.print_w(w_arr[1])
|
||||
txt.nl()
|
||||
|
||||
txt.print("ok!\n")
|
||||
sys.wait(2*60)
|
||||
uw_arr[ix] = ub
|
||||
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