flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Macro to simulate headers in structs |
Author |
|
beppe85 29 May 2005, 21:47
Hi. . .
I wanted a way to define a kind of headers in structs, which will be at the left of the pointer. To put it simple, some fields will have negative offsets. As I was not aware of a solution already, I extended the default struct to do so: Code: ; structure definition helper macro struct name { name@struct fix name normal@struct = 0 struc name { } macro struct_helper name { local ..name virtual at 0 ..name name end virtual normal.#name = normal@struct virtual at -normal@struct name name sizeof.#name = $ - name name equ sizeof.#name end virtual } ends fix } struct_helper name@struct macro normal { normal@struct = $ } Example of use: Code: struct MemoryBlock .sig dd ? .size dd ? .next dd ? normal .data rb 0 ends display '-', -MemoryBlock.size + '0' If you forget "normal", you'll get the good and old struct. If you repeat more times, just the last is valid. Hope it will be useful to someone else. []'s Beppe UPDATE: fixed normal when ommited. _________________ "I assemble, therefore I am" If you got some spare time, visit my blog: http://www.beppe.theblog.com.br/ and sign my guestmap Last edited by beppe85 on 03 Jun 2005, 03:24; edited 2 times in total |
|||
29 May 2005, 21:47 |
|
vid 29 May 2005, 21:59
nice, could be in standard package. I usually use such things once-twice per project
|
|||
29 May 2005, 21:59 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.