![]() |
Is posible put a ubyte variable just after DIM - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: Is posible put a ubyte variable just after DIM (/showthread.php?tid=1376) |
Is posible put a ubyte variable just after DIM - maeloterkim - 09-04-2021 Hi Is posible put a ubyte variable just after DIM WITHOUT ASSEMBLER maybe with AT @ or something Example: Code: DIM udg(1, 7) AS uByte => {{0,1,3,7,15,31,63,127}, _ RE: Is posible put a ubyte variable just after DIM - boriel - 09-05-2021 (09-04-2021, 02:17 PM)maeloterkim Wrote: Hi ZX Basic does not usually allow to change variables locations: this is the linker task, and currently ZX Basic linker is very... BASIC (pun intended). Unfortunately, single variables (like myVariable) are placed first. I will try to make ZX Basic to allocate global variables in the same order they are declared. Also, this will be soon available: Code: DIM myVariable as UByte AT @udg(1, 7) + 1 I will investigate this. A simpler way is to use PEEK and POKE I guess. RE: Is posible put a ubyte variable just after DIM - maeloterkim - 09-06-2021 I guess there must be different solutions depending on how you have made the compiler A rather good solution would be to put the global variables one behind each other as they are declared liked you said In this way you can "do structures" as in C For example, we can "create a structure" like this Typedef Struct Namestruct { U8 X; U8 Y; U8 * pointer; } My_struct; This Way. nameStruct: dim x as ubyte = 0 dim y as ubyte = 0 dim pointer as integer = 0 and after this we can iterate with index constants The compiler only must be sure that don't put any byte between variables another way is the form AT @udg(1, 7) + 1 but i don't know if the compiler puts some bytes between variables (before or after) |