Microsoft Macro Assembler


The Microsoft Macro Assembler (MASM) is an x86 assembler that uses the Intel syntax for MS-DOS and Microsoft Windows. Beginning with MASM 8.0, there are two versions of the assembler: One for 16-bit & 32-bit assembly sources, and another (ML64) for 64-bit sources only.

Program

public _start

_text segment
    _start:
        push    rcx
        sub     rsp, 20h

        add     rsp, 20h
        pop     rcx
        xor     edx, edx
        mov     eax, 2ch
        syscall
        ret
_text ends

end
ml64 program.asm
link /ENTRY:_start /SUBSYSTEM:windows program.obj

BSS Segment

The BSS segment contains uninitialized static data, both variables and constants, i.e. global variables and local static variables that are initialized to zero or do not have explicit initialization in source code.

_bss segment
    foo dword 0
    bar qword 0
_bss ends

DATA Segment

The data segment contains initialized static variables, that is, global variables and static local variables. The data segment is read/write, since the values of variables can be altered at run time.

_data segment
_data ends