flat assembler
Message board for the users of flat assembler.

Index > Main > local variables

Author
Thread Post new topic Reply to topic
Mentol



Joined: 08 Jun 2006
Posts: 7
Mentol 08 Jun 2006, 22:18
For example, MASM & TASM use this:
Code:
proc ...
LOCAL param1 db 0
...
endp    


and what i can do with FASM?
of cource, if can use:
Code:
proc1:
push ebp
mov ebp, esp
sub esp, 8
mov dword [ebp-4], 0x00 ; local var 1
mov dword [ebp-8], 0x01 ; local var 2
...
pop ebp
mov esp, ebp
retn
    

but i hope there is any ways to use "proc" definition and local vars in FASM?
Post 08 Jun 2006, 22:18
View user's profile Send private message Reply with quote
Mentol



Joined: 08 Jun 2006
Posts: 7
Mentol 08 Jun 2006, 22:20
and second question:
how i can setup ALIGN parameter (for EXE), to get size of EXE less that 2.048 bytes for example? (visual studio link.exe linker can parse /align:... parameter)

iam russian sorry for bad eng )
Post 08 Jun 2006, 22:20
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 08 Jun 2006, 22:58
Manual wrote:
To declare the local variable you can use the local macroinstruction, followed by one or more declarations separated with commas, each one consisting of the name for variable followed by colon and the type of variable – either one of the standard types (must be upper case) or the name of data structure. For example:

local hDC:DWORD,rc:RECT

To declare a local array, you can follow the name of variable by the size of array enclosed in square brackets, like:

local str[256]:BYTE

The other way to define the local variables is to declare them inside the block started with ”locals” macroinstruction and ended with ”endl”, in this case they can be defined just like regular data. This declaration is the equivalent of the earlier sample:

locals
hDC dd ?
rc RECT
endl

The local variables can be declared anywhere inside the procedure, with the only limitation that they have to be declared before they are used. The scope of labels for the variables defined as local is limited to inside the procedure, you can use the same names for other purposes outside the procedure. If you give some initialized values to the variables declared as local, the macroinstruction generates the instructions that will initialize these variables with the given values and puts these instruction at the same position in procedure, where the declaration is placed.

And the second question. Fasm doesn't allow changing that align value. MS Linker will create a file with it changed, but it won't execute. The only files with smaller align values (ie. smaller than the value which fasm defaults) can be drivers. Fasm puts a value which is the smallest possible for executables and dlls.
Post 08 Jun 2006, 22:58
View user's profile Send private message Visit poster's website Reply with quote
Quantum



Joined: 24 Jun 2005
Posts: 122
Quantum 09 Jun 2006, 02:11
Quote:

visual studio link.exe linker can parse /align:... parameter

You can compile your sources to MS COFF object format (luckily FASM supports MS COFF output) and then use link.exe to build the final exe, which won't run, as Reverend already explained.

A bit of additional info (from a Matt Pietrek's article):
Quote:

Unfortunately for Microsoft users, if you use /ALIGN, it sets both the in-memory section alignment and the on-disk alignment to the same value (such as 16 bytes). In Windows NT, an executable with 16-byte alignment can run, but you wouldn't want to do this for some low-level techie reasons. Alas, Windows 95 won't run an executable file with sections that aren't aligned on a boundary that's a multiple of 0x1000 bytes.


ЗЫ: А тут вообще много русских, кажется Smile
Post 09 Jun 2006, 02:11
View user's profile Send private message Reply with quote
Mentol



Joined: 08 Jun 2006
Posts: 7
Mentol 09 Jun 2006, 12:28
thanks

> ЗЫ: А тут вообще много русских, кажется
много)
Post 09 Jun 2006, 12:28
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav 09 Jun 2006, 16:37
как китайцев Smile
Post 09 Jun 2006, 16:37
View user's profile Send private message Reply with quote
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body 10 Jun 2006, 15:19
больше Smile
Post 10 Jun 2006, 15:19
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 10 Jun 2006, 19:01
For the MS linker, use /FILEALIGN instead of /ALIGN.
Post 10 Jun 2006, 19:01
View user's profile Send private message Visit poster's website 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.