0% found this document useful (0 votes)
30 views40 pages

Another Copy 4

This document is intended for diploma students and is one of four copies.

Uploaded by

Teaiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
30 views40 pages

Another Copy 4

This document is intended for diploma students and is one of four copies.

Uploaded by

Teaiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 40
Instruction Set of 8086 An instruction is a binary pattern designed inside a microprocessor to perform a specific function. The entire group of instructions that a microprocessor supports is called Instruction Set. 8086 has more than 20,000 instructions. Classification of Instruction Set Data Transfer Instructions Arithmetic Instructions Bit Manipulation Instructions Program Execution Transfer Instructions String Instructions Processor Control Instructions Data Transfer Instructions These instructions are used to transfer data from source to destination, The operand can be constant, memory location, register or 1/0 port address, Data Transfer Instructions * MOV Des, Ste: » Steoperand can be register, memory locationor immediate operand. » Desean be register or memory operand. » Both Sreand Des cannot be memory ocationat the same time, Eg: MOVCK,oy7A Hl MOVAL BL MOVEX, [oy H Data Transfer Instructions PUSH Operand: * Itpushes the operand intotop ofstack. + Eg:PUSHEX POP Des: « Itpopsthe operand from top of stack to Des. + Descan bea general purposeregister, segment register (escept CS) or memory location, » Eg FOPAL Data Transfer Instructions XCHG Des, Ste: ‘This instruction exchanges Sre with Des, Itcannot exchangetwo memory locations directly. Eg:XCHG DX, AX Data Transfer Instructions IN Accumulator, Port Address: itranses the operand fomspeifed porto accumulace rogister, Eg: INAX,on38H OUT Port Address, Accumulator: erasers the operand fromaccumulator to specie pi. Eg: OUT osBH. AX Data Transfer Instructions LEA Register, Ste: +Itloadsa 16-bit register with the offset address of the data specified by the Src, -Eg: LEA BX, [DI] This instruction loads the contents of DI (offset) into the BX register Data Transfer Instructions LDS Des, Sre: + Itfoads 32-bit pointer ftom memory source to destination register and DB. + Theoffet is placed in the destination register and the segment i placed in DS. * Touse this instruction the word at the lower memory address must contain the offset and the word at the higheraddress must contain thesegment. * Eg: LDS BX, [oyor H] Data Transfer Instructions LES Des, Sre: « It loads 32-bit pointer from memory source to destination register and ES. » The offset is placed in the destination register and the segment is placed in ES. « This instruction is very similar to LDS except that it initializes ES instead of DS. » Eg: LES BX, [o3o1 H] - Data Transfer Instructions LAHF: + Iteopies the lower byte of flag register to AH. » SAHF: + Itcopies 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, Data Transfer Instructions LES Des, Src: » It loads 32-bit pointer from memory source to destination register and ES. » The offset is placed in the destination register and the segment is placed in ES. » This instruction is very similar to LDS except that it initializes ES instead of DS. » E.g.: LES BX, [0301 H] Data Transfer Instructions » LAHF: » lteapies the lower byte of flag register to AH_ SAHF: « [toopies the contentsof AH to lower byte of flag register. » PUSHF: « Pushes flag register to top of stack. » POPF: « Pops the stack top to flag register, Arithmetic Instructions ADD Des, Ste: Itadds a byte to byte ora word to word. Iteffects AF, CF, OF, PF, SF, ZF flags. Eg: ADDAL, 4H ADDDX, AX ADDAN, [BX] Arithmetic Instructions ADC Des, Src: * Itadds the two operands with CF, Iteffects AF, CF, OF, PF, SF, ZF flags. *Eg: ADCAL 74H ADCDY,AX ADCAY, [BX] Arithmetic Instructions SUB Des, Ste: + ltsubiractsa byte rom byteora word from word. * Iteffets AF, CF, OF, PR, SF ZF flags, + Forsubtraction, CFactsas borrow fla. rEg: SUBAL 34H SUBDX,AX SUBAX. [BX] Arithmetic Instructions SBB Des, Sre: + Itsubtracts the two operands and also the borrow from the result. + Itefiects AF, CF, OF, PF SF, ZF flags. vEg: SBBAL, 74H SBBDX,AX SBBAX, [BX] Arithmetic Instructions “INC Ste: + Itincrements the byte or word by one. + The operand can bea register or memory location, + Iteffects AF, OF, PF, SF, ZF flags. + CF is noteffected. * Eg. INCAX ~— rithmetic | nstructions “DEC Ste: * Itdecrements the byte or word by one, + The operand can bea register or memory location. + Itelfcts AF, OF, PF, SF ZF flags, » CF is not effected. * Eg: DECAX hen Arithmetic Instructions AAA (ASCII Adjust after Addition): * The data entered from the terminal is in ASCH format. * In ASCH, 0 - 9 are represented by 30H - 39H_ * This instruction allows us to add the ASCII codes. * This instruction does not have any operand. Other ASCII Instructions: » AAS (ASCII Adjust after Subtraction) AAM (ASCII Adjust after Multiplication) * AAD (ASCII Adjust Before Division) Arithmetic Instructions DAA (Decimal Adjust after Addition) » Itis used to make sure that the result of adding two BCD numbers is adjusted to be a correct BCD number. Itonly works on AL register. DAS (Decimal Adjust after Subtraction) » Itis used to make sure that the result of subtracting two BCD numbers is adjusted to bea correct BCD number. « Itonly works on AL register. Arithmetic Instructions » NEG Sre: « It creates 2's complement of a given number. » That means, it changes the sign of a number. Arithmetic Instructions CMP Des, Src: » Itcompares two specified bytes or words. © The Sre and Des can bea constant, registeror memory location. © Both operands cannot be a memory location at the same time. » The comparison is done simply by internally subtracting the source from destination. © Thevalue of source and destination does not change, but the flags are modified to indicate the result. Arithmetic Instructions * MULSre: * Itisan unsigned multiplication instruction. « It multiplies two bytes to produce a word or two words to spies double word. B * AX=AL* Src * DX:AX=AX* Sre « This instruction assumes one of the operand in AL or AX_ * Srecan be a register or memory location, * IMULSre: * Itisa signed multiplication instruction. ete 7 Arithmetic Instructions DIV Sre: It is an unsigned division instruction. It divides word by byte or double word by word. The operand is stored in AX, divisor is Sre and the result is stored as: AH = remainder AL = quotient IDIV Sre: It is a signed division instruction. Arithmetic Instructions CBW (Convert Byte to Word): * This instruction converts byte in AL to word in AX. » The conversion is done by extending the sign bit of AL throughout AH. CWD (Convert Word to Double Word): » This instruction converts word in AX to double word in DX: AX. » The conversion is done by extending the sign bit of AX throughout DX. Bit Manipulation Instructions These instructions are used at the bit level. These instructions can be used for: » Testing a zero bit Set or reset a bit Shift bits across registers ~ Bit Manipulation Instructions « NOT Sre: » Itcomplements each bit of Src to produce 1's complement of the specified operand. » The operand can be a register or memory location. Bit Manipulation Instructions AND Des, Sre: » It performs AND operation of Des and Src. = Srccan 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. Bit Manipulation Instructions OR Des, Sre: » It performs OR operation of Des and Sre. » Sre 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. » CFand OF become zero after the operation. « PF, SF and ZF are updated. Bit Manipulation Instructions XOR Des, Sre: » Itperforms XOR operation of Des and Src. » Sre 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. Bit Manipulation Instructions SHL Des, Count: » It shift bits of byte or word left, by count. « It puts zero(s) in LSBs. » MSB is shifted into carry flag. If the number of bits desired to be shifted is 1, then the immediate number 1 can be written in Count. » However, if the number of bits to be shifted is more than 1, then the count is put in CL register. Bit Manipulation Instructions SHR Des, Count: * Itshift bits of byte or word right, by count. It puts zero(s) in MSBs. LSB is shifted into carry flag. If the number of bits desired to be shifted is1, then the immediate number can be written in Count. » However, if the number of bits to be shifted is more than 1, then the count is put in CL register. ‘ 2 ae ‘Bit Manipulation Instructions ROL Des, Count: « It rotates bits of byte or word left, by count. « MSB is transferred to LSB and also to CF. « If the number of bits desired to be shifted is 1, then the immediate number 1 can be written in Count, » However, if the number of bits to be shifted is more than 1, then the count is put in CL register Bit Manipulation Instructions ROR Des, Count: » Itrotates bits of byte or word right, by count. » LSB is transferred to MSB and also to CF. » Ifthe number of bits desired to be shifted is 1, then the immediate number 1 can be written in Count. However, if the number of bits to be shifted is more than 1, then the count is put in CL register, Program Execution Transfer Instructions » These instructions cause change in the sequence of the execution of instruction. This change can be through a condition or sometimes unconditional. » The conditions are represented by flags. Program Execution Transfer Instructions » CALL Des: « This instruction is used to call a subroutine or function or procedure. » Theaddress of next instruction after CALL is saved onto stack. * RET: » Itreturns 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 toanother. Jxx Des (Conditional Jump): » All the conditional jumps follow some conditional statements or any instruction that affects the flag. Conditional Jump Table Mnemonic Meaning Jump Condition JA Jump if Above CF = oand ZF =0 Jump if Above or Equal CF=0 JB Jump if Below Jump if Below or Equal Jump if Carry Jump if Equal Jump if Nor Carry Jump if Not Equal Jump if Not Zero Jump if Parity Even. Jump if Parity Odd Jump if Zero Program Execution Transfer Instructions » Loop Des: » This isa 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 String in assembly language is just a sequentially stored bytes or words. There are very strong set of string instructions in 8086. » By using these string instructions, the size of the program is considerably reduced. String Instructions ‘CMPS Des, Sre: » It compares the string bytes or words. - SCAS String: « Itscans a string. » Itcompares the String with byte in AL or with word in String Instructions MOVS / MOVSB / MOVSW: » Itcauses moving of byte or word from one string to another, © Inthis instruction, the source string is in Data Segment and destination string isin Extra Segment. * Sland DI store the offset values for source and destination index. String Instructions » REP (Repeat): « This isan instruction prefix. « It causes the repetition of the instruction until CX becomes zero. « E.g.: REP MOVSB STRi, STR2 » Itcopies byte by byte contents. + REP repeats the operation MOVSB until CX becomes zero. Processor Control Instructions These instructions control the processor itself. 8086 allows to control certain control flags that: causes the processing in a certain direction * processor synchronization if more than one microprocessor attached. = Processor Control Instructions * STC: » It sets the carry flag tot. cLe: » It clears the carry flag too. « CMC: « It complements the carry flag. Processor Control Instructions » STD: « Itsets the direction flag to1. » [Fit is set, string bytes are accessed from higher memory address to lower memory address. * CLD: » Itclears the direction flag to o. » Ifit is reset, the string bytes are accessed from lower memory address to higher memory address,

You might also like