News:

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

Are local frame variables zero ?

Started by BlackVortex, February 26, 2010, 09:02:02 AM

Previous topic - Next topic

BlackVortex

As the topic says, when I use for example :
MyFunction FRAME Input1
USES EBX,ESI,EDI
LOCALS Var1


Is Var1 always zero, or do I have to zero it myself ? I hope I don't sound stupid, I'm kinda tired etc  :toothy

BogdanOntanu

You have to zero it yourself.

Locals are usually implemented as stack locations and because of this they can contain garbage from stack's previouse contents.
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

BlackVortex


donkey

Hi BlackVortex,

If you include macros.h you can call ClearLocals in your stack frame and it will clear all local variables to zero. For example:

MyFunction FRAME SomeParam
    uses edi,esi,ebx
    LOCAL LOC1,LOC2,LOC3
    ClearLocals
    ....
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

BlackVortex

Hmm, sounds useful, gonna try it tomorrow and check the resulting assembly.