Basic Program Execution Registers

General Purpose:

32 bit		16 bit		8-bit (High)		8-bit (Low)
EAX		AX		AH			AL
EBX		BX		BH			BL
ECX		CX		CH			CL
EDX		DX		DH			DL

ESI		SI
EDI		DI
EBP		BP
ESP		SP

- EAX used automatically by multiplication and division
- ECX is loop counter
- ESP addresses data on the stack
- ESI and EDI used for high speed memory transfer instructions
- EBP used by high level languages to reference function parameters and local variables on stack.

EIP: Instruction Pointer.  Contains address of next instruction to be executed.

EFLAGS: Control and Status Flags
	Carry (CF) - Unsigned arithmetic operation too large for destination
	Overflow (OF) - Signed arithmetic operation too large or small for destination
	Sign (SF) - Negative result of arithmetic or logical operation
	Zero (ZF) - Arithmetic or logical operation returns 0
	Auxiliary Carry (AC) - Carry from bit 3 to 4 of 8 bit operand
	Parity (PF) - Set if least significant byte is even number of 1 bits
	
Floating-Point Unit Registers:

	80-bit Data Registers: ST(0-7), Opcode Register
	48 bit Pointer Registers: FPU Instruction Pointer, FPU Data Pointer
	16 bit Control Registers: Tag Register, Control Register, Status Register

Directives

.data: Identifies area of program containing variables
.code: Area of program for executable instructions
.stack: Area of program for runtime stack, sets size 

Data Types
BYTE: 8-bit unsigned integer
SBYTE: 8-bit signed integer.
WORD: 16-bit unsigned integer
SWORD: 16-bit signed integer
DWORD: 32-bit unsigned integer
SDWORD: 32-bit signed integer
FWORD: 48-bit integer
QWORD: 64-bit integer
TBYTE: 80-bit integer
REAL4: 32-bit IEEE short real
REAL8: 64-bit IEEE long real
REAL10: 80 bit IEEE extended real

DB: 8 bit integer
DW: 16-bit integer
DD: 32-bit integer or real
DQ: 64-bit integer or real
DT: define 80-bit integer

MOV:
MOV destination, source

- Both operands must be same size
- Both operands cannot be memory operands
- CS, EIP, and IP cannot be destination operands
- Immediate value cannot be moved to a segment register
- Cannot be used to move from one memory location to another.  A register must be used beforehand.  

Valid:
	MOV reg, reg
	MOV, mem, reg
	MOV reg, mem
	MOV mem, imm
	MOV reg, imm

Indirect Addressing
- Register is used as a pointer
- This is used for constant offsets in accessing array elements

Protected:
.data
byteVal BYTE 10h
.code
mov esi, OFFSET byteVal
mov al,[esi] ; AL = 10h

Real Address:
.data
byteVal BYTE 10h
.code
main PROC
	startup
	mov si, OFFSET byteVal
	mov al, [si] ; AL = 10h

Indexed: 
	- Adds constant to a register to generate an effective address:
		constant[reg]
		[constant + reg]

Pointer:

arrayB	BYTE 		10h…
arrayW 	WORD 	1000h…
ptrB		DWORD 	arrayB
ptrW		DWORD 	arrayW

Loops:

LOOP destination

- ECX sets the loop counter and decrements every time loop repeats
- Don't modify ECX in a loop
- When writing nested loops, ECX must be saved elsewhere temporarily