mirror of
https://github.com/irmen/prog8.git
synced 2024-10-17 10:24:55 +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) {
|
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(left)
|
||||||
asmgen.translateExpression(right)
|
asmgen.translateExpression(right)
|
||||||
asmgen.out(" jsr prog8_lib.lesseq_uw | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
|
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) {
|
private fun translateUwordGreater(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||||
if(rightConstVal!=null) {
|
if(rightConstVal!=null) {
|
||||||
if(leftConstVal!=null) {
|
if(leftConstVal!=null) {
|
||||||
if(rightConstVal>=leftConstVal)
|
if(rightConstVal<=leftConstVal)
|
||||||
asmgen.out(" jmp $jumpIfFalseLabel")
|
asmgen.out(" jmp $jumpIfFalseLabel")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@ -403,10 +430,8 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
else
|
else
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
lda $name
|
lda $name
|
||||||
bne +
|
ora $name+1
|
||||||
lda $name+1
|
beq $jumpIfFalseLabel""")
|
||||||
beq $jumpIfFalseLabel
|
|
||||||
+""")
|
|
||||||
return
|
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) {
|
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(left)
|
||||||
asmgen.translateExpression(right)
|
asmgen.translateExpression(right)
|
||||||
asmgen.out(" jsr prog8_lib.greatereq_ub | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
|
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) {
|
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(left)
|
||||||
asmgen.translateExpression(right)
|
asmgen.translateExpression(right)
|
||||||
asmgen.out(" jsr prog8_lib.greatereq_uw | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
|
asmgen.out(" jsr prog8_lib.greatereq_uw | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
|
||||||
|
@ -370,6 +370,11 @@ main {
|
|||||||
} else {
|
} else {
|
||||||
txt.print("fail < eb6\n")
|
txt.print("fail < eb6\n")
|
||||||
}
|
}
|
||||||
|
if b2 < 0 {
|
||||||
|
txt.print("ok < eb7\n")
|
||||||
|
} else {
|
||||||
|
txt.print("fail < eb7\n")
|
||||||
|
}
|
||||||
|
|
||||||
if w2 < -32768 {
|
if w2 < -32768 {
|
||||||
txt.print("fail < ew1\n")
|
txt.print("fail < ew1\n")
|
||||||
@ -401,6 +406,11 @@ main {
|
|||||||
} else {
|
} else {
|
||||||
txt.print("fail < ew6\n")
|
txt.print("fail < ew6\n")
|
||||||
}
|
}
|
||||||
|
if w2 < 0 {
|
||||||
|
txt.print("ok < ew7\n")
|
||||||
|
} else {
|
||||||
|
txt.print("fail < ew7\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub greater() {
|
sub greater() {
|
||||||
@ -557,6 +567,11 @@ main {
|
|||||||
} else {
|
} else {
|
||||||
txt.print("ok > eb6\n")
|
txt.print("ok > eb6\n")
|
||||||
}
|
}
|
||||||
|
if b2 > 0 {
|
||||||
|
txt.print("fail > eb7\n")
|
||||||
|
} else {
|
||||||
|
txt.print("ok > eb7\n")
|
||||||
|
}
|
||||||
|
|
||||||
if w2 > -32768 {
|
if w2 > -32768 {
|
||||||
txt.print("ok > ew1\n")
|
txt.print("ok > ew1\n")
|
||||||
@ -588,6 +603,11 @@ main {
|
|||||||
} else {
|
} else {
|
||||||
txt.print("ok > ew6\n")
|
txt.print("ok > ew6\n")
|
||||||
}
|
}
|
||||||
|
if w2 > 0 {
|
||||||
|
txt.print("fail > ew6\n")
|
||||||
|
} else {
|
||||||
|
txt.print("ok > ew6\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub lessequal() {
|
sub lessequal() {
|
||||||
@ -745,6 +765,11 @@ main {
|
|||||||
} else {
|
} else {
|
||||||
txt.print("fail <= eb6\n")
|
txt.print("fail <= eb6\n")
|
||||||
}
|
}
|
||||||
|
if b2 <= 0 {
|
||||||
|
txt.print("ok <= eb7\n")
|
||||||
|
} else {
|
||||||
|
txt.print("fail <= eb7\n")
|
||||||
|
}
|
||||||
|
|
||||||
if w2 <= -32768 {
|
if w2 <= -32768 {
|
||||||
txt.print("fail <= ew1\n")
|
txt.print("fail <= ew1\n")
|
||||||
@ -776,6 +801,11 @@ main {
|
|||||||
} else {
|
} else {
|
||||||
txt.print("fail <= ew6\n")
|
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 {
|
} else {
|
||||||
txt.print("ok >= eb6\n")
|
txt.print("ok >= eb6\n")
|
||||||
}
|
}
|
||||||
|
if b2 >= 0 {
|
||||||
|
txt.print("fail >= eb7\n")
|
||||||
|
} else {
|
||||||
|
txt.print("ok >= eb7\n")
|
||||||
|
}
|
||||||
|
|
||||||
if w2 >= -32768 {
|
if w2 >= -32768 {
|
||||||
txt.print("ok >= ew1\n")
|
txt.print("ok >= ew1\n")
|
||||||
@ -964,5 +999,10 @@ main {
|
|||||||
} else {
|
} else {
|
||||||
txt.print("ok >= ew6\n")
|
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
|
ubyte @zp y = cos8u(angle*3-spri*16) / 2 + 70
|
||||||
c64.SPXYW[spri] = mkword(y, lsb(x))
|
c64.SPXYW[spri] = mkword(y, lsb(x))
|
||||||
c64.MSIGX <<= 1
|
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
|
c64.EXTCOL-=8
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user