Machine Language 16 bit instruction mode Opcode 1
Machine Language 16 -bit instruction mode Opcode 1 -2 bytes MOD-REG-R/M 0 -1 bytes Displacement 0 -1 bytes Immediate 0 -2 bytes 32 -bit instruction mode(80386 -Pentium 4 only) Address size 0 -1 bytes 1 Register size 0 -1 bytes Opcode 1 -2 bytes MOD-REG-R/M 0 -1 bytes Scaled-index 0 -1 bytes Displacement 0 -4 bytes Immediate 0 -4 bytes
The Opcode D W Opcode D=1 data flow to register field from R/M field. D=0 data flow to the R/M field from register field. W=1 data size is a word or doubleword. W=0 data size is a byte. 2
MOD REG R/M MOD For MOD=11: - 3 Code W=0 000 AL AX EAX 001 CL CX ECX 010 DL DX EDX Function 00 No displacement 01 8 -bit sign-extended displacement 10 16 -bit signed displacement 11 R/M is a register W=1(word) w=1(DW) 011 BL BX EBX 100 AH SP ESP 101 CH BP EBP 110 DH SI ESI 111 BH DI Example: Suppose that a two-byte instruction 8 BECH Opcode D W 1 0 0 0 1 1 MOD REG R/M 11101100
For MOD= 00, 01, 10: R/M Code 000 001 010 011 100 101 110 111 Addressing Mode DS: [BX+SI] DS: [BX+DI] SS: [BP+SI] SS: [BP+DI] DS: [SI] DS: [DI] SS: [BP]* DS: [BX] Opcode D W 1 0 0 0 1 0 4 MOD Example: Suppose that a two-byte Instruction 8 A 15 H REG R/M 00010101
Movement Instructions 1. 2. 3. 4. 5 MOV PUSH/POP LEA : load a 16 - or 32 - bit register with the offset address of the data specified by the operand. LEA AX, NUMB LEA EAX, NUMB LDS, LES, LFS, LGS, and LSS : load any 16 - or 32 -bit register with an offset address and the DS, ES, FS, GS, or SS segment register with a segment address. LDS BX, [DI] LDS EBX, [DI]
STRING DATA TRANSFER 1. LODS : loads AL, AX, or EAX with data stored at the data segment, offset address indexed by the SI register. LODSB AL=DS: [SI]; SI=SI± 1 2. STOS : stores AL, AX, or EAX at the extra segment memory location addressed by the DI register. STOSB ES: [DI]=AL: DI=DI± 1 The repeat prefix : is add to any string data transfer instruction except the LODS. REP STOSW ES: [DI]=AX: DI=DI± 2, CX=CX-1 6
3. MOVS : it transfers data from one memory location to another (8086 -p 4). Transfers a B, W, or D from data segment location addressed by SI to extra segment location addressed by DI. MOVSB ES: [DI]=DS: [SI]; DI=DI± 1, SI=SI± 1 4. INS : (not available on the 8086/8088) transfer a B, W, or D of data from I/O device into the extra segment memory location addressed by the DI register. Note that the I/O address is contained in the DX register. INSD ES: [DI]=[DX]; DI=DI± 4 5. OUTS : (not available on the 8086/8088) transfer a B, W, or D of data from the data segment location addressed by SI to an I/O device. OUTSW [DX]=DS: [SI]; SI=SI± 2 7
MISCELLANEOUS DATA TRANSFER Instructions 1. XCHG: exchanges the contents of a register with the contents of any other register or memory location. XCHG AX, CX exchanges the contents of AX with CX Byte, word, or doubleword – size. Use any addressing mode except immediate addressing. Segment registers. Memory to memory. 2. 3. 8 LAHF: transfers the rightmost eight bits of the flag register into the AH register. SAHF : transfers the AH register to the rightmost eight bits of the flag register.
4. XLAT: converts the contents of the AL register into a number stored in a memory table. 5. IN and OUT: the content of AL, AX, or EAX are transferred only between the I/O device and the µP. IN: transfers data from an external I/O device into AL, AX, or EAX. OUT: transfers data from AL, AX, or EAX to an external I/O device. IN AX, p 8 IN AL, DX OUT p 8, AL OUT DX, EAX 9
6. MOVSX: (move and sign – extend) convert 8 - or 16 bits signed numbers into 16 - or 32 -bit signed number (80386 -P 4). MOVSX CX, BL BL=84 H, CX=FF 84 H 7. MOVZX: (move and zero – extend) convert unsigned 8 - or 16 -bits numbers into unsigned 16 - or 32 -bit number (80386 -P 4). MOVZX DX, AL AL=34 H, DX=0034 H 8. 9. BSWAP EAX=55667788 H EAX=88776655 H CMOV: ( conditional move) is new to the Pentium-Pro. P 4. CMOVC move if carry 10
- Slides: 10