MASM_LOCAL variable

  • Follow


Hi All,

    How to declare LOCAL variable inside a PROCEDURE And that variable
can assign to specific register during declaration time.


Some thing equivalent to.....
$My    equ        eax
But this is referring to global variable. 


Thanks 
Debadeepti Sahu

0
Reply spamtrap2 (1628) 7/1/2005 8:04:54 AM

Before you write ANY runtime code within the procedure, you use this
syntax.

MyProc arg1:DWORD,arg2:DWORD etc ...

    LOCAL varname  :DATASIZE

Examples,

    LOCAL var  :DWORD    ; single 32 bit variable
    LOCAL buf[260]:BYTE  ; 260 byte buffer
    LOCAL rct  :RECT     ; rectangle structure

With LOCALs in MASM the data is uninitialised like normal.

Regards,

hutch at movsd dot com

0
Reply hutch 7/1/2005 6:05:52 PM



spamtrap@crayne.org wrote:
> Hi All,
>
>     How to declare LOCAL variable inside a PROCEDURE And that variable
> can assign to specific register during declaration time.
>
>
> Some thing equivalent to.....
> $My    equ        eax
> But this is referring to global variable.
>
>
> Thanks
> Debadeepti Sahu

AFAIK, there is no way to make an equate local to a procedure in MASM.
You may, of course, create automatic variables (allocated on the stack)
whose names are local to the procedure (using the LOCAL directive), but
this is different from what you're asking.

You *could* switch to HLA (the High-Level Assembler) which provides
scoping for all named objects within a procedure, then you could write
something like this:

procedure proc;
const MyReg :text := "eax";
  .
  .
  .
 mov( 0, MyReg ); // equivalent to "mov( 0, eax);"
  .
  .
  .
Cheers,
Randy Hyde
P.S., you can find out about HLA at http://webster.cs.ucr.edu

0
Reply randyhyde 7/2/2005 12:17:53 AM

2 Replies
263 Views

(page loaded in 0.047 seconds)


Reply: