Author Topic: Getting offset of %local or %arg variables using 1-line command  (Read 17812 times)

Offline rdtsc

  • Jr. Member
  • *
  • Posts: 6
Getting offset of %local or %arg variables using 1-line command
« 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.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Getting offset of %local or %arg variables using 1-line command
« Reply #1 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


Offline rdtsc

  • Jr. Member
  • *
  • Posts: 6
Re: Getting offset of %local or %arg variables using 1-line command
« Reply #2 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
« Last Edit: January 23, 2011, 02:05:46 PM by rdtsc »