mirror of
https://github.com/irmen/prog8.git
synced 2025-02-10 14:32:20 +00:00
removed anyall library module altogether. The routines weren't very optimized and didn't work on split word arrays.
This commit is contained in:
parent
80d88b3c61
commit
1e85f7812f
@ -1,82 +0,0 @@
|
||||
; any() and all() checks on arrays/memory buffers.
|
||||
; These were builtin functions in older versions of the language.
|
||||
|
||||
%option no_symbol_prefixing, ignore_unused
|
||||
|
||||
anyall {
|
||||
sub any(uword arrayptr, uword num_elements) -> bool {
|
||||
; -- returns true if any byte in the array is not zero.
|
||||
cx16.r1 = arrayptr
|
||||
if msb(num_elements)==0 {
|
||||
for cx16.r0L in 0 to lsb(num_elements)-1 {
|
||||
if cx16.r1[cx16.r0L]!=0
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
repeat num_elements {
|
||||
if @(cx16.r1)!=0
|
||||
return true
|
||||
cx16.r1++
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
sub all(uword arrayptr, uword num_elements) -> bool {
|
||||
; -- returns true if all bytes in the array are not zero.
|
||||
cx16.r1 = arrayptr
|
||||
if msb(num_elements)==0 {
|
||||
for cx16.r0L in 0 to lsb(num_elements)-1 {
|
||||
if cx16.r1[cx16.r0L]==0
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
repeat num_elements {
|
||||
if @(cx16.r1)==0
|
||||
return false
|
||||
cx16.r1++
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
sub anyw(uword arrayptr, uword num_elements) -> bool {
|
||||
; -- returns true if any word in the array is not zero.
|
||||
; TODO FIX: doesn't work on split arrays. Just always test every byte !
|
||||
cx16.r1 = arrayptr
|
||||
if msb(num_elements)==0 {
|
||||
repeat lsb(num_elements) {
|
||||
if peekw(cx16.r1)!=0
|
||||
return true
|
||||
cx16.r1+=2
|
||||
}
|
||||
return false
|
||||
}
|
||||
repeat num_elements {
|
||||
if peekw(cx16.r1)!=0
|
||||
return true
|
||||
cx16.r1+=2
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
sub allw(uword arrayptr, uword num_elements) -> bool {
|
||||
; -- returns true if all words in the array are not zero.
|
||||
; TODO FIX: doesn't work on split arrays. Just always test every byte !
|
||||
cx16.r1 = arrayptr
|
||||
if msb(num_elements)==0 {
|
||||
repeat lsb(num_elements) {
|
||||
if peekw(cx16.r1)==0
|
||||
return false
|
||||
cx16.r1+=2
|
||||
}
|
||||
return true
|
||||
}
|
||||
repeat num_elements {
|
||||
if peekw(cx16.r1)==0
|
||||
return false
|
||||
cx16.r1+=2
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
%import floats
|
||||
%import textio
|
||||
%import strings
|
||||
%import anyall
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
@ -30,39 +29,6 @@ main {
|
||||
length=strings.length(name)
|
||||
if length!=3 txt.print("error strlen2\n")
|
||||
|
||||
; ANY
|
||||
ub = anyall.any(ubarr, len(ubarr)) as ubyte
|
||||
if ub==0 txt.print("error any1\n")
|
||||
ub = anyall.any(barr, len(barr)) as ubyte
|
||||
if ub==0 txt.print("error any2\n")
|
||||
ub = anyall.anyw(uwarr, len(uwarr)) as ubyte
|
||||
if ub==0 txt.print("error any3\n")
|
||||
ub = anyall.anyw(warr, len(warr)) as ubyte
|
||||
if ub==0 txt.print("error any4\n")
|
||||
|
||||
; ALL
|
||||
ub = anyall.all(ubarr, len(ubarr)) as ubyte
|
||||
if ub==1 txt.print("error all1\n")
|
||||
ub = anyall.all(barr, len(barr)) as ubyte
|
||||
if ub==1 txt.print("error all2\n")
|
||||
ub = anyall.allw(uwarr, len(uwarr)) as ubyte
|
||||
if ub==1 txt.print("error all3\n")
|
||||
ub = anyall.allw(warr, len(warr)) as ubyte
|
||||
if ub==1 txt.print("error all4\n")
|
||||
ubarr[1]=$40
|
||||
barr[1]=$40
|
||||
uwarr[1]=$4000
|
||||
warr[1]=$4000
|
||||
farr[1]=1.1
|
||||
ub = anyall.all(ubarr, len(ubarr)) as ubyte
|
||||
if ub==0 txt.print("error all6\n")
|
||||
ub = anyall.all(barr, len(barr)) as ubyte
|
||||
if ub==0 txt.print("error all7\n")
|
||||
ub = anyall.allw(uwarr, len(uwarr)) as ubyte
|
||||
if ub==0 txt.print("error all8\n")
|
||||
ub = anyall.allw(warr, len(warr)) as ubyte
|
||||
if ub==0 txt.print("error all9\n")
|
||||
|
||||
txt.print("\nyou should see no errors printed above (first run only).")
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
%import strings
|
||||
%import syslib
|
||||
%import math
|
||||
%import anyall
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
@ -351,62 +350,6 @@ main {
|
||||
ww = zero+(abs(ww) as word)*1+zero
|
||||
txt.print_w(ww)
|
||||
txt.nl()
|
||||
|
||||
ub = anyall.any(ubarr, len(ubarr)) as ubyte
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
ub = zero+(anyall.any(ubarr, len(ubarr)) as ubyte)*1+zero
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
|
||||
ub = anyall.any(barr, len(barr)) as ubyte
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
ub = zero+(anyall.any(barr, len(barr)) as ubyte)*1+zero
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
|
||||
ub = anyall.any(uwarr, len(uwarr)) as ubyte
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
ub = zero+(anyall.any(uwarr, len(uwarr)) as ubyte)*1+zero
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
|
||||
ub = anyall.any(warr, len(warr)) as ubyte
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
ub = zero+(anyall.any(warr, len(warr)) as ubyte)*1+zero
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
|
||||
ub = anyall.all(ubarr, len(ubarr)) as ubyte
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
ub = zero+(anyall.all(ubarr, len(ubarr)) as ubyte)*1+zero
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
|
||||
ub = anyall.all(barr, len(barr)) as ubyte
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
ub = zero+(anyall.all(barr, len(barr)) as ubyte)*1+zero
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
|
||||
ub = anyall.all(uwarr, len(uwarr)) as ubyte
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
ub = zero+(anyall.all(uwarr, len(uwarr)) as ubyte)*1+zero
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
|
||||
ub = anyall.all(warr, len(warr)) as ubyte
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
ub = zero+(anyall.all(warr, len(warr)) as ubyte)*1+zero
|
||||
txt.print_ub(ub)
|
||||
txt.nl()
|
||||
}
|
||||
|
||||
sub floatingpoint() {
|
||||
|
@ -1,6 +1,5 @@
|
||||
; all library modules for the atari compiler target
|
||||
|
||||
%import anyall
|
||||
%import buffers
|
||||
%import compression
|
||||
%import conv
|
||||
|
@ -1,6 +1,5 @@
|
||||
; all library modules for the c128 compiler target
|
||||
|
||||
%import anyall
|
||||
%import buffers
|
||||
%import compression
|
||||
%import conv
|
||||
|
@ -1,6 +1,5 @@
|
||||
; all library modules for the c64 compiler target
|
||||
|
||||
%import anyall
|
||||
%import buffers
|
||||
%import compression
|
||||
%import conv
|
||||
|
@ -1,6 +1,5 @@
|
||||
; all library modules for the cx16 compiler target
|
||||
|
||||
%import anyall
|
||||
%import buffers
|
||||
%import bmx
|
||||
%import compression
|
||||
|
@ -1,6 +1,5 @@
|
||||
; all library modules for the atari compiler target
|
||||
|
||||
%import anyall
|
||||
%import buffers
|
||||
%import compression
|
||||
%import conv
|
||||
|
@ -1,6 +1,5 @@
|
||||
; all library modules for the pet32 compiler target
|
||||
|
||||
%import anyall
|
||||
%import buffers
|
||||
%import compression
|
||||
%import conv
|
||||
|
@ -1,6 +1,5 @@
|
||||
; all library modules for the virtual compiler target
|
||||
|
||||
%import anyall
|
||||
%import buffers
|
||||
%import compression
|
||||
%import conv
|
||||
|
@ -393,25 +393,6 @@ sys (part of syslib)
|
||||
Low-level function that should normally not be used.
|
||||
|
||||
|
||||
anyall
|
||||
------
|
||||
Routines to check if any or all values in an array or memory buffer are not zero.
|
||||
|
||||
``any (arrayptr, num_elements)``
|
||||
true if any of the byte values in the array is not zero, else false.
|
||||
|
||||
``all (arrayptr, num_elements)``
|
||||
true if all of the byte values in the array are not zero, else false.
|
||||
|
||||
``anyw (arrayptr, num_elements)``
|
||||
true if any of the word values in the array is not zero, else false.
|
||||
Doesn't work on split arrays.
|
||||
|
||||
``allw (arrayptr, num_elements)``
|
||||
true if all of the word values in the array are not zero, else false.
|
||||
Doesn't work on split arrays.
|
||||
|
||||
|
||||
buffers (experimental)
|
||||
----------------------
|
||||
A small library providing a 8 KB stack, an 8 KB ringbuffer, and a fast 256 bytes ringbuffer.
|
||||
|
@ -3,7 +3,6 @@ TODO
|
||||
|
||||
- DONE: make word arrays split by default (remove @split tag) and use new @nosplit tag to make an array use the old storage format? Also invert -splitarrays command line option.
|
||||
- DONE: remove "splitarrays" %option switch
|
||||
- fix anyall.anyw/allw , optimize any/all in asm? make sure it still works for virtual
|
||||
- fix IR compilation errors
|
||||
- Regular & will just return the start of the split array in memory whatever byte comes first. Search TODO("address of split word array")
|
||||
- check this for 6502 codegen: split word arrays, both _msb and _lsb arrays are tagged with an alignment. This is not what's intended; only the one put in memory first should be aligned (the other one should follow straight after it)
|
||||
|
@ -2,11 +2,8 @@
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
uword large = memory("large", 20000, 256)
|
||||
|
||||
sub start() {
|
||||
for cx16.r1 in large to large+20000-1 {
|
||||
cx16.r0++
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user