News:

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

Is this documented somewhere?

Started by glburt, October 12, 2007, 03:12:05 PM

Previous topic - Next topic

glburt

I am using masm32 in a course I teach.  In the file

\masm32\examples\exampl11\fileio\ppfileio.asm

I see two things I can not find documented anywhere and would like to know more about them.

    sas txt,"Test String"                       ; assign string to local variable

    .if rv(exist,"testfile.txt") != 0           ; if file already exists

I can not find the sas or rv explained anywhere, can you point me to the right direction?

Thanks.

Gary

ramguru

Download macro.zip From_here
P.S. I hate redirecting lazy users from post to post

Vortex

glburt,

Did you check the \masm32\macros folder?

glburt

I checked everything in the help that comes with MASM32, and the new masmlib (I like the new look!), but it was in none of those places.
Thanks for the help.
Gary

MichaelW

In \masm32\help\hlhelp.hlp, sas is under Pseudo Mnemonics and rv under Code Calling Macros.
eschew obfuscation

glburt

Thanks for the info!!!! 

Apparently LOCAL also cleans up the stack when you leave the proc?

Gary

evlncrn8

local uses the ebp frame...
'cleaning the stack' - no it doesnt do that
'balancing the stack'.. yup it does that...

hutch--

gary,

the LOCAL operative in MASM does no more than assign a name to an address on the stack. Stack memory is already allocated when the EXE starts so all that has to be done to use it is to have a predictable scheme to use it.

With a normal procedure that has a stack frame the arguments passed to the procedure are on the stack from the address [ebp+8] upwards. LOCAL variables are below the EBP address and have addresses like [ebp-4], [ebp-8] etc .....

With the normal calling convention in Windows (STDCALL) the procedure also balances the stack on exit. MASM normally terminates the stack frame wih the single instruction LEAVE which works fine but the stack is balanced by the version of RET that is used. When you have a procedure that takes 3 DWORD arguments (3 * 4 = 12 bytes) on the exit end you have "RET 12" which restores the stack to its original location after the proc has ended.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mark Jones

Also note that LOCALS are not initialized to zero when used, since a local is simply a pointer to a stack position -- you must zero their contents manually as needed. They will often contain spurious values from other APIs or functions in the app, and can cause obscure bugs if not known.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08