X86 Assembly/MASM Syntax

From Wikibooks, open books for an open world
Jump to: navigation, search

This page will explain x86 Programming using MASM syntax, and will also discuss how to use the macro capabilities of MASM. Other assemblers, such as NASM and FASM, use syntax different from MASM, similar only in that they all use Intel syntax.

Instruction Order[edit]

MASM instructions typically have operands reversed from GAS instructions. for instance, instructions are typically written as Instruction Destination, Source.

The mov instruction, written as follows:

mov al, 05h

will move the value 5 into the al register.

Instruction Suffixes[edit]

MASM does not use instruction suffixes to differentiate between sizes (byte, word, dword, etc).


MASM is known as either the "Macro Assembler", or the "Microsoft Assembler", depending on who you talk to. But no matter where your answers are coming from, the fact is that MASM has a powerful macro engine, and a number of built-in macros available immediately.

MASM directives[edit]

MASM has a large number of directives that can control certain settings and behaviors. It has more of them compared to NASM or FASM, for example.