mirror of
https://github.com/irmen/prog8.git
synced 2025-04-05 03:37:25 +00:00
optimized reg_less_w (word < word)
This commit is contained in:
parent
d40788adfa
commit
05d3a2450c
@ -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
|
||||
|
@ -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
|
||||
|
173
examples/test.p8
173
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<w2
|
||||
if not ub {
|
||||
error++
|
||||
txt.print("ub!")
|
||||
}
|
||||
|
||||
if w1<(w2+zero) {
|
||||
zero = 0 ; dummy
|
||||
} else {
|
||||
error++
|
||||
txt.print("c!")
|
||||
}
|
||||
|
||||
if error {
|
||||
txt.print(" ")
|
||||
txt.print_w(w1)
|
||||
txt.print(" < ")
|
||||
txt.print_w(w2)
|
||||
txt.chrout('\n')
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
; sub start222() {
|
||||
;
|
||||
; ubyte[] ubarray = [100,200]
|
||||
; uword[] uwarray = [1000,2000]
|
||||
; float[] flarray = [100.1, 200.2]
|
||||
;
|
||||
; ubyte index = 1
|
||||
;
|
||||
; ubarray[1] += 3
|
||||
; txt.print_ub(ubarray[1])
|
||||
; txt.chrout('\n')
|
||||
; ubarray[index] += 3
|
||||
; txt.print_ub(ubarray[1])
|
||||
; txt.chrout('\n')
|
||||
; index = 0
|
||||
; ubarray[index*99+1] += 3
|
||||
; txt.print_ub(ubarray[1])
|
||||
; txt.chrout('\n')
|
||||
; txt.chrout('\n')
|
||||
;
|
||||
; index = 1
|
||||
; uwarray[1] += 3
|
||||
; txt.print_uw(uwarray[1])
|
||||
; txt.chrout('\n')
|
||||
; uwarray[index] += 3
|
||||
; txt.print_uw(uwarray[1])
|
||||
; txt.chrout('\n')
|
||||
; index = 0
|
||||
; uwarray[index*99+1] += 3
|
||||
; txt.print_uw(uwarray[1])
|
||||
; txt.chrout('\n')
|
||||
; txt.chrout('\n')
|
||||
;
|
||||
; index=1
|
||||
; flarray[1] += 3.0
|
||||
; floats.print_f(flarray[1])
|
||||
; txt.chrout('\n')
|
||||
; flarray[index] += 3.0
|
||||
; floats.print_f(flarray[1])
|
||||
; txt.chrout('\n')
|
||||
; index = 0
|
||||
; flarray[index*99+1] += 3.0
|
||||
; floats.print_f(flarray[1])
|
||||
; txt.chrout('\n')
|
||||
;
|
||||
; test_stack.test()
|
||||
;
|
||||
; }
|
||||
;
|
||||
; sub name() -> str {
|
||||
; return "irmen"
|
||||
; }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user