News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

local constant

Started by korte, April 04, 2009, 03:28:42 PM

Previous topic - Next topic

korte

how to define local constant?

Myproc proc
cursorPos textequ <ebx>  <= not local!!!
.
.
  inc cursorPos
.
.
.
Myproc endp

peaslee

MyProc proc var1:DWORD,...

LOCAL cursorPos:DWORD    ; or whatever type

...

MyProc endp
Bruce Peaslee
"Reality is a crutch for those who can't do drugs."

korte

I would like to solve it by a register, faster...

Vortex

korte,

This one should work :

main PROC

    param TEXTEQU <eax>

    add     param,1
    ret

    param TEXTEQU <>

main ENDP


The statement  param TEXTEQU <> destroys param at the end of the subroutine.

donkey

Scoping is much more effective and powerful in GoAsm...

QuoteWithin a FRAME..ENDF envelope you can use locally defined words. The definition can be made either in the FRAME..ENDF envelope itself or in an associated USEDATA..ENDU area.
Their scope is limited to the FRAME or USEDATA area. See inheritance and scope when using USEDATA..ENDU for more details about how this works in practice.
You define such local words using #localdef (or LOCALEQU if you prefer - they do the same thing).

Main FRAME
    #LOCALDEF Count ebx
    MyLocalConst LOCALEQU 0x1000

    mov Count, MyLocalConst

ENDF
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable