Intel IA-32 Assembly Tutorial
EFLAGS has binary flags that either control the CPU operation or reflect the outcome of a CPU operation. Some machine instructions test and manipulate the processor flags. When the result of an unsigned arithmetic operation is too large to fit into the destination, the CF (Carry Flag) is set. When the result of a signed arithmetic operation is too wide to fit into the destination, the OF (Overflow Flag) is set. When the result of an arithmetic or logical operation creates a negative result, the SF (Sign Flag) is set. When the result of an arithmetic or logical operation creates result of zero, the ZF (Zero Flag) is set. The Auxiliary Carry flag is set when an arithmetic operation causes a carry from bit 3 to bit 4 in an 8-bit operand. The Parity flag sums the number of bits that are set in a number determining whether the sum is odd or even.
Windows NT/2000/XP/Vista/7/8/8.1/10 run in protected mode. The segment registers (CS, DS, SS, ES, FS, GS) point to segment descriptor tables that the operating system uses to define the locations of individual program segments. A typical protected mode program has three segments: code, data and stack.
- CS refers to the descriptor table for the code segment
- DS refers to the descriptor table for the data segment
- SS refers to the descriptor table for the stack segment
The Assembly Language Elements
Reserved words can be:
- Instruction mnemonics like MOV, ADD, SUB, MUL, DIV.
- Directives which tell MASM how to assemble programs.
- Attributes which provide size and usage information for variables and operands: BYTE, WORD, DWORD
- Operators used in constant expressions
- Predefined symbols such as @data which return constant integer values at assembly time.
|'The dog said "Woof!"',0|
Notice that each string has a zero sentinal to terminate it.
An identifier is a programmer-created name. It may identify a constant, variable, procedure or code label. When creating identifiers, these rules apply:
- They are not case sensitive.
- Cannot be greater than 247 characters.
- The first character must be a letter, underscore (_), @, or $. Following characters may have numbers.
- Cannot be the same as a reserved word.
- DATA directive: .data (where global variables are defined)
- CODE directive: .code
- PROC directive: name PROC