flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Use a struc on a label?

Author
Thread Post new topic Reply to topic
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Nov 2009, 14:35
How do I add the elements of a struc to a label that is already defined?

Like I can't do
Code:
label struc    
because it is already defined somewhere, so what do I do? I tried
Code:
virtual at label
label struc
end virtual    
But that doesn't work.. Sad


Please help

_________________
Post 24 Nov 2009, 14:35
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 24 Nov 2009, 14:43
Both 'label' and 'struc' are internal directives. You will experience a lot of trouble trying to define them as something else.
Post 24 Nov 2009, 14:43
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Nov 2009, 14:48
Sorry bad example.


Let's use "blaa1" and "blaa2" instead.



Any ideas how to make it work? Confused

_________________
Post 24 Nov 2009, 14:48
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 24 Nov 2009, 14:53
Show some code please. With the abstraction above is not clear what you want to achieve.
Post 24 Nov 2009, 14:53
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Nov 2009, 15:07
Code:
blaa1 = 12345678

struc blaa2{
.element1 dd ?
.element2 dd ?
}
virtual at blaa1
blaa1 blaa2
end virtual    




I want;

blaa1.element1 to be 12345678
blaa1.element2 to be 12345682

_________________
Post 24 Nov 2009, 15:07
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 24 Nov 2009, 15:22
This works for me:
Code:
blaa3 = 12345678

struc blaa2{
.element1 dd ?
.element2 dd ?
}
virtual at blaa3
blaa1 blaa2
end virtual    
But 'blaa1' cannot be both a structure name and a variable name at the same time.
Post 24 Nov 2009, 15:22
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Nov 2009, 15:26
Thanks.. is there a way to redefine it then?


Something like this?



Code:
blaa1 = 12345678 

struc blaa2{ 
.element1 dd ? 
.element2 dd ? 
} 
virtual at blaa1
local blaa3
blaa3 blaa2 
undefine blaa1
blaa1 = blaa3
end virtual    



I need to keep it the same name..

_________________
Post 24 Nov 2009, 15:26
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 24 Nov 2009, 15:31
fasm does not support undefine.

'restore', 'purge' and 'restruc' only work at the preprocessor stage so they won't help you at the assembler stage
Post 24 Nov 2009, 15:31
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Nov 2009, 15:41
Thank you.

Is there a way to make it do whatever blaa1+blaa2.element1 does? I don't know what you call it but that is what I want (but condensed)..

_________________
Post 24 Nov 2009, 15:41
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 24 Nov 2009, 15:49
You can always do it manually of course.
Code:
blaa1 = 12345678
label blaa1.element1 dword at blaa1
label blaa1.element2 dword at blaa1+4    
Post 24 Nov 2009, 15:49
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Nov 2009, 15:51
I mean automatically


Something like this

Code:
for each element in blaa2
blaa1#.elementName=blaa1+elementOffset
end for    


Please isn't there some way to have FASM do it? Confused
Post 24 Nov 2009, 15:51
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 24 Nov 2009, 15:57
I'm not really sure what you want.
Code:
struc x {
    .e1 dd ?
    .e2 dd ?
    if .
        end if
}

y=1234
virtual at y
      y x
end virtual    
Post 24 Nov 2009, 15:57
View user's profile Send private message Visit poster's website Reply with quote
Azu



Joined: 16 Dec 2008
Posts: 1159
Azu 24 Nov 2009, 16:14
Thank you

Putting
Code:
        if . 
        end if     
in the struc made it work Very Happy


I don't understand though.. why does it fix it? It's an empty statement.. it shouldn't do anything should it? Unless I had "if used y" or something.. but I don't.. so I'm really confused. Why does it work? o.0



p.s.

Why aren't strucs like this by default? Is there a drawback in certain situations?

_________________
Post 24 Nov 2009, 16:14
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20356
Location: In your JS exploiting you and your system
revolution 24 Nov 2009, 16:22
Using 'if .' is a side effect that exploits the structure processing. When fasm detects that you used '.' it won't automatically assign it and assumes you will assign it in your own way. So using the '.' in an empty construct stops fasm from defining it.
Post 24 Nov 2009, 16:22
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Nov 2009, 16:23
nice trick Smile
Post 24 Nov 2009, 16:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.