flat assembler
Message board for the users of flat assembler.
Index
> Main > Please!! sizeof.(structure) implement directly into Fasm!! |
Author |
|
pelaillo 23 Aug 2004, 12:38
Hi Dragontamer,
the macros are flexible, for example, I never use sizeof.thing but instead the form thing.size that I find nicer. In order to start a debating, it would be interesting to have examples for limitations of struct macro in order to solve (if possible) each one of them. |
|||
23 Aug 2004, 12:38 |
|
Dragontamer 23 Aug 2004, 13:02
Ok, then how to allocate memory on the stack? Or how to allocate memory from malloc call?
sizeof.point is much cleaner than mypoint.size Especially if there aren't any handy points around to steal size from. For example: I wish to do: Code: function: push ebp mov ebp, esp sub esp, (amount of space to allocate) virtual at esp point1 point x dd ? y dd ? end virtual ;function mov esp, ebp pop ebp ret Or a better example Code: push sizeof.point call malloc add esp, 4 True, i can just do push mypoint.size, however, it makes more sense to do sizeof.point IMO. |
|||
23 Aug 2004, 13:02 |
|
Tomasz Grysztar 23 Aug 2004, 13:14
This is the flexibility of structure macros that disallows the "sizeof"-like features to be build in. Suppose you have such structure:
Code: struc mystruct string,cptrs { .String db string,0 .Pointers rd cptrs } What would the sizeof.mystruct mean, then? You can try to adapt "struct" macro for the structures with parameters, but you still have to allow the structure to accept empty parameters for it to work: Code: macro struct [def] { common struc def { } macro struct_helper name { virtual at 0 name name sizeof.#name = $ - name name equ sizeof.#name end virtual } ends fix } struct_helper struct point x,y .x dd x+0 .y dd y+0 ends point push sizeof.point There are also other, much more complex macro solutions. Last edited by Tomasz Grysztar on 12 Jun 2005, 09:33; edited 1 time in total |
|||
23 Aug 2004, 13:14 |
|
Dragontamer 23 Aug 2004, 13:22
Well, that makes sense...
I guess i'll just have to settle with doing mypoint.size for now. |
|||
23 Aug 2004, 13:22 |
|
pelaillo 23 Aug 2004, 18:24
Dragontamer wrote: I guess i'll just have to settle with doing mypoint.size for now. Or sizeof.point if you prefer. That's the standard way as Privalov have indicated. |
|||
23 Aug 2004, 18:24 |
|
vid 23 Aug 2004, 20:13
dragontamer: keep in mind "struc" is same as "macro", only with all names starting with "." character prepended by structure name. It is not like HLL strucgture definition.
|
|||
23 Aug 2004, 20:13 |
|
fasm9 24 Aug 2004, 03:14
HLL structure means "compiler",
While assembler is assembler. parsing, more-higher-abstraction, bison, flex, RTL(reigster transfer language), treecc, BNF, machine code generation, microcode, regex.. so means not only "sugar-syntax". -- PS: *_< at least, In my short knowledge. |
|||
24 Aug 2004, 03:14 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.