add lmh(longvalue) builtin function that returns the low, mid, hi (=bank) bytes of a long

symboldumps now also contain the builtin functions
This commit is contained in:
Irmen de Jong
2026-02-23 21:30:39 +01:00
parent 1b5dd980df
commit bdbdf6e5cd
22 changed files with 396 additions and 25 deletions
@@ -1,12 +1,67 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 9aff85f0 in branch master
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-c128.p8
Compiler target: c128
BUILTIN FUNCTIONS
-----------------
setlsb
setmsb
rol
ror
rol2
ror2
cmp
abs
len
sizeof
offsetof
sgn
sqrt
divmod
lmh
lsb
msb
lsw
msw
mkword
mklong
mklong2
clamp
min
max
peek
peekbool
peekw
peekl
peekf
poke
pokebool
pokebowl
pokew
pokel
pokef
pokemon
rsave
rrestore
memory
callfar
callfar2
call
push
pushw
pushl
pushf
pop
popw
popl
popf
LIBRARY MODULE NAME: bcd
------------------------
@@ -1,12 +1,67 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 9aff85f0 in branch master
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-c64.p8
Compiler target: c64
BUILTIN FUNCTIONS
-----------------
setlsb
setmsb
rol
ror
rol2
ror2
cmp
abs
len
sizeof
offsetof
sgn
sqrt
divmod
lmh
lsb
msb
lsw
msw
mkword
mklong
mklong2
clamp
min
max
peek
peekbool
peekw
peekl
peekf
poke
pokebool
pokebowl
pokew
pokel
pokef
pokemon
rsave
rrestore
memory
callfar
callfar2
call
push
pushw
pushl
pushf
pop
popw
popl
popf
LIBRARY MODULE NAME: bcd
------------------------
@@ -1,12 +1,67 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 9aff85f0 in branch master
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-cx16.p8
Compiler target: cx16
BUILTIN FUNCTIONS
-----------------
setlsb
setmsb
rol
ror
rol2
ror2
cmp
abs
len
sizeof
offsetof
sgn
sqrt
divmod
lmh
lsb
msb
lsw
msw
mkword
mklong
mklong2
clamp
min
max
peek
peekbool
peekw
peekl
peekf
poke
pokebool
pokebowl
pokew
pokel
pokef
pokemon
rsave
rrestore
memory
callfar
callfar2
call
push
pushw
pushl
pushf
pop
popw
popl
popf
LIBRARY MODULE NAME: bcd
------------------------
@@ -1,12 +1,67 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 9aff85f0 in branch master
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-pet32.p8
Compiler target: pet32
BUILTIN FUNCTIONS
-----------------
setlsb
setmsb
rol
ror
rol2
ror2
cmp
abs
len
sizeof
offsetof
sgn
sqrt
divmod
lmh
lsb
msb
lsw
msw
mkword
mklong
mklong2
clamp
min
max
peek
peekbool
peekw
peekl
peekf
poke
pokebool
pokebowl
pokew
pokel
pokef
pokemon
rsave
rrestore
memory
callfar
callfar2
call
push
pushw
pushl
pushf
pop
popw
popl
popf
LIBRARY MODULE NAME: bcd
------------------------
@@ -1,12 +1,67 @@
Prog8 compiler v12.2-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
Prerelease version from git commit 9aff85f0 in branch master
Prerelease version from git commit 1b5dd980 in branch builtins-return-multivalue
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
Compiling program import-all-virtual.p8
Compiler target: virtual
BUILTIN FUNCTIONS
-----------------
setlsb
setmsb
rol
ror
rol2
ror2
cmp
abs
len
sizeof
offsetof
sgn
sqrt
divmod
lmh
lsb
msb
lsw
msw
mkword
mklong
mklong2
clamp
min
max
peek
peekbool
peekw
peekl
peekf
poke
pokebool
pokebowl
pokew
pokel
pokef
pokemon
rsave
rrestore
memory
callfar
callfar2
call
push
pushw
pushl
pushf
pop
popw
popl
popf
LIBRARY MODULE NAME: buffers
----------------------------
+7 -1
View File
@@ -144,7 +144,13 @@ Miscellaneous
:index:`msb` (x)
Get the most significant (highest) byte of the word or long value
(so for a long value, msb($11223344) is $11, not $33. To grab the bank byte of a long variable, you need to do this:
``lsb(msw(longvariable))`` or the equivalent ``@(&longvariable+2)``.)
``lsb(msw(longvariable))`` or the equivalent ``@(&longvariable+2)``.) But also look at the ``lmh`` function.
:index:`lmh` (x)
Get the three low, mid and high (bank) bytes of the given long value. The upper byte (bits 24-31) of the long value is not considered.
So this means lmh($11223344) returns the three bytes $44, $33, $22 in that order.
For the Commander X16 a possible use of this function is to set the 24-bits Vera address in one assignment statement:
``cx16.VERA_ADDR_L, cx16.VERA_ADDR_M, cx16.VERA_ADDR_H = lmh(address)``
:index:`msw` (x)
Get the most significant (higher) word of the value x. For all word and byte numbers this will always result in 0.
+1 -2
View File
@@ -1,8 +1,6 @@
TODO
====
add lmh(longvalue) -or whatever sensible name- builtin function that returns the low, mid, hi (=bank) bytes of a long.
simplifiedAstMaker: transform(srcCall: FunctionCallStatement) : what when the call actually returns multiple return values???
@@ -35,6 +33,7 @@ Future Things and Ideas
- struct/ptr: really fixing the pointer dereferencing issues (cursed hybrid beween IdentifierReference, PtrDereferece and PtrIndexedDereference) may require getting rid of scoped identifiers altogether and treat '.' as a "scope or pointer following operator"
- struct/ptr: (later, nasty parser problem:) support chaining pointer dereference on function calls that return a pointer. (type checking now fails on stuff like func().field and func().next.field)
- should we have a SourceStorageKind.POINTER? (there is one for TargetStorageKind...)
- add a "tuple" node that allows you to do: a,b,c = 1,2,3 or l,m,h = lmh($00aabbcc) -> l,m,h = $aa,$bb,$cc (can't currently const-fold this, see ConstantFoldingOptimizer)
- make memory mapped variables support more constant expressions such as: &uword MyHigh = &mylong1+2 (see github issue #192)
- allow memory() to occur in array initializer (maybe needed for 2 dimensional arrays?) i.e. make it a constant (see github issue #192)
- allow the value of a memory mapped variable to be address-of another variable, not just a constant number