diff --git a/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt b/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt index b8a5872ca..57596958d 100644 --- a/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt +++ b/compiler/src/prog8/compiler/target/cpu6502/codegen/ExpressionsAsmGen.kt @@ -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 -> {} } } } diff --git a/examples/test.p8 b/examples/test.p8 index 872943e95..bb107b980 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -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"