fix wordvar -= @(memory)

This commit is contained in:
Irmen de Jong 2023-09-03 01:12:26 +02:00
parent 95be1c9e22
commit e1b3582f08
2 changed files with 17 additions and 17 deletions

View File

@ -892,7 +892,7 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
// now implement the non-assiciative operators...
when (operator) {
"-" -> {
// TODO optimize: don't use scratch var
// A = variable - A
val tmpVar = if(variable!="P8ZP_SCRATCH_B1") "P8ZP_SCRATCH_B1" else "P8ZP_SCRATCH_REG"
asmgen.out(" sta $tmpVar | lda $variable | sec | sbc $tmpVar")
}
@ -1240,8 +1240,8 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
+""")
}
"-" -> {
// name -= @(memory)
asmgen.translateDirectMemReadExpressionToRegA(memread)
// TODO optimize: don't use scratch var if possible
val tmpByte = if(name!="P8ZP_SCRATCH_B1") "P8ZP_SCRATCH_B1" else "P8ZP_SCRATCH_REG"
asmgen.out("""
sta $tmpByte
@ -1249,7 +1249,7 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
sec
sbc $tmpByte
sta $name
bcc +
bcs +
dec $name+1
+""")
}

View File

@ -3,25 +3,25 @@
main {
sub start() {
byte index = 100
byte[] t_index = [-1,-2,-3,-4,-5]
index = 4
index = index>t_index[4]
txt.print_b(index)
txt.nl()
index = index>t_index[4]
txt.print_b(index)
txt.nl()
uword ww= 300
@($4000) = 100
ww -= @($4000)
ww -= 100
txt.print_uw(ww) ; 100
; index = index < t_index[4]
; index = index < t_index[nibble]
; txt.print_ub(index)
; ubyte index = 100
; ubyte[] t_index = [1,2,3,4,5]
; ubyte nibble = 0
;
; index = index + t_index[4]
; index = index + t_index[nibble]
; txt.print_ub(index) ; 106
; txt.nl()
;
; nibble++
; index = index > t_index[3]
; index = index > t_index[nibble]
; index = index - t_index[3]
; index = index - t_index[nibble]
; txt.print_ub(index) ; 100
; txt.nl()
}