Reputation: 634
I need help understanding MASM32 LOCAL Macro. I know the LOCAL variables are push to the stack. However, I'm trying to use them to store a temporary value. Here is a quick snippet.
FormatError PROC USES EBX ECX
LOCAL NumComma:DWORD, NumPeriod:DWORD
. . .
.WHILE ecx < eax
mov bl, [edx + ecx]
.IF bl == ","
inc [NumComma]
.ELSEIF bl == "."
inc [NumPeriod]
.ENDIF
inc ecx
.ENDW
mov ebx, [NumComma]
mov ecx, [NumPeriod]
EBX = 004059B5h ECX = 7EFDE000h
There are not 4,217,269(004059B5h) Commas. And there are not 2,130,567,168(7EFDE000h) Periods... They both don't seem to be addresses holding any value... Really lost on how to inc Local variables.
Side Note: Kinda new to programming Assembly...
Upvotes: 1
Views: 8809
Reputation: 22074
A local (stack) variable mus tbe initialized if you intend to use it. So you should do somehting like this:
xor eax, eax
mov NumPeriod, eax
mov NumComma, eax
If you are using variables from the BSS
or DATA
segment, they are preinitialized, but stack variables have the values whatever happens to be on the stack, when the function is called.
Upvotes: 2