mirror of
https://github.com/irmen/prog8.git
synced 2024-11-22 15:33:02 +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 -> {
|
||||
TODO("use some other evaluation here; there's no evalstack anymore to transfer the address to read/write from")
|
||||
// TODO: asmgen.assignExpressionTo(memory.address, AsmAssignTarget(TargetStorageKind.STACK, asmgen, DataType.UWORD, memory.definingISub(), target.position))
|
||||
asmgen.out(" jsr prog8_lib.read_byte_from_address_on_stack | sta P8ZP_SCRATCH_B1")
|
||||
asmgen.assignExpressionTo(memory.address, AsmAssignTarget(TargetStorageKind.REGISTER, asmgen, DataType.UWORD, memory.definingISub(), target.position, register = RegisterOrPair.AY))
|
||||
asmgen.saveRegisterStack(CpuRegister.A, true)
|
||||
asmgen.saveRegisterStack(CpuRegister.Y, false)
|
||||
asmgen.out(" jsr prog8_lib.read_byte_from_address_in_AY | sta P8ZP_SCRATCH_B1")
|
||||
when(value.kind) {
|
||||
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)
|
||||
@ -208,7 +209,9 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
||||
}
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
; AY < P8ZP_SCRATCH_W2?
|
||||
cpy P8ZP_SCRATCH_W2+1
|
||||
|
@ -11,7 +11,7 @@ import prog8tests.helpers.compileText
|
||||
|
||||
class TestAstChecks: FunSpec({
|
||||
|
||||
test("conditional expression w/float works even without tempvar to split it") {
|
||||
test("conditional expression w/float works") {
|
||||
val text = """
|
||||
%import floats
|
||||
main {
|
||||
|
@ -2,7 +2,6 @@ TODO
|
||||
====
|
||||
|
||||
- (branch): fix optimizeCmpSequence in AsmOptimizer
|
||||
- (branch): fix inplaceModification TODO in AugmentableAssignmentAsmGen
|
||||
- (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.
|
||||
|
Loading…
Reference in New Issue
Block a user