flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Expcn
How to define unions and named substructures?
struct BAR field_1 dd ? struct TAIL field_2 dd ? field_2b db ? ends ends |
|||
![]() |
|
Madis731
like:
Code: struct TAIL field_2 dd ? field_2b db ? ends struct BAR field_1 dd ? tail TAIL ends Or you need something fancier ![]() |
|||
![]() |
|
Expcn
How i do this:
Code:
;file1.inc
struct TAIL
field_1 dw ?
field_2 dd ?
field_3 dd ?
ends
struct BAR
field_1 dd ?
struct TAIL
field_2 dd ?
field_2b db ?
ends
ends
|
|||
![]() |
|
Expcn
You not understand my questions, look this:
how to define structure BAR, without extern definition structure tail, that is structure tail must be valid only within structure BAR, to avoid conflicts with others same names, because substructures that has name tail, can be present in others structures, but with different fields Code: struct BAR field_1 dd ? struct tail field_2 dd ? field_2b db ? ends ends struct BAR2 field_a dd ? field_b dd ? struct tail field_5 dd ? field_6 dd ? field_7 dw ? field_8 db ? ends ends bar BAR bar2 BAR2 mov eax,[bar.tail.field_2] mov cx,[bar2.tail.field_7] |
|||
![]() |
|
Tomasz Grysztar
Isn't it just:
Code: struct __tmp1 field_2 dd ? field_2b db ? ends struct BAR field_1 dd ? tail __tmp1 ends struct __tmp2 field_5 dd ? field_6 dd ? field_7 dw ? field_8 db ? ends struct BAR2 field_a dd ? field_b dd ? tail __tmp2 ends bar BAR bar2 BAR2 mov eax,[bar.tail.field_2] mov cx,[bar2.tail.field_7] ? |
|||
![]() |
|
RedGhost
he wan'ts to define a union or 'substructure' which can only be accessed from within the structure e.g.
Code: struct BAR union TAIL endu ends abc TAIL ;ERROR: TAIL is only valid within BAR unless redefined as an external version he wants this so BAR.TAIL.a is not the same as BAR2.TAIL.a when the union TAIL in BAR2 is different than that of BAR |
|||
![]() |
|
Tomasz Grysztar
But the name of substructure, which is in fact an instance is not the same as the name of the structure, which is just a type. As in my example, you can define type named "__tmp1" and then define the instance of "__tmp1" structure, named "TAIL" - this does not imply that you have a type named "TAIL".
|
|||
![]() |
|
Expcn
Tomasz Grysztar, its right! but little problem still exist, that is bad code readability, because with such structure definitions, i can't see substructures fields in structures where its declared, i'm must find definitions outside structures.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.