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
Download macro.zip From_here (http://www.masm32.com/board/index.php?topic=8002.new#new)
P.S. I hate redirecting lazy users from post to post
glburt,
Did you check the \masm32\macros folder?
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
In \masm32\help\hlhelp.hlp, sas is under Pseudo Mnemonics and rv under Code Calling Macros.
Thanks for the info!!!!
Apparently LOCAL also cleans up the stack when you leave the proc?
Gary
local uses the ebp frame...
'cleaning the stack' - no it doesnt do that
'balancing the stack'.. yup it does that...
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.
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.