mirror of
https://github.com/irmen/prog8.git
synced 2025-08-16 05:27:31 +00:00
fixed optimized code for >= and <=
This commit is contained in:
@@ -1157,6 +1157,82 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun byteLessEquals(expr: PtBinaryExpression, signed: Boolean) {
|
private fun byteLessEquals(expr: PtBinaryExpression, signed: Boolean) {
|
||||||
|
// note: this is the inverse of byteGreater
|
||||||
|
when(expr.right) {
|
||||||
|
is PtNumber -> {
|
||||||
|
val number = (expr.right as PtNumber).number.toInt()
|
||||||
|
asmgen.assignExpressionToRegister(expr.left, RegisterOrPair.A, signed)
|
||||||
|
if(signed)
|
||||||
|
asmgen.out("""
|
||||||
|
sec
|
||||||
|
sbc #$number
|
||||||
|
bvc +
|
||||||
|
eor #$80
|
||||||
|
+ bmi +
|
||||||
|
beq +
|
||||||
|
lda #0
|
||||||
|
beq ++
|
||||||
|
+ lda #1
|
||||||
|
+""")
|
||||||
|
else
|
||||||
|
asmgen.out("""
|
||||||
|
cmp #$number
|
||||||
|
bcc +
|
||||||
|
beq +
|
||||||
|
lda #0
|
||||||
|
beq ++
|
||||||
|
+ lda #1
|
||||||
|
+""")
|
||||||
|
}
|
||||||
|
is PtIdentifier -> {
|
||||||
|
val varname = (expr.right as PtIdentifier).name
|
||||||
|
asmgen.assignExpressionToRegister(expr.left, RegisterOrPair.A, signed)
|
||||||
|
if(signed)
|
||||||
|
asmgen.out("""
|
||||||
|
sec
|
||||||
|
sbc $varname
|
||||||
|
bvc +
|
||||||
|
eor #$80
|
||||||
|
+ bmi +
|
||||||
|
beq +
|
||||||
|
lda #0
|
||||||
|
beq ++
|
||||||
|
+ lda #1
|
||||||
|
+""")
|
||||||
|
else
|
||||||
|
asmgen.out("""
|
||||||
|
cmp $varname
|
||||||
|
bcc +
|
||||||
|
beq +
|
||||||
|
lda #0
|
||||||
|
beq ++
|
||||||
|
+ lda #1
|
||||||
|
+""")
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
// note: left and right operands get reversed here to reduce code size
|
||||||
|
asmgen.assignByteOperandsToAAndVar(expr.right, expr.left, "P8ZP_SCRATCH_B1")
|
||||||
|
if(signed)
|
||||||
|
asmgen.out("""
|
||||||
|
sec
|
||||||
|
sbc P8ZP_SCRATCH_B1
|
||||||
|
bvc +
|
||||||
|
eor #$80
|
||||||
|
+ bmi +
|
||||||
|
lda #1
|
||||||
|
bne ++
|
||||||
|
+ lda #0
|
||||||
|
+""")
|
||||||
|
else
|
||||||
|
asmgen.out("""
|
||||||
|
cmp P8ZP_SCRATCH_B1
|
||||||
|
lda #0
|
||||||
|
rol a""")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun byteLessEqualsWRONG(expr: PtBinaryExpression, signed: Boolean) {
|
||||||
// note: this is the inverse of byteGreater
|
// note: this is the inverse of byteGreater
|
||||||
when(expr.right) {
|
when(expr.right) {
|
||||||
is PtNumber -> {
|
is PtNumber -> {
|
||||||
@@ -1305,11 +1381,11 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checked OK:
|
||||||
private fun byteGreaterEquals(expr: PtBinaryExpression, signed: Boolean) {
|
private fun byteGreaterEquals(expr: PtBinaryExpression, signed: Boolean) {
|
||||||
// note: this is the inverse of byteLess
|
// note: this is the inverse of byteLess
|
||||||
when(expr.right) {
|
when(expr.right) {
|
||||||
is PtNumber -> {
|
is PtNumber -> {
|
||||||
// TODO verify if this is correct code on all corner cases
|
|
||||||
val number = (expr.right as PtNumber).number.toInt()
|
val number = (expr.right as PtNumber).number.toInt()
|
||||||
asmgen.assignExpressionToRegister(expr.left, RegisterOrPair.A, signed)
|
asmgen.assignExpressionToRegister(expr.left, RegisterOrPair.A, signed)
|
||||||
if(signed) {
|
if(signed) {
|
||||||
@@ -1329,7 +1405,6 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
|||||||
and #1""")
|
and #1""")
|
||||||
}
|
}
|
||||||
is PtIdentifier -> {
|
is PtIdentifier -> {
|
||||||
// TODO verify if this is correct code on all corner cases
|
|
||||||
val varname = (expr.right as PtIdentifier).name
|
val varname = (expr.right as PtIdentifier).name
|
||||||
asmgen.assignExpressionToRegister(expr.left, RegisterOrPair.A, signed)
|
asmgen.assignExpressionToRegister(expr.left, RegisterOrPair.A, signed)
|
||||||
if(signed) {
|
if(signed) {
|
||||||
@@ -1349,7 +1424,6 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
|||||||
and #1""")
|
and #1""")
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// TODO verify if this is correct code on all corner cases
|
|
||||||
// note: left and right operands get reversed here to reduce code size
|
// note: left and right operands get reversed here to reduce code size
|
||||||
asmgen.assignByteOperandsToAAndVar(expr.right, expr.left, "P8ZP_SCRATCH_B1")
|
asmgen.assignByteOperandsToAAndVar(expr.right, expr.left, "P8ZP_SCRATCH_B1")
|
||||||
if(signed)
|
if(signed)
|
||||||
@@ -1365,9 +1439,12 @@ internal class AssignmentAsmGen(private val program: PtProgram,
|
|||||||
else
|
else
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
cmp P8ZP_SCRATCH_B1
|
cmp P8ZP_SCRATCH_B1
|
||||||
rol a
|
bcc +
|
||||||
and #1
|
beq +
|
||||||
eor #1""")
|
lda #0
|
||||||
|
beq ++
|
||||||
|
+ lda #1
|
||||||
|
+""")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ generate:
|
|||||||
p8compile -target cx16 *.p8 >/dev/null
|
p8compile -target cx16 *.p8 >/dev/null
|
||||||
|
|
||||||
test_prgs:
|
test_prgs:
|
||||||
|
x16emu -run -prg optimized_compares.prg
|
||||||
x16emu -run -prg more_compares.prg
|
x16emu -run -prg more_compares.prg
|
||||||
for program in *.prg; do \
|
for program in *.prg; do \
|
||||||
echo "RUNNING:" $$program ; \
|
echo "RUNNING:" $$program ; \
|
||||||
|
339
compiler/test/comparisons/optimized_compares.p8
Normal file
339
compiler/test/comparisons/optimized_compares.p8
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
%import textio
|
||||||
|
%zeropage basicsafe
|
||||||
|
|
||||||
|
main {
|
||||||
|
sub start() {
|
||||||
|
greater()
|
||||||
|
greater_signed()
|
||||||
|
less()
|
||||||
|
less_signed()
|
||||||
|
|
||||||
|
greatereq()
|
||||||
|
greatereq_signed()
|
||||||
|
lesseq()
|
||||||
|
lesseq_signed()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub value(ubyte arg) -> ubyte {
|
||||||
|
cx16.r0++
|
||||||
|
return arg
|
||||||
|
}
|
||||||
|
|
||||||
|
sub svalue(byte arg) -> byte {
|
||||||
|
cx16.r0++
|
||||||
|
return arg
|
||||||
|
}
|
||||||
|
|
||||||
|
sub greater () {
|
||||||
|
ubyte b1 = 10
|
||||||
|
ubyte b2 = 20
|
||||||
|
ubyte b3 = 10
|
||||||
|
|
||||||
|
txt.print(">(u): 101010: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2>10
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b3>b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>value(10)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b3>value(20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub greater_signed () {
|
||||||
|
byte b1 = -20
|
||||||
|
byte b2 = -10
|
||||||
|
byte b3 = -20
|
||||||
|
|
||||||
|
txt.print(">(s): 101010: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2 > -20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2 > -10
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b3>b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>svalue(-20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b3>svalue(-10)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub less () {
|
||||||
|
ubyte b1 = 20
|
||||||
|
ubyte b2 = 10
|
||||||
|
ubyte b3 = 20
|
||||||
|
|
||||||
|
txt.print("<(u): 101010: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2<20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<10
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b3<b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<value(20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2<value(10)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub less_signed () {
|
||||||
|
byte b1 = -10
|
||||||
|
byte b2 = -20
|
||||||
|
byte b3 = -10
|
||||||
|
|
||||||
|
txt.print("<(s): 101010: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2 < -10
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2 < -20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b3<b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<svalue(-10)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b3<svalue(-20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub greatereq () {
|
||||||
|
ubyte b1 = 19
|
||||||
|
ubyte b2 = 20
|
||||||
|
ubyte b3 = 21
|
||||||
|
ubyte b4 = 20
|
||||||
|
|
||||||
|
txt.print(">=(u): 110110110: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2>=19
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=21
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b4
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b3
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=value(19)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2>=value(20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2>=value(21)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub greatereq_signed () {
|
||||||
|
byte b1 = -19
|
||||||
|
byte b2 = -20
|
||||||
|
byte b3 = -21
|
||||||
|
byte b4 = -20
|
||||||
|
|
||||||
|
txt.print(">=(s): 011011011: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2>= -19
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>= -20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>= -21
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b4
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b3
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=value(-19)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2>=value(-20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2>=value(-21)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub lesseq () {
|
||||||
|
ubyte b1 = 19
|
||||||
|
ubyte b2 = 20
|
||||||
|
ubyte b3 = 21
|
||||||
|
ubyte b4 = 20
|
||||||
|
|
||||||
|
txt.print("<=(u): 011011011: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2<=19
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=21
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b4
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b3
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=value(19)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2<=value(20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2<=value(21)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub lesseq_signed () {
|
||||||
|
byte b1 = -19
|
||||||
|
byte b2 = -20
|
||||||
|
byte b3 = -21
|
||||||
|
byte b4 = -20
|
||||||
|
|
||||||
|
txt.print("<=(s): 110110110: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2<= -19
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<= -20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<= -21
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b4
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b3
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=value(-19)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2<=value(-20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2<=value(-21)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
193
examples/test.p8
193
examples/test.p8
@@ -7,6 +7,11 @@ main {
|
|||||||
greater_signed()
|
greater_signed()
|
||||||
less()
|
less()
|
||||||
less_signed()
|
less_signed()
|
||||||
|
|
||||||
|
greatereq()
|
||||||
|
greatereq_signed()
|
||||||
|
lesseq()
|
||||||
|
lesseq_signed()
|
||||||
}
|
}
|
||||||
|
|
||||||
sub value(ubyte arg) -> ubyte {
|
sub value(ubyte arg) -> ubyte {
|
||||||
@@ -24,7 +29,7 @@ main {
|
|||||||
ubyte b2 = 20
|
ubyte b2 = 20
|
||||||
ubyte b3 = 10
|
ubyte b3 = 10
|
||||||
|
|
||||||
txt.print("101010: ")
|
txt.print(">(u): 101010: ")
|
||||||
ubyte xx
|
ubyte xx
|
||||||
xx = b2>10
|
xx = b2>10
|
||||||
txt.print_ub(xx)
|
txt.print_ub(xx)
|
||||||
@@ -57,7 +62,7 @@ main {
|
|||||||
byte b2 = -10
|
byte b2 = -10
|
||||||
byte b3 = -20
|
byte b3 = -20
|
||||||
|
|
||||||
txt.print("101010: ")
|
txt.print(">(s): 101010: ")
|
||||||
ubyte xx
|
ubyte xx
|
||||||
xx = b2 > -20
|
xx = b2 > -20
|
||||||
txt.print_ub(xx)
|
txt.print_ub(xx)
|
||||||
@@ -90,7 +95,7 @@ main {
|
|||||||
ubyte b2 = 10
|
ubyte b2 = 10
|
||||||
ubyte b3 = 20
|
ubyte b3 = 20
|
||||||
|
|
||||||
txt.print("101010: ")
|
txt.print("<(u): 101010: ")
|
||||||
ubyte xx
|
ubyte xx
|
||||||
xx = b2<20
|
xx = b2<20
|
||||||
txt.print_ub(xx)
|
txt.print_ub(xx)
|
||||||
@@ -123,7 +128,7 @@ main {
|
|||||||
byte b2 = -20
|
byte b2 = -20
|
||||||
byte b3 = -10
|
byte b3 = -10
|
||||||
|
|
||||||
txt.print("101010: ")
|
txt.print("<(s): 101010: ")
|
||||||
ubyte xx
|
ubyte xx
|
||||||
xx = b2 < -10
|
xx = b2 < -10
|
||||||
txt.print_ub(xx)
|
txt.print_ub(xx)
|
||||||
@@ -151,4 +156,184 @@ main {
|
|||||||
txt.nl()
|
txt.nl()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub greatereq () {
|
||||||
|
ubyte b1 = 19
|
||||||
|
ubyte b2 = 20
|
||||||
|
ubyte b3 = 21
|
||||||
|
ubyte b4 = 20
|
||||||
|
|
||||||
|
txt.print(">=(u): 110110110: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2>=19
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=21
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b4
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b3
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=value(19)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2>=value(20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2>=value(21)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub greatereq_signed () {
|
||||||
|
byte b1 = -19
|
||||||
|
byte b2 = -20
|
||||||
|
byte b3 = -21
|
||||||
|
byte b4 = -20
|
||||||
|
|
||||||
|
txt.print(">=(s): 011011011: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2>= -19
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>= -20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>= -21
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b4
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=b3
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2>=value(-19)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2>=value(-20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2>=value(-21)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub lesseq () {
|
||||||
|
ubyte b1 = 19
|
||||||
|
ubyte b2 = 20
|
||||||
|
ubyte b3 = 21
|
||||||
|
ubyte b4 = 20
|
||||||
|
|
||||||
|
txt.print("<=(u): 011011011: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2<=19
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=21
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b4
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b3
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=value(19)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2<=value(20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2<=value(21)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
|
sub lesseq_signed () {
|
||||||
|
byte b1 = -19
|
||||||
|
byte b2 = -20
|
||||||
|
byte b3 = -21
|
||||||
|
byte b4 = -20
|
||||||
|
|
||||||
|
txt.print("<=(s): 110110110: ")
|
||||||
|
ubyte xx
|
||||||
|
xx = b2<= -19
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<= -20
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<= -21
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b1
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b4
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=b3
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
xx = b2<=value(-19)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2<=value(-20)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
xx = b2<=value(-21)
|
||||||
|
txt.print_ub(xx)
|
||||||
|
txt.spc()
|
||||||
|
|
||||||
|
txt.nl()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user