NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: rdtsc on January 22, 2011, 06:31:00 PM

Title: Getting offset of %local or %arg variables using 1-line command
Post by: rdtsc on January 22, 2011, 06:31:00 PM
Hello, dear NASM creators and others!

I have a problem.

How i can simply get offset of %LOCAL or %ARG vars in my FUNCTION ?
For example,

Code: [Select]
Proc:
  %args var:dword
 push var ; THIS DOES NOT WORK!!! I need offset...of var
  ..........
 ret

I don't want to use
Code: [Select]
lea eax,[var]
push eax

I want to use (may be with some modifiers/directives)  1-line command, such as

Code: [Select]
push var ; where var is in %local or %arg

Thx.
Title: Re: Getting offset of %local or %arg variables using 1-line command
Post by: Frank Kotler on January 22, 2011, 08:35:33 PM
Good luck with that. "Local" variables and passed "args" don't have an "offset". Why don't you want to use "lea"? That's what it's for!

Best,
Frank

Title: Re: Getting offset of %local or %arg variables using 1-line command
Post by: rdtsc on January 23, 2011, 01:43:22 PM
Good luck with that. "Local" variables and passed "args" don't have an "offset". Why don't you want to use "lea"? That's what it's for!

Best,
Frank


Well, of course ,my quest is stupid... [ebp+0x??] itself dosen't have an offset,when used in "mov reg,local"..lea is exit.
But how cool when i can "push var" - push offset for usual vars...I tryed to find a way for locals to do the same thing (pushing offset on stack)..
Will use lea.

Or next macros may be work ok

Code: [Select]
%macro PUSHL 1
push eax
lea eax,%1
xchg eax,dword [esp]
%endmacro