Copyright © 2000 Jarno van der Linden.
freegdgetgdconstgetgdrwglobaldataglobaldataend<global data tool>freegd <name>
getgd macro. This will create a fresh copy, without any of the
changes made before freegd. You better be absolutely sure that
the program doesn't use the global data anywhere after it has been freed.
For this macro to work, the name of the data area must be equal to the tool
defining the data area. The best way to ensure this is to always use the
globaldata and globaldataend macros to define the
data.
At present, this macro is does nothing when applied to constant global data.
getgdrw demo/gd/my_data, p0 cpy.i 42,[p0+MYDATA_ANSWER] ; Do lots of stuff... [...] ; I guarantee not to need the data again from here freegd demo/gd/my_data ; Do lots more stuff... [...] |
getgdrw
getgdconst <name>,<data pointer>
For this macro to work, the name of the data area must be equal to the tool
defining the data area. The best way to ensure this is to always use the
globaldata and globaldataend macros to define the data.
globaldata 'demo/gd/my_data', GD_CONST dc.d 3.141592654 dc.b 'This is a chunk of constant global data',0 globaldataend [...] getgdconst demo/gd/my_data, p0 printf "String = %s\n", (p0+8) |
String = This is a chunk of constant global data |
freegd
getgdrw
getgdrw <name>,<data pointer>
For this macro to work, the name of the data area must be equal to the tool
defining the data area. The best way to ensure this is to always use the
globaldata and globaldataend macros to define the data.
globaldata 'demo/gd/my_data' dc.i 69 dc.b 'This is a chunk of read/write global data',0 blk.b 256-42,0 globaldataend [...] getgdrw demo/gd/my_data, p0 printf "Value = %d\n", [p0] cpy.p 42,[p0] printf "New value = %d\n", [p0] |
Value = 69 New value = 42 |
freegd
getgdconst
globaldata "<name>" [, <type>]
The created tool can be called to obtain a pointer to the global data.
If the type is GD_RW, the data can be read and written to. Each process will get its own copy of the global data. A type of GD_CONST on the other hand indicates that the data is read-only. The data will be shared by all processes. The type defaults to GD_RW.
The data is aligned on an 8 byte boundary. Any extra alignment you insert
with .align, for example, will be part of the data structure.
It is probably not a good idea to start a new data or code section within the
global data definition.
globaldata 'demo/gd/my_data' dc.i 69 dc.b 'This is a chunk of read/write global data',0 blk.b 256-42,0 globaldataend globaldata 'demo/gd/my_const_data', GD_CONST dc.d 3.141592654 dc.b 'This is a chunk of constant global data',0 globaldataend |
demo/gd/my_data which contains the given
read/write global data, and a tool called demo/gd/my_const_data
which contains the given constant global data.
globaldataend
globaldataend
globaldata
globaldata macro
globaldata macro
can be called to obtain a pointer to the global data (or a copy thereof,
depending on whether the global data is constant or not).
You probably want to use the getgdconst and getgdrw
macro instead of calling the tool directly.
qcall demo/gd/my_data, (0 : p0) printf "Value = %d\n", [p0] cpy.p 42,[p0] printf "New value = %d\n", [p0] qcall demo/gd/my_data, (1 : p~) |
Value = 69 New value = 42 |
globaldata
getgdconst
getgdrw