MASM32

32-bit assembler

2026-01-16

Written by: xiaobin

After downloading v11r, install it using administrator.

Create an empty console application (VC++) and set it up.

project Set

masm(.targets, .props)
Entry Point: main
C:\masm32\lib;

program

new file “test1.asm” right click “properties” choice “Microsoft Macro Assembler”

Project -> Add New Item

Add New Item

Microsoft Macro Assembler -> General -> Include Paths

C:\masm32\include;

code

test1.asm

.686
.MODEL  flat, c

includelib ucrt.lib                            ; VS2015+ Usage
includelib legacy_stdio_definitions.lib        ; VS2015+ Usage
;includelib  \masm32\lib\msvcrt.lib            ; VS2013- Usage

;Function prototypes 
printf  proto arg1:ptr byte, printlist:vararg

.data
msg1fmt byte "%s%d",0Ah,0
msg1    byte "y: ",0
x       sdword ?
y       sdword ?

.code
        align 4
        
main    PROC
        mov eax, 3h
        mov x, eax
        ;;y = 2 + 3
        ;add eax, 2h
        ;;y = 3 - 2
        sub eax, 2h
        mov y, eax

        invoke printf, ADDR msg1fmt, ADDR msg1, y
        ret
main    ENDP

end ;program end

Ref