mirror of
https://github.com/irmen/prog8.git
synced 2025-02-05 09:33:46 +00:00
asm: also work for asmsub that return N or Z flag (Carry already worked)
This commit is contained in:
parent
796add0ee2
commit
0da9142009
@ -1870,7 +1870,22 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
|||||||
+ lda #1
|
+ lda #1
|
||||||
+""")
|
+""")
|
||||||
}
|
}
|
||||||
else -> throw AssemblyError("can't use Z or N flags as return 'values'")
|
Statusflag.Pz -> {
|
||||||
|
asmgen.out("""
|
||||||
|
beq +
|
||||||
|
lda #0
|
||||||
|
beq ++
|
||||||
|
+ lda #1
|
||||||
|
+""")
|
||||||
|
}
|
||||||
|
Statusflag.Pn -> {
|
||||||
|
asmgen.out("""
|
||||||
|
bmi +
|
||||||
|
lda #0
|
||||||
|
beq ++
|
||||||
|
+ lda #1
|
||||||
|
+""")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assignRegisterByte(target, CpuRegister.A, false, true)
|
assignRegisterByte(target, CpuRegister.A, false, true)
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ TODO
|
|||||||
====
|
====
|
||||||
|
|
||||||
- optimize if-else expressions whose condition returns the boolean status in a status register to use a branch opcode instead of a comparison against 0
|
- optimize if-else expressions whose condition returns the boolean status in a status register to use a branch opcode instead of a comparison against 0
|
||||||
- fix "can't use Z or N flags as return 'values'" in 6502 codegen?
|
|
||||||
|
|
||||||
- merge branch optimize-st for some optimizations regardign SymbolTable use
|
- merge branch optimize-st for some optimizations regardign SymbolTable use
|
||||||
|
|
||||||
@ -12,6 +11,8 @@ TODO
|
|||||||
|
|
||||||
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
- [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 ....
|
||||||
|
|
||||||
|
- IR (expericodegen): fix code for calling routines that return a boolean in a status register such as Carry flag, it has to store the flag value somewhere
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,24 +1,42 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import math
|
%import string
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
ubyte x,y,z = math.rnd()
|
bool @shared blerp = test(100)
|
||||||
|
|
||||||
txt.print_ub(x)
|
if test(100)
|
||||||
txt.nl()
|
goto skip
|
||||||
txt.print_ub(y)
|
txt.print("no0")
|
||||||
txt.nl()
|
|
||||||
txt.print_ub(z)
|
|
||||||
txt.nl()
|
|
||||||
|
|
||||||
x=y=z=math.rnd()
|
skip:
|
||||||
txt.print_ub(x)
|
if test(100) {
|
||||||
txt.nl()
|
txt.print("yes1")
|
||||||
txt.print_ub(y)
|
goto skip2
|
||||||
txt.nl()
|
}
|
||||||
txt.print_ub(z)
|
txt.print("no1")
|
||||||
txt.nl()
|
|
||||||
|
skip2:
|
||||||
|
if test(100)
|
||||||
|
txt.print("yes2")
|
||||||
|
else
|
||||||
|
txt.print("no2")
|
||||||
|
|
||||||
|
|
||||||
|
while test(100) {
|
||||||
|
cx16.r0++
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
cx16.r0++
|
||||||
|
} until test(100)
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub test(ubyte value @A) -> bool @Pz {
|
||||||
|
%asm {{
|
||||||
|
lda #0
|
||||||
|
rts
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user