flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
ouadji 13 Oct 2010, 18:30
Code: struct mystruct .yop_1 dd ? ; <--- with dot .yop_2 dd ? ends What would be the use and meaning of this ? thank you all ![]() |
|||
![]() |
|
baldr 14 Oct 2010, 18:27
ouadji,
Of course one can. Nothing special though: .yop_1 is a valid field name (its size will be sizeof.mystruct..yop_1, for example). |
|||
![]() |
|
baldr 15 Oct 2010, 07:12
ouadji,
To have local label be defined inside struc-macro you'll need to protect leading dot with backslash(es). With struct / ends macroinstructions it's different: current implementation encloses structure body in virtual at 0 directive and collects individual data definitions/reservations in symbolic constant. Labels (as you may expect) are not handled, so they are defined inside that virtual block instead of at macro expansion. |
|||
![]() |
|
ouadji 15 Oct 2010, 09:38
Quote:
ok. it's possible with "struc", but not with "struct". about "struC + local label", please, could you give me an example. (thank you baldr for your replies and your help) |
|||
![]() |
|
revolution 15 Oct 2010, 09:46
Code: struc point { \.localLabel: .x dw ? .y dw ? } abc point jmp abc.localLabel |
|||
![]() |
|
Tomasz Grysztar 15 Oct 2010, 09:50
Code: struc mystruc { .yop_1 dd ? .yop_2 dd ? } first: .local_struc mystruc ; all fields get local labels second: .local_struc mystruc mov eax,[.local_struc.yop_2] ; from second mov eax,[first.local_struc.yop_2] ; from first ![]() |
|||
![]() |
|
ouadji 15 Oct 2010, 10:10
Code: ;and this ? (I guess not) struc point { \.x dw ? .y dw ? } abc point mov eax,dword[abc.x] ;abc.x == local label ??? |
|||
![]() |
|
Tomasz Grysztar 15 Oct 2010, 10:20
Yes, in this case it will work just as it works in revolution's example - however it doesn't really make much sense to do it. You just move the moment at which "abc" is prepended to the ".x" label from preprocessor into parser - but this doesn't really affect the result. In both cases you have "abc.x" label in the end. To get any noticeable difference between the backslashed and non-backslashed one you would need a more sophisticated example.
Last edited by Tomasz Grysztar on 15 Oct 2010, 10:22; edited 2 times in total |
|||
![]() |
|
revolution 15 Oct 2010, 10:20
Code: struc point { \.localLabel: \.x dw ? \.y dw ? } func1 point jmp .localLabel mov eax,dword[.x] func2: jmp func1.localLabel mov eax,dword[func1.x] |
|||
![]() |
|
ouadji 15 Oct 2010, 10:33
Code: ;Can I write this in all cases: (??) struc AA { .a dw ? .b: \.c: \.d dw ? ;db, dd, dw, ..... } BB AA BB.a ; global BB.b ; global BB.c ; local BB.d ; local ;without "\" before == always global ? ;with "\" before == always local ? |
|||
![]() |
|
baldr 15 Oct 2010, 23:02
ouadji,
Due to the way struc-macro expands, those local labels get slightly longer full names than you're expecting: BB.b.c and BB.b.d. ----8<---- Tomasz Grysztar wrote: I hope he is going to provide some example aswell. ![]() |
|||
![]() |
|
ouadji 15 Oct 2010, 23:38
This is not a big problem. I have a recursive function which parses very well this kind of case. but you did not answer my question: (thank you) Code: struc AA { .a dw ? .b: \.c: \.d dw ? ;db, dd, dw, ..... } BB AA BB.a ; global BB.b ; global BB.c ; local BB.d ; local (can I write this in all cases) within a "struc" definition : A) without "\" before == always global ? B) with "\" before == always local ? |
|||
![]() |
|
revolution 16 Oct 2010, 00:30
ouadji: If you manually expand the struc macro then you will see what happens.
BB AA expands to: Code: BB.a dw ? ;<--- a global label BB.b: ;<--- a new global label .c: ;<--- it is local to the previous global label, i.e. it is BB.b.c .d dw ? ;<--- BB.b.d |
|||
![]() |
|
revolution 16 Oct 2010, 00:38
So if you want to make the labels BB.c and BB.d then change the struc:
Code: struc AA { .a dw ? .b: .#c: .#d dw ? } BB AA Code: struc AA { .a dw ? .b: .c: .d dw ? } BB AA |
|||
![]() |
|
bitRAKE 16 Oct 2010, 01:57
All labels are global, the dot scheme just allows shortcuts to be used:
Code: XX.abc dw 5 XX: mov ax,[.abc] |
|||
![]() |
|
revolution 16 Oct 2010, 03:03
bitRAKE wrote: All labels are global, the dot scheme just allows shortcuts to be used: Consider: Code: XX: ;global. Changes the base name to XX .bcd dw 1 ;.bcd as local. XX.bcd as global XX.abc dw 2 ;global. Changes the base name to XX.abc .bcd dw 3 ;.bcd as local. XX.abc.bcd as global |
|||
![]() |
|
baldr 16 Oct 2010, 09:53
ouadji,
Is this question related to Wink development? I'm asking just to be sure I'm not taking the wrong route: in general case you should preprocess/interpret source to be sure what does symbol exactly mean. Code: macro A.c x { struc b \{ x \} } struc a { .b db 1 .c db 2 .d db 3 } A a B b C a |
|||
![]() |
|
ouadji 16 Oct 2010, 10:01
Quote: The difference being the local labels do not change the base global label name for the next local label. just for the fun, ![]() Code: struc AA1 { .x: \.y: } .BB1 AA1 jmp .BB1.x.y ;does not compile ;is ".BB1.x.y" unattainable ? ;--------------------------------------------- struc AA1 { .x: \.y: } BB1 AA1 jmp BB1.x.y ;does compile Tomasz,when will we have a true doc about macros ? Why this must remain the gods secret !! (thank you) |
|||
![]() |
|
ouadji 16 Oct 2010, 10:09
Quote: Is this question related to Wink development ? Code: macro A.c x { struc b \{ x \} } struc a { .b db 1 .c db 2 .d db 3 } A a B b C a ![]() ![]() I will never have the time to parse this kind of complex case in real time. Quote: in general case you should preprocess/interpret source to be sure what does symbol exactly mean. I have only the time between two keystrokes on the keyboard, (repeat keystrokes ... 0,1 sec... max 0,2 sec!) I don't have time to do what I want. ![]() I have to make choices, it's inescapable ! |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.