Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is posible put a ubyte variable just after DIM
#1
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}, _
                           {1,2,4,7,15,31,63,127}}

DIM myVariable as ubyte 

I WANT THIS VARIABLE VALUE JUST THE NEXT BYTE AT THE END OF LAST UDG DIM BYTE LIKE THIS

ADDRESS       1  2  3  4   5   6   7   8     9  10   11  12   13   14   15   16        17
VALUE         0  1  3  7  15  31  63  127    1   2   4    7   15   31   63   127    myVariable
              --------------------      DIM UDG  -------------------------------
Reply
#2
(09-04-2021, 02:17 PM)maeloterkim Wrote: 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}, _
                           {1,2,4,7,15,31,63,127}}

DIM myVariable as ubyte 

I WANT THIS VARIABLE VALUE JUST THE NEXT BYTE AT THE END OF LAST UDG DIM BYTE LIKE THIS

ADDRESS       1  2  3  4   5   6   7   8     9  10   11  12   13   14   15   16        17
VALUE         0  1  3  7  15  31  63  127    1   2   4    7   15   31   63   127    myVariable
              --------------------      DIM UDG  -------------------------------

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
Which will, effectively, declare myVariable at the first byte after the array, but it won't allocate the required byte (DIM ... AT, is just an alias for memory access).

I will investigate this.
A simpler way is to use PEEK and POKE I guess.
Reply
#3
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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)