Search code examples
assemblyx86masm32

Assembly coding with masm32


In assembly coding, working with masm32.

How can i put a value into a variable, that is not defiened at the .data segment, but by the LOCAL decleration?
thous:

.486                                    
.model flat, stdcall                    
option casemap :none                    

include \masm32\include\windows.inc     
include \masm32\macros\macros.asm       

include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib


.data  

.code  

start:  

call main  
exit  

main proc  

LOCAL dewit:DWORD

mov dewit, 0
print dewit  

ret  

main endp  

end start

I tried something like this:

Mov dewit, 0  

It didnt work. However, this code:

Mov dewit, input("enter a number")  

Did put a value into it.

Anybody?

** the LOCAL decleration can only be in a procedure


Solution

  • Since you are using MASM32 If you are trying to print out a 32-bit value try doing it this way with str$:

    print str$(dewit)
    

    This converts the 32-bit value at the memory location dewit into a string, and that string is printed on the console. This also work for an immediate value as well:

    print str$(100)
    

    And a register:

    print str$(eax)
    

    You can use $ustr as well if you wish to print the unsigned value.

    These macros are described in the High Level Macro help that comes with MASM32 SDK