mirror of
https://github.com/irmen/prog8.git
synced 2025-02-16 22:30:46 +00:00
optimized byte comparison expressions
This commit is contained in:
parent
533d825f1a
commit
ffb54110e9
@ -728,7 +728,16 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
||||
"<" -> {
|
||||
assignExpressionOperandsLeftScratchRightA()
|
||||
if(signed)
|
||||
return false // TODO("< signed")
|
||||
asmgen.out("""
|
||||
clc
|
||||
sbc P8ZP_SCRATCH_B1
|
||||
bvc +
|
||||
eor #$80
|
||||
+ bpl +
|
||||
lda #0
|
||||
beq ++
|
||||
+ lda #1
|
||||
+""")
|
||||
else
|
||||
asmgen.out("""
|
||||
cmp P8ZP_SCRATCH_B1
|
||||
@ -742,7 +751,16 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
||||
"<=" -> {
|
||||
assignExpressionOperandsLeftScratchRightA()
|
||||
if(signed)
|
||||
return false // TODO("< signed")
|
||||
asmgen.out("""
|
||||
sec
|
||||
sbc P8ZP_SCRATCH_B1
|
||||
bvc +
|
||||
eor #$80
|
||||
+ bpl +
|
||||
lda #0
|
||||
beq ++
|
||||
+ lda #1
|
||||
+""")
|
||||
else
|
||||
asmgen.out("""
|
||||
cmp P8ZP_SCRATCH_B1
|
||||
@ -752,7 +770,16 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
||||
">" -> {
|
||||
assignExpressionOperandsLeftScratchRightA()
|
||||
if(signed)
|
||||
return false // TODO("< signed")
|
||||
asmgen.out("""
|
||||
sec
|
||||
sbc P8ZP_SCRATCH_B1
|
||||
bvc +
|
||||
eor #$80
|
||||
+ bmi +
|
||||
lda #0
|
||||
beq ++
|
||||
+ lda #1
|
||||
+""")
|
||||
else
|
||||
asmgen.out("""
|
||||
cmp P8ZP_SCRATCH_B1
|
||||
@ -765,7 +792,16 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
||||
">=" -> {
|
||||
assignExpressionOperandsLeftScratchRightA()
|
||||
if(signed)
|
||||
return false // TODO(">= signed")
|
||||
asmgen.out("""
|
||||
clc
|
||||
sbc P8ZP_SCRATCH_B1
|
||||
bvc +
|
||||
eor #$80
|
||||
+ bmi +
|
||||
lda #0
|
||||
beq ++
|
||||
+ lda #1
|
||||
+""")
|
||||
else
|
||||
asmgen.out("""
|
||||
cmp P8ZP_SCRATCH_B1
|
||||
|
@ -4,16 +4,58 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
txt.print("hello")
|
||||
; foobar()
|
||||
}
|
||||
ubyte[10] envelope_attacks = 99
|
||||
|
||||
asmsub foobar() {
|
||||
%asm {{
|
||||
nop
|
||||
rts
|
||||
|
||||
}}
|
||||
; signed and unsigned word:
|
||||
; ==
|
||||
; !=
|
||||
; >
|
||||
; >=
|
||||
; <
|
||||
; <=
|
||||
|
||||
|
||||
; expect yep yep nope nope nope
|
||||
cx16.r0sL = -10
|
||||
cx16.r2sL = -9
|
||||
if (cx16.r0sL <= cx16.r2sL) or (envelope_attacks[cx16.r1L]==0) {
|
||||
txt.print("\nyep\n")
|
||||
} else {
|
||||
txt.print("\nnope\n")
|
||||
}
|
||||
|
||||
cx16.r0sL = -9
|
||||
cx16.r2sL = -9
|
||||
if (cx16.r0sL <= cx16.r2sL) or (envelope_attacks[cx16.r1L]==0) {
|
||||
txt.print("\nyep\n")
|
||||
} else {
|
||||
txt.print("\nnope\n")
|
||||
}
|
||||
|
||||
cx16.r0sL = -8
|
||||
cx16.r2sL = -9
|
||||
if (cx16.r0sL <= cx16.r2sL) or (envelope_attacks[cx16.r1L]==0) {
|
||||
txt.print("\nyep\n")
|
||||
} else {
|
||||
txt.print("\nnope\n")
|
||||
}
|
||||
|
||||
cx16.r0sL = 0
|
||||
cx16.r2sL = -9
|
||||
if (cx16.r0sL <= cx16.r2sL) or (envelope_attacks[cx16.r1L]==0) {
|
||||
txt.print("\nyep\n")
|
||||
} else {
|
||||
txt.print("\nnope\n")
|
||||
}
|
||||
|
||||
cx16.r0sL = 10
|
||||
cx16.r2sL = 1
|
||||
if (cx16.r0sL <= cx16.r2sL) or (envelope_attacks[cx16.r1L]==0) {
|
||||
txt.print("\nyep\n")
|
||||
} else {
|
||||
txt.print("\nnope\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user