flat assembler
Message board for the users of flat assembler.

Index > Main > fasm support for local variables???

Author
Thread Post new topic Reply to topic
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
Does fasm have support for declaring local variables like the local directive with masm? If fasm doesn't have a similiar feature I would like to know if its possible to implement it with macros. I would like to be able to declare local variables and structures and access the structure members by the member names. Any help would be appreciated.

_________________
silkodyssey
Post 14 Oct 2003, 22:08
View user's profile Send private message MSN Messenger Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Dunduk
silkodyssey wrote:
Does fasm have support for declaring local variables like the local directive with masm? If fasm doesn't have a similiar feature I would like to know if its possible to implement it with macros. I would like to be able to declare local variables and structures and access the structure members by the member names. Any help would be appreciated.

Sure, fasm has it. Example:
Code:
proc some_proc, var1,var2,...
.localvar1 db ?
.localvar2 dd ?
.localvar3 SOME_STRUCTURE
enter
...
lea eax, [.localvar3]
...
mov [.localvar3.some_strusture_member], 0
...
mov [.localvar1], 0ffh
...
return
    

Proc, enter, return - are macroses. See include in fasmw package.
Did I answer your question?
Post 15 Oct 2003, 02:32
View user's profile Send private message Reply with quote
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
Thanks a lot Dunduk. I think you answered my question and I'm happy with the answer Smile .

_________________
silkodyssey
Post 15 Oct 2003, 10:41
View user's profile Send private message MSN Messenger Reply with quote
Beginner



Joined: 08 Oct 2003
Posts: 1
Location: Germany
Beginner
Hi,
can someone tell me, please, why this code doesn't work?
Code:
include '%include%\win32ax.inc'
.data
        GlobalString db 'Global',0
.code
        proc Put,arg
        .LocalString db 'Local',0
        enter

               invoke MessageBox,0,.LocalString,GlobalString,0
        return

        start:

                stdcall Put,0
                invoke ExitProcess,0
.end start
    
Post 15 Oct 2003, 16:28
View user's profile Send private message Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
Proably a mistake is here:
Code:
proc Put,arg
        .LocalString db 'Local',0
        enter    

AFAIK you can't declare a local variable and put some value there as you can do with globals. You need to put the string to your variable in run-time, ie. add some code that sets .LocalString to proper value. And your declaration should look like:
Code:
.LocalString rb 6    
Post 15 Oct 2003, 16:36
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7796
Location: Kraków, Poland
Tomasz Grysztar
Local variables are not initialized to any predefined values, even when you specify them.
Post 15 Oct 2003, 16:36
View user's profile Send private message Visit poster's website Reply with quote
eet_1024



Joined: 22 Jul 2003
Posts: 59
eet_1024
Locals are allocated into the stack when the function is called. Runtime code is required to initialize them. It is your responsibility for writing that code.
Post 17 Oct 2003, 19:27
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.