Operand Description ------- ----------- r8 8-bit general purpose register [GPR] (AH, AL, ... DH, DL) r16 16-bit GPR (AX, BX, CX, DX, SI, DI, SP, BP) r32 32-bit GPR (EAX, EBX, ECX, EDX, ESI, EDI, ESP, EBP) reg any GPR sreg 16-bit seg reg (CS, DS, SS, ES, FS, GS) imm any immediate value of 8, 16, or 32-bits imm8 imm16 imm32 r/m8 8-bit register or memory byte r/m16 r/m32 mem a memory operand of size 8, 16, or 32-bits
Remember, the IA-32 Processor can address 1MB of memory in Real Mode and 4 GB in Protected Mode. We will assume Real Mode unless otherwise stated.
.data val1 BYTE 5hIf val1 was located at address 1400h, then an assembled instruction would look something like:
mov al,[1400](i1) MOV dest, src
MOV places the contents of the src operand into the destination location.
(i2) MOVZX dest, src
Q#1: What does it mean to zero extend a value?
Q#2: Why would we use an instruction that zero extends a value? HINT: Think about unsigned vs 2's complement numbers?
(i3) MOVSX dest, src
Q#3: What does it mean to sign extend a value?
(i4) LAHF ; load the low byte of the flags register into AH
(i5) SAHF ; store the value of AH into low byte of the flags register
(i6) XCHG op1, op2
Let's examine the file Moves.asm from
TITLE Data Transfer Examples (Moves.asm) ; Chapter 4 example. Demonstration of MOV and ; XCHG with direct and direct-offset operands. ; Last update: 2/1/02 INCLUDE Irvine16.inc .data val1 WORD 1000h val2 WORD 2000h arrayB BYTE 10h,20h,30h,40h,50h arrayW WORD 100h,200h,300h arrayD DWORD 10000h,20000h .code main PROC ; MOVZX mov bx,0A69Bh movzx eax,bx ; EAX = 0000A69Bh movzx edx,bl ; EDX = 0000009Bh movzx cx,bl ; CX = 009Bh ; MOVSX mov bx,0A69Bh movsx eax,bx ; EAX = FFFFA69Bh movsx edx,bl ; EDX = FFFFFF9Bh movsx cx,bl ; CX = FF9Bh ; Memory-to-memory exchange: mov ax,val1 ; AX = 1000h xchg ax,val2 ; AX = 2000h, val2 = 1000h mov val1,ax ; val1 = 2000h ; Direct-Offset Addressing (byte array): mov al,arrayB ; AL = 10h mov al,[arrayB+1] ; AL = 20h mov al,[arrayB+2] ; AL = 30h ; Direct-Offset Addressing (word array): mov ax,arrayW ; AX = 100h mov ax,[arrayW+2] ; AX = 200h ; Direct-Offset Addressing (doubleword array): mov eax,arrayD ; EAX = 10000h mov eax,[arrayD+4] ; EAX = 20000h mov eax,[arrayD+TYPE arrayD] ; EAX = 20000h exit main ENDP END main