Docsity

8086 Assembly Language: String Manipulation Instructions, Lecture notes of Microprocessors

Partial preview of the text

Download 8086 Assembly Language: String Manipulation Instructions and more Lecture notes Microprocessors in PDF only on Docsity!

& ASSEMBLER DIRECTIVES

INSTRUCTION

SET

1. Data Transfer Instructions

2. Arithmetic Instructions

3. Logical Instructions

4. String manipulation Instructions

5. Process Control Instructions

6. Control Transfer Instructions

8086 supports 6 types of instructions.

  1. Data Transfer Instructions Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT … MOV reg2/ mem, reg1/ mem MOV reg2, reg MOV mem, reg MOV reg2, mem (reg2)  (reg1) (mem)  (reg1) (reg2)  (mem) MOV reg/ mem, data MOV reg, data MOV mem, data (reg)  data (mem)  data XCHG reg2/ mem, reg XCHG reg2, reg XCHG mem, reg (reg2)  (reg1) (mem)  (reg1)

XCHG ■ (^) Exchanges a byte/word between the source and the destination specified in the instruction. Source: Register, Memory Location

  • Destination: Register, Memory Location
  • (^) Even here, both operands cannot be memory locations. Eg: XCHG CX, BX ; CX <-----> BX XCHG BL, CH ; BL <------> CH
  1. Data Transfer Instructions Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT …

PUSH AX & POP BX

  1. Data Transfer Instructions Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT … IN destination register, source port Loads the destination register with the contents of the I/O port specified by the source. Source : It is an I/O port address. If the address is 8-bit it will be given in the instruction by Direct addressing mode. If it is a 16 bit address it will be given by DX register using Indirect addressing mode. Destination : It has to be some form of “A” register, in which we will get data from the I/O device. If we are getting 8-bit data, it will be AL or AH register. If we are getting 16-bit data, it will be AX register. Eg: IN AL, 80H ; AL gets 8-bit data from I/O port address 80H IN AX, 80H ; AX gets 16-bit data from I/O port address 80H IN AL, DX ; AL gets 8-bit data from I/O port address given by DX. IN AX, DX ; AX gets 16-bit data from I/O port address given by DX. OUT destination port, source register Loads the destination I/O port with the contents of the source register. Eg: OUT 80H, AL ; I/O port 80H gets 8-bit data from AL OUT 80H, AX ; I/O port 80H gets 16-bit data from AX OUT DX, AL ; I/O port whose address is given by DX gets 8-bit data from AL OUT DX, AX ; I/O port whose address is given by DX gets 16-bit data from AX
  1. Data Transfer Instructions 11 Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT … I/O addresses in 8086 can be either 8–bit or 16-bit Direct Addressing Mode: If we use 8-bit I/O address we get a range of 00H… FFH. This gives a total of 256 I/O ports. Here we use Direct addressing Mode, that is, the I/O address is specified in the instruction. E.g.:: IN AL, 80H ; AL gets data from I/O port address 80H. This is also called Fixed Port Addressing. Indirect Addressing Mode: If we use 16-bit I/O address we get a range of 0000H… FFFFH. This gives a total of 65536 I/O ports. Here we use Indirect addressing Mode, that is, the I/O address is specified by DX register. E.g.:: MOV DX, 2000H IN AL, DX ; AL gets data from I/O port address 2000H given by DX. This is also called Variable Port Addressing.
  1. Arithmetic Instructions Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP… ADC reg2/ mem, reg1/mem ADC reg2, reg ADC reg2, mem ADC mem, reg (reg2)  (reg1) + (reg2)+CF (reg2)  (reg2) + (mem)+CF (mem)  (mem)+(reg1)+CF ADC reg/mem, data ADC reg, data ADC mem, data (reg)  (reg)+ data+CF (mem)  (mem)+data+CF ADDC A, data ADD AL, data ADD AX, data (AL)  (AL) + data8+CF (AX)  (AX) +data16+CF
  1. Arithmetic Instructions Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
  1. Arithmetic Instructions Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP… SBB reg2/ mem, reg1/mem SBB reg2, reg SBB reg2, mem SBB mem, reg (reg2)  (reg1) - (reg2) - CF (reg2)  (reg2) - (mem)- CF (mem)  (mem) - (reg1) –CF SBB reg/mem, data SBB reg, data SBB mem, data (reg)  (reg) – data - CF (mem)  (mem) - data - CF SBB A, data SBB AL, data SBB AX, data (AL)  (AL) - data8 - CF (AX)  (AX) - data16 - CF
  1. Arithmetic Instructions Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP… INC reg/ mem INC reg INC reg INC mem (reg8)  (reg8) + 1 (reg16)  (reg16) + 1 (mem)  (mem) + 1 DEC reg/ mem DEC reg DEC reg DEC mem (reg8)  (reg8) - 1 (reg16)  (reg16) - 1 (mem)  (mem) - 1
  1. Arithmetic Instructions Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP… MUL reg/ mem MUL reg MUL mem For byte : (AX)  (AL) x (reg8) For word : (DX)(AX)  (AX) x (reg16) For byte : (AX)  (AL) x (mem8) For word : (DX)(AX)  (AX) x (mem16) IMUL reg/ mem IMUL reg IMUL mem For byte : (AX)  (AL) x (reg8) For word : (DX)(AX)  (AX) x (reg16) For byte : (AX)  (AX) x (mem8) For word : (DX)(AX)  (AX) x (mem16)
  1. Arithmetic Instructions Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…