8086 Microprocessor :: Instruction Sets

1) Data transfer: MOV, IN, OUT, LEA

    i) MOV R/M, R/M/Imm
  • Copy byte or word from specified source to specified destination
    ii) IN AL/AX, port no/DX
  • Copy a byte or word from specified port number to accumulator
  • Second operand is a port number. If required to access port number over 255 - DX register should be used.
    iii) OUT port no/DX, AL/AX
  • Copy a byte or word from accumulator to specified port number
  • First operand is a port number. If required to access port number over 255 - DX register should be used.
    iv) LEA R, M
  • Load effective address of operand into specified register
2) Arithmetic: ADD, SUB, INC, DEC, MUL, DIV, CMP, DAA, AAA

    i) ADD R/M, R/M/Imm
  • Add specified byte to byte or specified word to word
    ii) SUB R/M, R/M/Imm
  • Subtract specified byte from byte or specified word from word
    iii) INC R/M
  • Increment specified byte or word by 1
    iv) DEC R/M
  • Decrement 1 from specified byte or word
    v) MUL R/M
  • Multiplies an unsigned multiplicand by an unsigned multiplier 
  • AL or AX is assumed as multiplicand.
    vi) DIV R/M
  • Divides an unsigned dividend (accumulator) by an unsigned divisor (register)
    vii) CMP R/M, R/M/Imm
  • Compare two specified bytes or two specified words

CF
SF
ZF
Operand1>Operand2
0
0
0
Operand1=Operand2
0
0
1
Operand1<Operand2
1
1
0
    viii) DAA
  • Decimal adjust After Addition.
  • Corrects the result of addition of two packed BCD values
  • Algorithm: 
If low nibble of AL > 9 or AF = 1 then:
· AL = AL + 6
· AF = 1

If AL > 9Fh or CF = 1 then:
· AL = AL + 60h
· CF = 1

Example:
MOV AL,0Fh    ;AL=0Fh (15)
DAA    ;AL = 15h
RET

    ix) AAA
  • ASCII Adjust after Addition.
  • Corrects result in AH and AL after addition when working with BCD values. 
  • It works according to the following Algorithm: 
If low nibble of AL > 9 or AF = 1 then:
· AL = AL + 6
· AH = AH + 1
· AF = 1
· CF = 1
Else
· AF = 0
· CF = 0
in both cases:
clear the high nibble of AL. 

Example:
MOV AX,15    ;AH=00, AL=0Fh
AAA    ;AH=01, AL=05
RET

3) Logic: AND, OR, XOR, NOT, ROR, RCR, ROL, RCL, SHL, SHR

    i) AND/OR/XOR R/M, R/M/Imm

    ii) NOT R/M
  • Invert each bit of a byte or word
    iii) RCL/RCR
Syntax: RCL/RCR R/M, CL/Imm
RCL
RCR
Rotate operand1 left through Carry Flag. The number of rotates is set by operand2.
Rotate operand1 right through Carry Flag. The number of rotates is set by operand2.
Algorithm: shift all bits left, the bit that goes off is set to CF and previous value of CF is inserted to the right-most position.
Algorithm: shift all bits right, the bit that goes off is set to CF and previous value of CF is inserted to the left-most position.
Example:
STC                        ; set carry (CF=1).
MOV AL, 1Ch       ; AL = 00011100b
RCL AL, 1             ; AL = 00111001b, CF=0.
RET
Example:
STC                        ; set carry (CF=1).
MOV AL, 1Ch       ; AL = 00011100b
RCR AL, 1             ; AL = 10001110b, CF=0.
RET

    iv) ROL/ROR
Syntax: ROL/ROR R/M, CL/Imm
ROL
ROR
Rotate operand1 left. The number of rotates is set by operand2.
Rotate operand1 right. The number of rotates is set by operand2.
Algorithm: shift all bits left, the bit that goes off is set to CF and the same bit is inserted to the right-most position.
Algorithm: shift all bits right, the bit that goes off is set to CF and the same bit is inserted to the left-most position.
Example:
MOV AL, 1Ch       ; AL = 00011100b
ROL AL, 1             ; AL = 00111000b, CF=0.
RET
Example:
MOV AL, 1Ch       ; AL = 00011100b
ROR AL, 1             ; AL = 00001110b, CF=0.
RET

    v) SHL/SHR
  • Shift logical left / Shift logical right
  • Syntax: SHL/SHR R/M, CL/Imm
SHL
SHR
Shift operand1 Left. The number of shifts is set by operand2.
Shift operand1 Right. The number of shifts is set by operand2.
Algorithm:
  • Shift all bits left, the bit that goes off is set to CF.
  • Zero bit is inserted to the right-most position.
Algorithm:
  • Shift all bits right, the bit that goes off is set to CF.
  • Zero bit is inserted to the left-most position.
Example:
MOV AL, 11100000b
SHL AL, 1         ; AL = 11000000b,  CF=1.
Example:
MOV AL, 00000111b
SHR AL, 1         ; AL = 00000011b,  CF=1.

4) Branching: JMP, CALL, RET, LOOP

    i) JMP label
  • Jumps to a designated address
    ii) CALL label
  • Call a procedure (subprogram), save return address on stack
    iii) RET
  • Returns from a procedure previously entered by a call
    iv) LOOP
  • Loop through a sequence of instruction until CX=0
Label: …..
           …..
           …..
           Loop Label

5) Stack: PUSH, POP
  • Like in 8085
  • E.g. PUSH BX
  • POP BX

No comments:

Post a Comment