Chandigarh University: University Institute of Engineering
Chandigarh University: University Institute of Engineering
Prepared By:
Sukhpreet Singh E1474 &
Oshin E5408
Instruction Set of 8086
PUSH Operand:
It pushes the operand into top of stack.
E.g.: PUSH BX
POP Des:
It pops the operand from top of stack to Des.
Des can be a general purpose register, segment register (except
CS) or memory location.
E.g.: POP AX
Data Transfer Instructions
• LAHF:
– It copies the lower byte of flag register to AH.
• SAHF:
– It copies the contents of AH to lower byte of flag register.
• PUSHF:
– Pushes flag register to top of stack.
• POPF:
– Pops the stack top to flag register.
Exercise 1
Q.1 Transfer 16 bit number from memory into register AX. The
address of first location is 7000h:1500h(BA:EA).
• INC Src:
– It increments the byte or word by one.
– The operand can be a register or memory location.
– It effects AF, OF, PF, SF, ZF flags.
– CF is not effected.
– E.g.: INC AX
Arithmetic Instructions
• DEC Src:
– It decrements the byte or word by one.
– The operand can be a register or memory location.
– It effects AF, OF, PF, SF, ZF flags.
– CF is not effected.
– E.g.: DEC AX
Arithmetic Instructions
• NEG Src:
– It creates 2’s complement of a given
number.
– That means, it changes the sign of a
number.
Arithmetic Instructions
• MUL Src:
– It is an unsigned multiplication instruction.
– It multiplies two bytes to produce a word or two words to produce a
double word.
– AX = AL * Src
– DX : AX = AX * Src
– This instruction assumes one of the operand in AL or AX.
– Src can be a register or memory location.
• IMUL Src:
– It is a signed multiplication instruction.
Arithmetic Instructions
• DIV Src:
– It is an unsigned division instruction.
– It divides word by byte or double word by word.
– The operand is stored in AX, divisor is Src and the
result is stored as:
• AH = remainder AL = quotient
• IDIV Src:
– It is a signed division instruction.
Arithmetic Instructions
• NOT Src:
– It complements each bit of Src to produce 1’s
complement of the specified operand.
– The operand can be a register or memory location.
Logical Instructions
• OR Des, Src:
– It performs OR operation of Des and Src.
– Src can be immediate number, register or memory location.
– Des can be register or memory location.
– Both operands cannot be memory locations at the same
time.
– CF and OF become zero after the operation.
– PF, SF and ZF are updated.
Logical Instructions
• CALL Des:
– This instruction is used to call a subroutine or function or
procedure.
– The address of next instruction after CALL is saved onto
stack.
• RET:
– It returns the control from procedure to calling program.
– Every CALL instruction should have a RET.
Program Execution Transfer Instructions
• JMP Des:
– This instruction is used for unconditional jump
from one place to another.
• Loop Des:
– This is a looping instruction.
– The number of times looping is required is placed
in the CX register.
– With each iteration, the contents of CX are
decremented.
– ZF is checked whether to loop again or not.
String Instructions
• SCAS String:
– It scans a string.
– It compares the String with byte in AL or with
word in AX.
String Instructions
• REP (Repeat):
– This is an instruction prefix.
– It causes the repetition of the instruction until CX
becomes zero.
– E.g.: REP MOVSB STR1, STR2
• It copies byte by byte contents.
• REP repeats the operation MOVSB until CX becomes
zero.
Processor/Flag Control Instructions
• STC:
– It sets the carry flag to 1.
• CLC:
– It clears the carry flag to 0.
• CMC:
– It complements the carry flag.
Processor Control Instructions
• STD:
– It sets the direction flag to 1.
– If it is set, string bytes are accessed from higher memory
address to lower memory address.
• CLD:
– It clears the direction flag to 0.
– If it is reset, the string bytes are accessed from lower
memory address to higher memory address.
Home Assignment
Q.1 Give the status of zero and carry flag for the instructions :
(a) MOV AX, 1345h
(b) MOV BX, 1457h
(c) CMP BX, AX