News:

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

PUSHAD / local vars

Started by Mark Jones, March 01, 2005, 10:42:06 PM

Previous topic - Next topic

Mark Jones

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.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Relvinian

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

Mark Jones

"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08