mirror of
https://github.com/irmen/prog8.git
synced 2025-02-18 05:30:34 +00:00
fix augassign
This commit is contained in:
parent
4784f1c65a
commit
da57f76de3
@ -190,9 +190,10 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
TODO("use some other evaluation here; there's no evalstack anymore to transfer the address to read/write from")
|
asmgen.assignExpressionTo(memory.address, AsmAssignTarget(TargetStorageKind.REGISTER, asmgen, DataType.UWORD, memory.definingISub(), target.position, register = RegisterOrPair.AY))
|
||||||
// TODO: asmgen.assignExpressionTo(memory.address, AsmAssignTarget(TargetStorageKind.STACK, asmgen, DataType.UWORD, memory.definingISub(), target.position))
|
asmgen.saveRegisterStack(CpuRegister.A, true)
|
||||||
asmgen.out(" jsr prog8_lib.read_byte_from_address_on_stack | sta P8ZP_SCRATCH_B1")
|
asmgen.saveRegisterStack(CpuRegister.Y, false)
|
||||||
|
asmgen.out(" jsr prog8_lib.read_byte_from_address_in_AY | sta P8ZP_SCRATCH_B1")
|
||||||
when(value.kind) {
|
when(value.kind) {
|
||||||
SourceStorageKind.LITERALNUMBER -> inplaceModification_byte_litval_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.number!!.number.toInt())
|
SourceStorageKind.LITERALNUMBER -> inplaceModification_byte_litval_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.number!!.number.toInt())
|
||||||
SourceStorageKind.VARIABLE -> inplaceModification_byte_variable_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.asmVarname)
|
SourceStorageKind.VARIABLE -> inplaceModification_byte_variable_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.asmVarname)
|
||||||
@ -208,7 +209,9 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
}
|
}
|
||||||
else -> throw AssemblyError("weird source type ${value.kind}")
|
else -> throw AssemblyError("weird source type ${value.kind}")
|
||||||
}
|
}
|
||||||
asmgen.out(" lda P8ZP_SCRATCH_B1 | jsr prog8_lib.write_byte_to_address_on_stack | inx")
|
asmgen.restoreRegisterStack(CpuRegister.Y, false)
|
||||||
|
asmgen.restoreRegisterStack(CpuRegister.A, false)
|
||||||
|
asmgen.out(" ldx P8ZP_SCRATCH_B1 | jsr prog8_lib.write_byte_X_to_address_in_AY")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,26 @@
|
|||||||
|
|
||||||
orig_stackpointer .byte 0 ; stores the Stack pointer register at program start
|
orig_stackpointer .byte 0 ; stores the Stack pointer register at program start
|
||||||
|
|
||||||
|
|
||||||
|
read_byte_from_address_in_AY .proc
|
||||||
|
sta P8ZP_SCRATCH_W2
|
||||||
|
sty P8ZP_SCRATCH_W2+1
|
||||||
|
ldy #0
|
||||||
|
lda (P8ZP_SCRATCH_W2),y
|
||||||
|
rts
|
||||||
|
.pend
|
||||||
|
|
||||||
|
|
||||||
|
write_byte_X_to_address_in_AY .proc
|
||||||
|
sta P8ZP_SCRATCH_W2
|
||||||
|
sty P8ZP_SCRATCH_W2+1
|
||||||
|
ldy #0
|
||||||
|
txa
|
||||||
|
sta (P8ZP_SCRATCH_W2),y
|
||||||
|
rts
|
||||||
|
.pend
|
||||||
|
|
||||||
|
|
||||||
reg_less_uw .proc
|
reg_less_uw .proc
|
||||||
; AY < P8ZP_SCRATCH_W2?
|
; AY < P8ZP_SCRATCH_W2?
|
||||||
cpy P8ZP_SCRATCH_W2+1
|
cpy P8ZP_SCRATCH_W2+1
|
||||||
|
@ -11,7 +11,7 @@ import prog8tests.helpers.compileText
|
|||||||
|
|
||||||
class TestAstChecks: FunSpec({
|
class TestAstChecks: FunSpec({
|
||||||
|
|
||||||
test("conditional expression w/float works even without tempvar to split it") {
|
test("conditional expression w/float works") {
|
||||||
val text = """
|
val text = """
|
||||||
%import floats
|
%import floats
|
||||||
main {
|
main {
|
||||||
|
@ -2,7 +2,6 @@ TODO
|
|||||||
====
|
====
|
||||||
|
|
||||||
- (branch): fix optimizeCmpSequence in AsmOptimizer
|
- (branch): fix optimizeCmpSequence in AsmOptimizer
|
||||||
- (branch): fix inplaceModification TODO in AugmentableAssignmentAsmGen
|
|
||||||
- (branch): fix up cx16/keyboardhandler.p8 X register shenanigans
|
- (branch): fix up cx16/keyboardhandler.p8 X register shenanigans
|
||||||
|
|
||||||
- IR: instructions that do type conversion (SZ etc, CONCAT, SGN) should put the result in a DIFFERENT register.
|
- IR: instructions that do type conversion (SZ etc, CONCAT, SGN) should put the result in a DIFFERENT register.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user