flat assembler
Message board for the users of flat assembler.
Index
> Windows > "struc" and "struct" |
Author |
|
cod3b453 01 May 2005, 00:32
I think struc defines the structure but struct actually creates the structure at compile time, so I end up writing:
struc POINT { .X dd ? .Y dd ? } struct POINT otherwise I get a compile error |
|||
01 May 2005, 00:32 |
|
Tomasz Grysztar 01 May 2005, 08:21
cod3b453: you're using the old "struct" macro, the newest packages support this kind of syntax:
Code: struct POINT .X dd ? .Y dd ? ends As for the wisepenguin's question: The "struc" directive defines the structure in a way that it defines a kind of macro, which can be then used to declare different instances of that structure. The "struct" (in its new version) is a macro which does the same, but defines also some additional values (like the absolute field offsets and structure size) for the convenience of programmer. It was made only to make it more like the structure definitions are in other assemblers, but it's only a macro (which uses internally the "struc" definition anyway), and it's not as flexible as the "struc" directive itself. If you understand how the "struc" works (and are not biased by other assemblers' approach), it's better for you to use the "struc" and take advantage of all capabilities it gives. In fact I personally don't recommend using the "struct" macro, even though it is used in official includes - but I've done it to satisfy the expectations of people used to structure implementations in assemblers like TASM and NASM. In my vision (based on which I have designed the "struc" mechanism for flat assembler) defining absolute structure offsets is a wrong choice and structure should be declared independently for its each appearance and usage - even when you've got dynamically allocated structure, you can do it with "virtual" directive, like: Code: virtual at ebx mystruc@ebx MYSTRUC end virtual Note that "struc" directive allows definitions of structures that have variable sizes and field offsets depending on instance, and perhaps depending on some additional parameters (you can define them with all the freedom you've got with macroinstructions in fasm) - this is where the idea of absolute offsets and size completely fails. I plan to write something more about it in the fifth section of my Design Principles article, which is not yet finished (even though officially published on this website). |
|||
01 May 2005, 08:21 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.