diff --git a/compiler/res/prog8lib/prog8_lib.asm b/compiler/res/prog8lib/prog8_lib.asm index 7cc9f46b7..24c4ebb54 100644 --- a/compiler/res/prog8lib/prog8_lib.asm +++ b/compiler/res/prog8lib/prog8_lib.asm @@ -470,27 +470,19 @@ less_uw .proc reg_less_w .proc ; -- AY < P8ZP_SCRATCH_W2? - sta P8ZP_SCRATCH_B1 + cmp P8ZP_SCRATCH_W2 tya - sec sbc P8ZP_SCRATCH_W2+1 bvc + eor #$80 + bmi _true - bvc + - eor #$80 -+ bne _false - lda P8ZP_SCRATCH_B1 - sbc P8ZP_SCRATCH_W2 - bcs _false -_true lda #1 + lda #0 rts -_false lda #0 +_true lda #1 rts .pend less_w .proc - ; TODO is this word comparison < correct? reg_less_w is a lot larger... lda P8ESTACK_LO+2,x cmp P8ESTACK_LO+1,x lda P8ESTACK_HI+2,x diff --git a/docs/source/todo.rst b/docs/source/todo.rst index e7bd1c408..fedaccf6e 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,9 +3,10 @@ TODO ==== - check the various math routines that are marked TODO in prog8_lib.asm for correctness... +- see if we can group some errors together for instance the (now single) errors about unidentified symbols +- Cx16 target: support full-screen 640x480 and 320x240 graphics? That requires our own custom graphics routines though to draw lines. - make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as '_' - option to load the built-in library files from a directory instead of the embedded ones (for easier library development/debugging) -- see if we can group some errors together for instance the (now single) errors about unidentified symbols - use VIC banking to move up the graphics bitmap memory location. Move it to $e000 under the kernal rom? - some support for recursive subroutines? - via %option recursive?: allocate all params and local vars on estack, don't allow nested subroutines, can begin by first not allowing any local variables just fixing the parameters diff --git a/examples/test.p8 b/examples/test.p8 index bee9d4f25..66e545e92 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -7,77 +7,116 @@ main { sub start() { - ubyte[] ubarray = [100,200] - uword[] uwarray = [1000, 2000] + word lessvar + word comparevar - ubyte index = 0 - ubarray[index+1] += 13 - ubarray[index+1] += 13 - ubarray[index+1] += 13 - ; ubarray[index+2] += 13 - - txt.print_ub(ubarray[1]) + comparevar = 0 + txt.print_w(comparevar) txt.chrout('\n') + for lessvar in -1 downto -32768 { + check_less_w(lessvar, comparevar) + } - uwarray[index+1] += 13 - uwarray[index+1] += 13 - uwarray[index+1] += 13 - ; uwarray[index+2] += 13 - - txt.print_uw(uwarray[1]) + comparevar = -2 + txt.print_w(comparevar) txt.chrout('\n') + for lessvar in -3 downto -32768 { + check_less_w(lessvar, comparevar) + } + + comparevar = -254 + txt.print_w(comparevar) + txt.chrout('\n') + for lessvar in -255 downto -32768 { + check_less_w(lessvar, comparevar) + } + + comparevar = -255 + txt.print_w(comparevar) + txt.chrout('\n') + for lessvar in -256 downto -32768 { + check_less_w(lessvar, comparevar) + } + + comparevar = -256 + txt.print_w(comparevar) + txt.chrout('\n') + for lessvar in -257 downto -32768 { + check_less_w(lessvar, comparevar) + } + + comparevar = -5000 + txt.print_w(comparevar) + txt.chrout('\n') + for lessvar in -5001 downto -32768 { + check_less_w(lessvar, comparevar) + } + + comparevar = 1 + txt.print_w(comparevar) + txt.chrout('\n') + for lessvar in 0 downto -32768 { + check_less_w(lessvar, comparevar) + } + + comparevar = 255 + txt.print_w(comparevar) + txt.chrout('\n') + for lessvar in 254 downto -32768 { + check_less_w(lessvar, comparevar) + } + + comparevar = 256 + txt.print_w(comparevar) + txt.chrout('\n') + for lessvar in 255 downto -32768 { + check_less_w(lessvar, comparevar) + } + + comparevar = 257 + txt.print_w(comparevar) + txt.chrout('\n') + for lessvar in 256 downto -32768 { + check_less_w(lessvar, comparevar) + } + + comparevar = 32767 + txt.print_w(comparevar) + txt.chrout('\n') + for lessvar in 32766 downto -32768 { + check_less_w(lessvar, comparevar) + } + + + test_stack.test() + return + + sub check_less_w(word w1, word w2) { + word zero = 0 + ubyte error=0 + + ubyte ub = w1 str { -; return "irmen" -; } }