mirror of
https://github.com/irmen/prog8.git
synced 2025-01-13 10:29:52 +00:00
wip
This commit is contained in:
parent
6780d4f562
commit
330e691b78
@ -501,7 +501,6 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun translateWordLessJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
private fun translateWordLessJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||||
// TODO 100% checked ok.
|
|
||||||
|
|
||||||
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
@ -667,7 +666,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun translateWordGreaterJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
private fun translateWordGreaterJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||||
// TODO 100% checked ok.
|
|
||||||
fun code(leftName: String) {
|
fun code(leftName: String) {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
cmp $leftName
|
cmp $leftName
|
||||||
@ -791,6 +790,8 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
|
|
||||||
private fun translateUwordLessOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
private fun translateUwordLessOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||||
|
|
||||||
|
// TODO fix this uword <=
|
||||||
|
|
||||||
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
cpy $msbCpyOperand
|
cpy $msbCpyOperand
|
||||||
@ -809,7 +810,6 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
} else {
|
} else {
|
||||||
if (left is IdentifierReference) {
|
if (left is IdentifierReference) {
|
||||||
return if(rightConstVal.number.toInt()!=0) {
|
return if(rightConstVal.number.toInt()!=0) {
|
||||||
// TODO is this correct? uword <= not-null
|
|
||||||
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
||||||
code("#>${rightConstVal.number}", "#<${rightConstVal.number}")
|
code("#>${rightConstVal.number}", "#<${rightConstVal.number}")
|
||||||
}
|
}
|
||||||
@ -825,7 +825,6 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(right is IdentifierReference) {
|
if(right is IdentifierReference) {
|
||||||
// TODO is this correct? uword <= variable
|
|
||||||
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
||||||
val varname = asmgen.asmVariableName(right)
|
val varname = asmgen.asmVariableName(right)
|
||||||
return code("$varname+1", varname)
|
return code("$varname+1", varname)
|
||||||
@ -838,6 +837,8 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
|
|
||||||
private fun translateWordLessOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
private fun translateWordLessOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||||
|
|
||||||
|
// TODO fix this word <=
|
||||||
|
|
||||||
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
cmp $msbCpyOperand
|
cmp $msbCpyOperand
|
||||||
@ -857,27 +858,24 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
} else {
|
} else {
|
||||||
if (left is IdentifierReference) {
|
if (left is IdentifierReference) {
|
||||||
return if(rightConstVal.number.toInt()!=0) {
|
return if(rightConstVal.number.toInt()!=0) {
|
||||||
// TODO is this correct? word <= not-null
|
|
||||||
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
||||||
code("#>${rightConstVal.number}", "#<${rightConstVal.number}")
|
code("#>${rightConstVal.number}", "#<${rightConstVal.number}")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// TODO is this correct? word <= 0 (can be shorter?)
|
|
||||||
val name = asmgen.asmVariableName(left)
|
val name = asmgen.asmVariableName(left)
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
lda #0
|
lda $name+1
|
||||||
cmp $name
|
bmi +
|
||||||
sbc $name+1
|
bne $jumpIfFalseLabel
|
||||||
bvc +
|
lda $name
|
||||||
eor #$80
|
bne $jumpIfFalseLabel
|
||||||
+ bmi $jumpIfFalseLabel""")
|
+""")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(right is IdentifierReference) {
|
if(right is IdentifierReference) {
|
||||||
// TODO is this correct? word <= variable
|
|
||||||
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
||||||
val varname = asmgen.asmVariableName(right)
|
val varname = asmgen.asmVariableName(right)
|
||||||
return code("$varname+1", varname)
|
return code("$varname+1", varname)
|
||||||
@ -961,6 +959,8 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
|
|
||||||
private fun translateUwordGreaterOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
private fun translateUwordGreaterOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||||
|
|
||||||
|
// TODO fix this uword >=
|
||||||
|
|
||||||
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
cpy $msbCpyOperand
|
cpy $msbCpyOperand
|
||||||
@ -979,7 +979,6 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
} else {
|
} else {
|
||||||
if (left is IdentifierReference) {
|
if (left is IdentifierReference) {
|
||||||
if(rightConstVal.number.toInt()!=0) {
|
if(rightConstVal.number.toInt()!=0) {
|
||||||
// TODO is this correct? uword >= not-0
|
|
||||||
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
||||||
code("#>${rightConstVal.number}", "#<${rightConstVal.number}")
|
code("#>${rightConstVal.number}", "#<${rightConstVal.number}")
|
||||||
}
|
}
|
||||||
@ -988,7 +987,6 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(right is IdentifierReference) {
|
if(right is IdentifierReference) {
|
||||||
// TODO is this correct? uword >= variable
|
|
||||||
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
||||||
val varname = asmgen.asmVariableName(right)
|
val varname = asmgen.asmVariableName(right)
|
||||||
return code("$varname+1", varname)
|
return code("$varname+1", varname)
|
||||||
@ -1001,6 +999,8 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
|
|
||||||
private fun translateWordGreaterOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
private fun translateWordGreaterOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
|
||||||
|
|
||||||
|
// TODO fix this word >=
|
||||||
|
|
||||||
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
fun code(msbCpyOperand: String, lsbCmpOperand: String) {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
cmp $lsbCmpOperand
|
cmp $lsbCmpOperand
|
||||||
@ -1019,7 +1019,6 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
} else {
|
} else {
|
||||||
if (left is IdentifierReference) {
|
if (left is IdentifierReference) {
|
||||||
return if(rightConstVal.number.toInt()!=0) {
|
return if(rightConstVal.number.toInt()!=0) {
|
||||||
// TODO is this correct? word >= not-0
|
|
||||||
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
||||||
code("#>${rightConstVal.number}", "#<${rightConstVal.number}")
|
code("#>${rightConstVal.number}", "#<${rightConstVal.number}")
|
||||||
}
|
}
|
||||||
@ -1032,7 +1031,6 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(right is IdentifierReference) {
|
if(right is IdentifierReference) {
|
||||||
// TODO is this correct? word >= variable
|
|
||||||
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
asmgen.assignExpressionToRegister(left, RegisterOrPair.AY)
|
||||||
val varname = asmgen.asmVariableName(right)
|
val varname = asmgen.asmVariableName(right)
|
||||||
return code("$varname+1", varname)
|
return code("$varname+1", varname)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user