The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Mark Jones on March 01, 2005, 10:42:06 PM

Title: PUSHAD / local vars
Post by: Mark Jones on March 01, 2005, 10:42:06 PM
Hopefully another simple question. :toothy  When this is run, the local vars "toggle" and "once" are not zero and the compare jumps when it should not. Is the PushAD causing this, or are local vars not always preset to 0?


LowLevelFun Proc Private lpDest:DWORD, lpSource:DWORD
    LOCAL toggle:BYTE
    LOCAL once:BYTE

    PushAD                 ; save regs
    Xor Ecx, Ecx
    Xor Edx, Edx
    Xor Esi, Esi           ; es,fs,gs = 386+ spare regs but cannot use, si/di instead
    Mov Eax, lpSource      ; get handle of source string into eax
    Mov Ebx, lpDest        ; handle for destination string in ebx
startit:
    cmp toggle,0           ; which thing are we doing?
    jnz do2ndthing         ; we're doing the second thing

; else do first thing here

do2ndthing:
; do second thing, etc.
Title: Re: PUSHAD / local vars
Post by: Relvinian on March 01, 2005, 10:50:55 PM
Mark,

Any variables you define on the stack "inherit" the value on the stack where the variable is located. Basically, you should consider stack/local variables unitialized at define time. If you want them to be a certain value, set them to that.

Relvinian
Title: Re: PUSHAD / local vars
Post by: Mark Jones on March 01, 2005, 11:28:38 PM
Good to know, thanks!  :U