mirror of
https://github.com/irmen/prog8.git
synced 2025-01-29 09:31:23 +00:00
all unsigned comparisons
This commit is contained in:
parent
66364554c4
commit
4179b4e543
@ -325,7 +325,34 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
||||
}
|
||||
|
||||
private fun translateUwordLessOrEqual(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||
// TODO compare with optimized asm
|
||||
if(rightConstVal!=null) {
|
||||
if(leftConstVal!=null) {
|
||||
if(rightConstVal>leftConstVal)
|
||||
asmgen.out(" jmp $jumpIfFalseLabel")
|
||||
return
|
||||
} else {
|
||||
if (left is IdentifierReference) {
|
||||
val name = asmgen.asmVariableName(left)
|
||||
if(rightConstVal.number.toInt()!=0)
|
||||
asmgen.out("""
|
||||
lda #>${rightConstVal.number}
|
||||
cmp $name+1
|
||||
bcc $jumpIfFalseLabel
|
||||
bne +
|
||||
lda #<${rightConstVal.number}
|
||||
cmp $name
|
||||
bcc $jumpIfFalseLabel
|
||||
+""")
|
||||
else
|
||||
asmgen.out("""
|
||||
lda $name
|
||||
ora $name+1
|
||||
bne $jumpIfFalseLabel""")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asmgen.translateExpression(left)
|
||||
asmgen.translateExpression(right)
|
||||
asmgen.out(" jsr prog8_lib.lesseq_uw | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
|
||||
@ -383,7 +410,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
||||
private fun translateUwordGreater(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||
if(rightConstVal!=null) {
|
||||
if(leftConstVal!=null) {
|
||||
if(rightConstVal>=leftConstVal)
|
||||
if(rightConstVal<=leftConstVal)
|
||||
asmgen.out(" jmp $jumpIfFalseLabel")
|
||||
return
|
||||
} else {
|
||||
@ -403,10 +430,8 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
||||
else
|
||||
asmgen.out("""
|
||||
lda $name
|
||||
bne +
|
||||
lda $name+1
|
||||
beq $jumpIfFalseLabel
|
||||
+""")
|
||||
ora $name+1
|
||||
beq $jumpIfFalseLabel""")
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -425,7 +450,30 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
||||
}
|
||||
|
||||
private fun translateUbyteGreaterOrEqual(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||
// TODO compare with optimized asm
|
||||
if(rightConstVal!=null) {
|
||||
if(leftConstVal!=null) {
|
||||
if(rightConstVal<leftConstVal)
|
||||
asmgen.out(" jmp $jumpIfFalseLabel")
|
||||
return
|
||||
} else {
|
||||
if (left is IdentifierReference) {
|
||||
val name = asmgen.asmVariableName(left)
|
||||
if(rightConstVal.number.toInt()!=0)
|
||||
asmgen.out("""
|
||||
lda $name
|
||||
cmp #${rightConstVal.number}
|
||||
bcc $jumpIfFalseLabel""")
|
||||
return
|
||||
}
|
||||
else if (left is DirectMemoryRead) {
|
||||
translateDirectMemReadExpression(left, false)
|
||||
if(rightConstVal.number.toInt()!=0)
|
||||
asmgen.out(" cmp #${rightConstVal.number} | bcc $jumpIfFalseLabel")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asmgen.translateExpression(left)
|
||||
asmgen.translateExpression(right)
|
||||
asmgen.out(" jsr prog8_lib.greatereq_ub | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
|
||||
@ -439,7 +487,29 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
||||
}
|
||||
|
||||
private fun translateUwordGreaterOrEqual(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||
// TODO compare with optimized asm
|
||||
if(rightConstVal!=null) {
|
||||
if(leftConstVal!=null) {
|
||||
if(rightConstVal<leftConstVal)
|
||||
asmgen.out(" jmp $jumpIfFalseLabel")
|
||||
return
|
||||
} else {
|
||||
if (left is IdentifierReference) {
|
||||
val name = asmgen.asmVariableName(left)
|
||||
if(rightConstVal.number.toInt()!=0)
|
||||
asmgen.out("""
|
||||
lda $name+1
|
||||
cmp #>${rightConstVal.number}
|
||||
bcc $jumpIfFalseLabel
|
||||
bne +
|
||||
lda $name
|
||||
cmp #<${rightConstVal.number}
|
||||
bcc $jumpIfFalseLabel
|
||||
+""")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asmgen.translateExpression(left)
|
||||
asmgen.translateExpression(right)
|
||||
asmgen.out(" jsr prog8_lib.greatereq_uw | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
|
||||
|
@ -370,6 +370,11 @@ main {
|
||||
} else {
|
||||
txt.print("fail < eb6\n")
|
||||
}
|
||||
if b2 < 0 {
|
||||
txt.print("ok < eb7\n")
|
||||
} else {
|
||||
txt.print("fail < eb7\n")
|
||||
}
|
||||
|
||||
if w2 < -32768 {
|
||||
txt.print("fail < ew1\n")
|
||||
@ -401,6 +406,11 @@ main {
|
||||
} else {
|
||||
txt.print("fail < ew6\n")
|
||||
}
|
||||
if w2 < 0 {
|
||||
txt.print("ok < ew7\n")
|
||||
} else {
|
||||
txt.print("fail < ew7\n")
|
||||
}
|
||||
}
|
||||
|
||||
sub greater() {
|
||||
@ -557,6 +567,11 @@ main {
|
||||
} else {
|
||||
txt.print("ok > eb6\n")
|
||||
}
|
||||
if b2 > 0 {
|
||||
txt.print("fail > eb7\n")
|
||||
} else {
|
||||
txt.print("ok > eb7\n")
|
||||
}
|
||||
|
||||
if w2 > -32768 {
|
||||
txt.print("ok > ew1\n")
|
||||
@ -588,6 +603,11 @@ main {
|
||||
} else {
|
||||
txt.print("ok > ew6\n")
|
||||
}
|
||||
if w2 > 0 {
|
||||
txt.print("fail > ew6\n")
|
||||
} else {
|
||||
txt.print("ok > ew6\n")
|
||||
}
|
||||
}
|
||||
|
||||
sub lessequal() {
|
||||
@ -745,6 +765,11 @@ main {
|
||||
} else {
|
||||
txt.print("fail <= eb6\n")
|
||||
}
|
||||
if b2 <= 0 {
|
||||
txt.print("ok <= eb7\n")
|
||||
} else {
|
||||
txt.print("fail <= eb7\n")
|
||||
}
|
||||
|
||||
if w2 <= -32768 {
|
||||
txt.print("fail <= ew1\n")
|
||||
@ -776,6 +801,11 @@ main {
|
||||
} else {
|
||||
txt.print("fail <= ew6\n")
|
||||
}
|
||||
if w2 <= 0 {
|
||||
txt.print("ok <= ew7\n")
|
||||
} else {
|
||||
txt.print("fail <= ew7\n")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -933,6 +963,11 @@ main {
|
||||
} else {
|
||||
txt.print("ok >= eb6\n")
|
||||
}
|
||||
if b2 >= 0 {
|
||||
txt.print("fail >= eb7\n")
|
||||
} else {
|
||||
txt.print("ok >= eb7\n")
|
||||
}
|
||||
|
||||
if w2 >= -32768 {
|
||||
txt.print("ok >= ew1\n")
|
||||
@ -964,5 +999,10 @@ main {
|
||||
} else {
|
||||
txt.print("ok >= ew6\n")
|
||||
}
|
||||
if w2 >= 0 {
|
||||
txt.print("fail >= ew7\n")
|
||||
} else {
|
||||
txt.print("ok >= ew7\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ irq {
|
||||
ubyte @zp y = cos8u(angle*3-spri*16) / 2 + 70
|
||||
c64.SPXYW[spri] = mkword(y, lsb(x))
|
||||
c64.MSIGX <<= 1
|
||||
if msb(x) c64.MSIGX++
|
||||
if msb(x) c64.MSIGX++ ; TODO has this become badly translated to asm?? it makes the loop quite slow
|
||||
}
|
||||
c64.EXTCOL-=8
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user