byte comparison jumps now without translateExpression()

This commit is contained in:
Irmen de Jong 2020-11-21 23:28:51 +01:00
parent 8be234973c
commit e1dc283d4b
5 changed files with 110 additions and 186 deletions

View File

@ -1181,7 +1181,7 @@ $label nop""")
out(" lda #<${asmVar} | ldy #>${asmVar} | jsr floats.MOVFM") out(" lda #<${asmVar} | ldy #>${asmVar} | jsr floats.MOVFM")
} }
else -> { else -> {
// todo evaluate directly into fac1 instead of via stack intermediate // todo evaluate directly into fac1 instead of via stack intermediate (add RegisterOrPair.FAC1 ??)
translateExpression(returnvalue) translateExpression(returnvalue)
out(" jsr floats.pop_float_fac1") out(" jsr floats.pop_float_fac1")
} }

View File

@ -143,7 +143,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
DataType.FLOAT -> { DataType.FLOAT -> {
// todo via func args // todo via func args
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e1): '<' at ${left.position}") // TODO println("warning: slow stack evaluation used (e1): '<' at ${left.position}") // TODO float
translateExpression(left) translateExpression(left)
translateExpression(right) translateExpression(right)
asmgen.out(" jsr floats.less_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr floats.less_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -161,7 +161,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
DataType.FLOAT -> { DataType.FLOAT -> {
// todo via func args // todo via func args
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e1): '<=' at ${left.position}") // TODO println("warning: slow stack evaluation used (e1): '<=' at ${left.position}") // TODO float
translateExpression(left) translateExpression(left)
translateExpression(right) translateExpression(right)
asmgen.out(" jsr floats.lesseq_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr floats.lesseq_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -179,7 +179,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
DataType.FLOAT -> { DataType.FLOAT -> {
// todo via func args // todo via func args
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e1): '>' at ${left.position}") // TODO println("warning: slow stack evaluation used (e1): '>' at ${left.position}") // TODO float
translateExpression(left) translateExpression(left)
translateExpression(right) translateExpression(right)
asmgen.out(" jsr floats.greater_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr floats.greater_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -197,7 +197,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
DataType.FLOAT -> { DataType.FLOAT -> {
// todo via func args // todo via func args
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e1): '>=' at ${left.position}") // TODO println("warning: slow stack evaluation used (e1): '>=' at ${left.position}") // TODO float
translateExpression(left) translateExpression(left)
translateExpression(right) translateExpression(right)
asmgen.out(" jsr floats.greatereq_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr floats.greatereq_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -239,12 +239,9 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
} }
} }
// todo via func args or regs, or rather inline for bytes? asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
if(asmgen.options.slowCodegenWarnings) asmgen.assignExpressionToRegister(left, RegisterOrPair.A)
println("warning: slow stack evaluation used (e2): '<' at ${left.position}") // TODO ubyte < asmgen.out(" cmp P8ZP_SCRATCH_B1 | bcs $jumpIfFalseLabel")
asmgen.translateExpression(left)
asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.less_ub | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
} }
private fun translateByteLessJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) { private fun translateByteLessJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
@ -271,12 +268,14 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
} }
} }
// todo via func args or regs, or rather inline for bytes? asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
if(asmgen.options.slowCodegenWarnings) asmgen.assignExpressionToRegister(left, RegisterOrPair.A)
println("warning: slow stack evaluation used (e3): '<' at ${left.position}") // TODO byte < asmgen.out("""
asmgen.translateExpression(left) sec
asmgen.translateExpression(right) sbc P8ZP_SCRATCH_B1
asmgen.out(" jsr prog8_lib.less_b | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") bvc +
eor #$80
+ bpl $jumpIfFalseLabel""")
} }
private fun translateUwordLessJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) { private fun translateUwordLessJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
@ -307,7 +306,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e4): '<' at ${left.position}") // TODO println("warning: slow stack evaluation used (e4): '<' at ${left.position}") // TODO uword
asmgen.translateExpression(left) asmgen.translateExpression(left)
asmgen.translateExpression(right) asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.less_uw | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr prog8_lib.less_uw | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -340,7 +339,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e5): '<' at ${left.position}") // TODO println("warning: slow stack evaluation used (e5): '<' at ${left.position}") // TODO word
asmgen.translateExpression(left) asmgen.translateExpression(left)
asmgen.translateExpression(right) asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.less_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr prog8_lib.less_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -376,12 +375,12 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
} }
} }
// todo via func args or regs, or rather inline for bytes? asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
if(asmgen.options.slowCodegenWarnings) asmgen.assignExpressionToRegister(left, RegisterOrPair.A)
println("warning: slow stack evaluation used (e6): '>' at ${left.position}") // TODO ubyte > asmgen.out("""
asmgen.translateExpression(left) cmp P8ZP_SCRATCH_B1
asmgen.translateExpression(right) bcc $jumpIfFalseLabel
asmgen.out(" jsr prog8_lib.greater_ub | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") beq $jumpIfFalseLabel""")
} }
private fun translateByteGreaterJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) { private fun translateByteGreaterJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
@ -410,12 +409,16 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
} }
} }
// todo via func args or regs, or rather inline for bytes? asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
if(asmgen.options.slowCodegenWarnings) asmgen.assignExpressionToRegister(left, RegisterOrPair.A)
println("warning: slow stack evaluation used (e7): '>' at ${left.position}") // TODO byte > asmgen.out("""
asmgen.translateExpression(left) clc
asmgen.translateExpression(right) sbc P8ZP_SCRATCH_B1
asmgen.out(" jsr prog8_lib.greater_b | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") bvc +
eor #$80
+ bpl +
bmi $jumpIfFalseLabel
+""")
} }
private fun translateUwordGreaterJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) { private fun translateUwordGreaterJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
@ -450,7 +453,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e8): '>' at ${left.position}") // TODO println("warning: slow stack evaluation used (e8): '>' at ${left.position}") // TODO uword
asmgen.translateExpression(left) asmgen.translateExpression(left)
asmgen.translateExpression(right) asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.greater_uw | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr prog8_lib.greater_uw | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -489,7 +492,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e9): '>' at ${left.position}") // TODO println("warning: slow stack evaluation used (e9): '>' at ${left.position}") // TODO word
asmgen.translateExpression(left) asmgen.translateExpression(left)
asmgen.translateExpression(right) asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.greater_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr prog8_lib.greater_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -532,12 +535,13 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
} }
} }
// todo via func args or regs, or rather inline for bytes? asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
if(asmgen.options.slowCodegenWarnings) asmgen.assignExpressionToRegister(left, RegisterOrPair.A)
println("warning: slow stack evaluation used (e10): '<=' at ${left.position}") // TODO ubyte <= asmgen.out("""
asmgen.translateExpression(left) cmp P8ZP_SCRATCH_B1
asmgen.translateExpression(right) beq +
asmgen.out(" jsr prog8_lib.lesseq_ub | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") bcs $jumpIfFalseLabel
+""")
} }
private fun translateByteLessOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) { private fun translateByteLessOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
@ -568,12 +572,14 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
} }
} }
// todo via func args or regs, or rather inline for bytes? asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
if(asmgen.options.slowCodegenWarnings) asmgen.assignExpressionToRegister(left, RegisterOrPair.A)
println("warning: slow stack evaluation used (e11): '<=' at ${left.position}") // TODO byte <= asmgen.out("""
asmgen.translateExpression(left) clc
asmgen.translateExpression(right) sbc P8ZP_SCRATCH_B1
asmgen.out(" jsr prog8_lib.lesseq_b | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") bvc +
eor #$80
+ bpl $jumpIfFalseLabel""")
} }
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) {
@ -607,7 +613,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e12): '<=' at ${left.position}") // TODO println("warning: slow stack evaluation used (e12): '<=' at ${left.position}") // TODO uword
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")
@ -646,7 +652,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e13): '<=' at ${left.position}") // TODO println("warning: slow stack evaluation used (e13): '<=' at ${left.position}") // TODO word
asmgen.translateExpression(left) asmgen.translateExpression(left)
asmgen.translateExpression(right) asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.lesseq_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr prog8_lib.lesseq_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -677,12 +683,9 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
} }
} }
// todo via func args or regs, or rather inline for bytes? asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
if(asmgen.options.slowCodegenWarnings) asmgen.assignExpressionToRegister(left, RegisterOrPair.A)
println("warning: slow stack evaluation used (e14): '>=' at ${left.position}") // TODO ubyte >= asmgen.out(" cmp P8ZP_SCRATCH_B1 | bcc $jumpIfFalseLabel")
asmgen.translateExpression(left)
asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.greatereq_ub | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
} }
private fun translateByteGreaterOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) { private fun translateByteGreaterOrEqualJump(left: Expression, right: Expression, leftConstVal: NumericLiteralValue?, rightConstVal: NumericLiteralValue?, jumpIfFalseLabel: String) {
@ -712,12 +715,14 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
} }
} }
// todo via func args or regs, or rather inline for bytes? asmgen.assignExpressionToVariable(right, "P8ZP_SCRATCH_B1", DataType.UBYTE, null)
if(asmgen.options.slowCodegenWarnings) asmgen.assignExpressionToRegister(left, RegisterOrPair.A)
println("warning: slow stack evaluation used (e15): '>=' at ${left.position}") // TODO byte >= asmgen.out("""
asmgen.translateExpression(left) sec
asmgen.translateExpression(right) sbc P8ZP_SCRATCH_B1
asmgen.out(" jsr prog8_lib.greatereq_b | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") bvc +
eor #$80
+ bmi $jumpIfFalseLabel""")
} }
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) {
@ -746,7 +751,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e16): '>=' at ${left.position}") // TODO println("warning: slow stack evaluation used (e16): '>=' at ${left.position}") // TODO uword
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")
@ -780,7 +785,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e17): '>=' at ${left.position}") // TODO println("warning: slow stack evaluation used (e17): '>=' at ${left.position}") // TODO word
asmgen.translateExpression(left) asmgen.translateExpression(left)
asmgen.translateExpression(right) asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.greatereq_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr prog8_lib.greatereq_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -878,7 +883,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e20): '==' at ${left.position}") // TODO println("warning: slow stack evaluation used (e20): '==' at ${left.position}") // TODO (u)word
asmgen.translateExpression(left) asmgen.translateExpression(left)
asmgen.translateExpression(right) asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.equal_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr prog8_lib.equal_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -916,7 +921,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args or regs // todo via func args or regs
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e21): '!=' at ${left.position}") // TODO println("warning: slow stack evaluation used (e21): '!=' at ${left.position}") // TODO (u)word
asmgen.translateExpression(left) asmgen.translateExpression(left)
asmgen.translateExpression(right) asmgen.translateExpression(right)
asmgen.out(" jsr prog8_lib.notequal_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr prog8_lib.notequal_w | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -964,7 +969,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args // todo via func args
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e22): '==' at ${left.position}") // TODO println("warning: slow stack evaluation used (e22): '==' at ${left.position}") // TODO float
translateExpression(left) translateExpression(left)
translateExpression(right) translateExpression(right)
asmgen.out(" jsr floats.equal_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr floats.equal_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")
@ -1013,7 +1018,7 @@ internal class ExpressionsAsmGen(private val program: Program, private val asmge
// todo via func args // todo via func args
if(asmgen.options.slowCodegenWarnings) if(asmgen.options.slowCodegenWarnings)
println("warning: slow stack evaluation used (e23): '!=' at ${left.position}") // TODO println("warning: slow stack evaluation used (e23): '!=' at ${left.position}") // TODO float
translateExpression(left) translateExpression(left)
translateExpression(right) translateExpression(right)
asmgen.out(" jsr floats.notequal_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel") asmgen.out(" jsr floats.notequal_f | inx | lda P8ESTACK_LO,x | beq $jumpIfFalseLabel")

View File

@ -1,6 +1,7 @@
%import textio %import textio
%import floats %import floats
%import syslib %import syslib
%import test_stack
%zeropage basicsafe %zeropage basicsafe
main { main {
@ -11,7 +12,7 @@ main {
integers() integers()
floatingpoint() floatingpoint()
testX() test_stack.test()
} }
sub rotations() { sub rotations() {
@ -251,8 +252,7 @@ main {
txt.chrout('\n') txt.chrout('\n')
txt.chrout('\n') txt.chrout('\n')
test_stack.test()
testX()
} }
@ -324,7 +324,7 @@ main {
txt.print(result) txt.print(result)
txt.chrout('\n') txt.chrout('\n')
testX() test_stack.test()
} }
@ -643,7 +643,7 @@ main {
reverse(uwarr) reverse(uwarr)
reverse(warr) reverse(warr)
testX() test_stack.test()
} }
sub floatingpoint() { sub floatingpoint() {
@ -831,36 +831,6 @@ main {
floats.print_f(fl) floats.print_f(fl)
txt.chrout('\n') txt.chrout('\n')
testX() test_stack.test()
}
asmsub testX() {
%asm {{
stx _saveX
lda #13
jsr txt.chrout
lda #'x'
jsr txt.chrout
lda #'='
jsr txt.chrout
lda _saveX
jsr txt.print_ub
lda #' '
jsr txt.chrout
lda #'s'
jsr txt.chrout
lda #'p'
jsr txt.chrout
lda #'='
jsr txt.chrout
tsx
txa
jsr txt.print_ub
lda #13
jsr txt.chrout
ldx _saveX
rts
_saveX .byte 0
}}
} }
} }

View File

@ -7,77 +7,41 @@ main {
sub start() { sub start() {
ubyte ub byte ub1
byte bb byte ub2
uword uw byte bb1
word ww byte bb2
uword uw1
uword uw2
word ww1
word ww2
const ubyte arrub = 10 ub1 = 10
const uword arruw = 10 ub2 = 11
const byte arrb = 10 if ub1<ub2
const word arrw = 10 txt.chrout('.')
else
test_stack.test() txt.chrout('!')
if ub1<=ub2
for ub in 0 to arrub step 2 { txt.chrout('.')
txt.print_ub(ub) else
txt.chrout(',') txt.chrout('!')
} if ub1>ub2
txt.chrout('\n') txt.chrout('!')
else
for ub in 5 to arrub step 2 { txt.chrout('.')
txt.print_ub(ub) if ub1>=ub2
txt.chrout(',') txt.chrout('!')
} else
txt.chrout('\n') txt.chrout('.')
if ub1==ub2
for uw in 0 to arruw step 2 { txt.chrout('!')
txt.print_uw(uw) else
txt.chrout(',') txt.chrout('.')
} if ub1!=ub2
txt.chrout('\n') txt.chrout('.')
else
for uw in 5 to arruw step 2 { txt.chrout('!')
txt.print_uw(uw)
txt.chrout(',')
}
txt.chrout('\n')
for bb in 0 to arrb step 2 {
txt.print_b(bb)
txt.chrout(',')
}
txt.chrout('\n')
for bb in -2 to arrb-2 step 2 {
txt.print_b(bb)
txt.chrout(',')
}
txt.chrout('\n')
for ww in 0 to arrw step 2 {
txt.print_w(ww)
txt.chrout(',')
}
txt.chrout('\n')
for ww in -2 to arrw-2 step 2{
txt.print_w(ww)
txt.chrout(',')
}
txt.chrout('\n')
for bb in arrb-2 to -2 step -2 {
txt.print_b(bb)
txt.chrout(',')
}
txt.chrout('\n')
; for ww in arrw-2 to -2 step -2 {
; txt.print_w(ww)
; txt.chrout(',')
; }
; txt.chrout('\n')
test_stack.test() test_stack.test()
txt.chrout('\n') txt.chrout('\n')

View File

@ -981,19 +981,4 @@ util {
}} }}
} }
asmsub testX() {
%asm {{
stx _saveX
lda #13
jsr txt.chrout
lda _saveX
jsr txt.print_ub
lda #13
jsr txt.chrout
ldx _saveX
rts
_saveX .byte 0
}}
}
} }