added codegen for expression that needs the status-flag register result as a value on the stack

This commit is contained in:
Irmen de Jong 2021-03-24 21:42:27 +01:00
parent 863ec9ce8a
commit 112a7b09f2
2 changed files with 51 additions and 12 deletions

View File

@ -1523,9 +1523,42 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
""")
}
}
}
else if(reg.statusflag!=null) {
TODO("statusflag result onto stack")
} else when(reg.statusflag) {
Statusflag.Pc -> {
asmgen.out("""
lda #0
adc #0
sta P8ESTACK_LO,x
dex""")
}
Statusflag.Pz -> {
asmgen.out("""
beq +
lda #0
beq ++
+ lda #1
+ sta P8ESTACK_LO,x
dex""")
}
Statusflag.Pv -> {
asmgen.out("""
bvs +
lda #0
beq ++
+ lda #1
+ sta P8ESTACK_LO,x
dex""")
}
Statusflag.Pn -> {
asmgen.out("""
bmi +
lda #0
beq ++
+ lda #1
+ sta P8ESTACK_LO,x
dex""")
}
null -> {}
}
}
}

View File

@ -1,20 +1,26 @@
;%target cx16
%import textio
%zeropage basicsafe
main {
sub start() {
txt.print("hello")
ubyte[] array = [1,2,3,4]
ubyte ix
ubyte zero
ubyte one=1
ubyte a = array[1] + array[ix]
a = array[ix] + array[ix]
a = array[ix+1] + array[ix]
uword multiple=0
a = array[lsb(multiple)] + array[ix]
ubyte qq=1
qq = qq + c64.CHKIN(1) * qq
txt.print_ub(qq)
; ubyte[] array = [1,2,3,4]
; ubyte ix
;
; ubyte a = array[1] + array[ix]
; a = array[ix] + array[ix]
; a = array[ix+1] + array[ix]
; uword multiple=0
; a = array[lsb(multiple)] + array[ix]
; str filename = "titlescreen.bin"