mirror of
https://github.com/irmen/prog8.git
synced 2024-11-19 11:32:17 +00:00
use less tempvars
This commit is contained in:
parent
e1b3582f08
commit
10d0b03a90
@ -2172,23 +2172,21 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
||||
// the other variable is a BYTE type so optimize for that
|
||||
when (operator) {
|
||||
"+" -> {
|
||||
// name += byteexpression
|
||||
if(valueDt==DataType.UBYTE) {
|
||||
// TODO optimize: don't use scratch var
|
||||
asmgen.assignExpressionToVariable(value, "P8ZP_SCRATCH_B1", valueDt)
|
||||
asmgen.assignExpressionToRegister(value, RegisterOrPair.A, false)
|
||||
asmgen.out("""
|
||||
lda $name
|
||||
clc
|
||||
adc P8ZP_SCRATCH_B1
|
||||
adc $name
|
||||
sta $name
|
||||
bcc +
|
||||
inc $name+1
|
||||
+""")
|
||||
} else {
|
||||
// TODO optimize: don't use scratch var
|
||||
asmgen.assignExpressionToVariable(value, "P8ZP_SCRATCH_B1", valueDt)
|
||||
asmgen.assignExpressionToRegister(value, RegisterOrPair.A, true)
|
||||
asmgen.out("""
|
||||
ldy #0
|
||||
lda P8ZP_SCRATCH_B1
|
||||
cmp #0
|
||||
bpl +
|
||||
dey ; sign extend
|
||||
+ clc
|
||||
@ -2200,7 +2198,7 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
||||
}
|
||||
}
|
||||
"-" -> {
|
||||
// TODO optimize: don't use scratch var
|
||||
// name -= byteexpression
|
||||
asmgen.assignExpressionToVariable(value, "P8ZP_SCRATCH_B1", valueDt)
|
||||
if(valueDt==DataType.UBYTE)
|
||||
asmgen.out("""
|
||||
|
@ -3,7 +3,6 @@ TODO
|
||||
- fix on c64 target: examples/cube3d-float (broken since 9.3 with the evalstack removal) it works on x16 target, oddly enough.
|
||||
More detailed and simpler code for this problem in floatproblem64.p8 / floatproblem64.asm (the minified version)
|
||||
|
||||
- optimize: search for TODO optimize: don't use scratch var
|
||||
- prefix prog8 subroutines with p8s_ instead of p8_ to not let them clash with variables in the asm?
|
||||
- allow 'chained' array indexing for expressions: value = ptrarray[0][0]
|
||||
- allow 'chained' array indexing for assign targets: ptrarray[0][0] = 42 this is just evaluating the lhs as a uword pointer expression
|
||||
|
@ -4,11 +4,10 @@
|
||||
main {
|
||||
sub start() {
|
||||
|
||||
uword ww= 300
|
||||
@($4000) = 100
|
||||
ww -= @($4000)
|
||||
ww -= 100
|
||||
txt.print_uw(ww) ; 100
|
||||
byte bb = 20
|
||||
word ww= 300
|
||||
ww += bb*3
|
||||
txt.print_w(ww) ; 240
|
||||
|
||||
; ubyte index = 100
|
||||
; ubyte[] t_index = [1,2,3,4,5]
|
||||
|
Loading…
Reference in New Issue
Block a user