0% found this document useful (0 votes)
10 views38 pages

8086 Instructions 1

The document provides an overview of the Intel 8086 microprocessor instruction set, detailing various categories such as data transfer, arithmetic, logical, and bit manipulation instructions. It includes specific instructions like MOV, ADD, SUB, and their functionalities, along with examples of usage. Additionally, it covers the effects of these instructions on processor flags and provides insights into how they operate within the microprocessor architecture.

Uploaded by

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

8086 Instructions 1

The document provides an overview of the Intel 8086 microprocessor instruction set, detailing various categories such as data transfer, arithmetic, logical, and bit manipulation instructions. It includes specific instructions like MOV, ADD, SUB, and their functionalities, along with examples of usage. Additionally, it covers the effects of these instructions on processor flags and provides insights into how they operate within the microprocessor architecture.

Uploaded by

bholachomu2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Microprocessors

(ENEX 201)
Sharad Kumar Ghimire
Department of Electronics and Computer Engineering
Pulchowk Campus
Institute of Engineering
Tribhuvan University
Nepal
Chapter 3

Intel 8086 Microprocessor


(contd…)

S. K. Ghimire
8086 Microprocessor Instruction Set
The 8086 microprocessor instructions
Data Transfer Instructions

Arithmetic Instructions

Logical Instructions

Bit Manipulation Instructions: Shift, Rotate

Program Execution Transfer (Branching) Instructions: Jump, Jx, Loop

Subroutine and Subroutine Handling Instructions

Interrupt Instructions

String Instructions
Contents
8086 Microprocessor Instructions:

Data Transfer: MOV, LEA, XCHG

Arithmetic: ADD, ADC, SUB, SBB, MUL, IMUL, DIV, IDIV, INC, DEC, DAA,
DAS, CBW, CWD

Logical: AND, OR, XOR, NOT, NEG, CMP, TEST

Rotate & Shift: RCL, RCR, ROL, ROR, SAL/SHL, SAR, SHR

- S. K. Ghimire
DATA TRANSFER INSTRUCTIONS
MOV – MOV Destination, Source
Copies a word or byte of data from a specified source to a specified destination

The destination can be a register or a memory location

The source can be a register, a memory location or an immediate data

The source and destination both cannot be memory at once

Both operands must be of the same type (bytes or words)

Does not affect any flag

MOV CX, 037AH ;Put immediate data 037AH to CX


MOV BL, [437AH] ;Copy byte in DS at offset 437AH to BL
XCHG – XCHG Destination, Source
Exchanges the content of a register with the content of another register or with the
content of memory location(s)

Cannot directly exchange the content of two memory locations

Source and destination must both be of the same type (bytes or words)

Does not affect any flag

XCHG AX, DX ;Exchange word in AX with word in DX


XCHG BL, CH ;Exchange byte in BL with byte in CH
XCHG AL, VAL_1
LEA – LEA Register, Source
Determines the offset of the variable or memory location named as the source and
puts this offset in the indicated 16-bit register

LEA does not affect any flag

E.g.

LEA BX, PRICES ;Load BX with offset of PRICE in DS

LEA CX, [BX][DI] ;Load CX with EA = [BX] + [DI]


LDS – LDS Register, Memory address of the first
word
Loads new values into the specified register and into the DS register from four
successive memory locations

The word from two memory locations is copied into the specified register and the
word from the next two memory locations is copied into the DS registers

Does not affect any flag


LDS BX, [4326] Copy content of memory at 4326H in DS to BL content of 4327H
to BH. Copy content at displacement of 4328H and 4329H in DS to DS register
LDS SI, SPTR Copy content of memory at displacement SPTR and SPTR + 1
LES – LES Register
Loads new values into the specified register and into the ES register from four
successive memory locations

The word from the first two memory locations is copied into the specified register,
and the word from the next two memory locations is copied into the ES register

Does not affect any flag

LES BX, [789AH] Copy content of memory at displacement 789AH in DS to


BL, content of 789BH to BH, content of memory at displacement 789CH and
789DH in DS is copied to ES register
LES DI, [BX] Copy content of memory at offset [BX] and offset [BX] + 1 in DS
to DI register & copy content of memory at offset [BX]+2 and [BX]+3 to ES register
ARITHMETIC INSTRUCTIONS
ADD – ADD Destination, Source
ADC – ADC Destination, Source
ADD - adds a number from some source to a number in destination and put the
result in the specified destination

ADC - also adds the status of the carry flag to the result

The source may be an immediate number, a register, or a memory location

The destination may be a register or a memory location

The source and the destination both cannot be memory locations at once

The source and the destination must be of the same type (bytes or words)

Flags affected: AF, CF, OF, PF, SF and ZF


ADD/ADC Examples
ADD AL, 74H ;Add immediate number 74H to content of AL

ADC CL, BL ;Add content of BL plus carry to content of CL

ADD DX, BX ;Add content of BX to content of DX


SUB – SUB Destination, Source
SBB – SBB Destination, Source
Subtract the number in some source from the number in some destination and put
the result in the destination

SBB instruction also subtracts the content of carry flag from the destination

Source may be an immediate number, a register or memory location

Destination can also be a register or a memory location

The source and the destination both cannot be memory location at once

The source and the destination must both be of the same type (bytes or words)

Flags affected: AF, CF, OF, PF, SF, ZF


SUB/SBB Examples
SUB CX, BX ;CX – BX is stored in CX

SBB CH, AL ;Subtract content of AL and CF from CH - result in CH

SUB AX, 3427H ;Subtract immediate number 3427H from AX

SBB BX, [3427H] ;Subtract word at 3427H in DS and CF from BX


MUL – MUL Source
Multiplies an unsigned byte in source with an unsigned byte in AL register or an
unsigned word in some source with an unsigned word in AX register

Source can be a register or a memory location

When a byte is multiplied by the content of AL, the result (product) is put in AX

When a word is multiplied by the content of AX, the result is put in DX and AX
registers

CF & OF affected but AF, PF, SF and ZF are undefined after a MUL instruction

MUL BH ;Multiply AL with BH; result in AX


MUL CX ;Multiply AX with CX; result high word in DX, low word in AX
IMUL – IMUL Source
Multiplies a signed byte from source with a signed byte in AL or a signed word
from some source with a signed word in AX

Similar with MUL except that it deals with signed number

IMUL BH ;Multiply signed byte in AL with signed byte in BH; result in AX.

IMUL AX ;Multiply AX times AX as signed words & result in DX and AX


DIV – DIV Source
Divides an unsigned word by a byte or to divide an unsigned double word (32 bits)
by a word

When a byte is used as divisor the content of AX register is divided and AL will
contain the 8-bit quotient, and AH will contain the 8-bit remainder

When a word is used as divisor the 32 bit contents of DX:AX is divided and AX will
contain the 16-bit quotient and DX will contain the 16-bit remainder

DIV BL ;Divide word in AX by byte in BL; Quotient in AL, remainder in AH

DIV CX ;Divide double word in DX and AX by a word in CX


IDIV – IDIV Source
Used to divide a signed word by a signed byte, or to divide a signed double word
by a signed word

Similar with DIV except that it deals with signed number


INC – INC Destination
Adds 1 to a specified register or to a memory location

The flags AF, OF, PF, SF, and ZF are updated whereas CF remain unaffected

INC BL ;Add 1 to contains of BL register

INC CX ;Add 1 to contains of CX register

INC BYTE PTR [BX] ;Increment byte in data segment at offset contained in BX

INC WORD PTR [BX] ;Increment the word pointed by BX in the data segment
DEC – DEC Destination
Subtracts 1 from the destination word or byte

The destination can be a register or a memory location

The flags AF, OF, SF, PF, and ZF are affected, whereas CF is unchanged

DEC CL ;Subtract 1 from content of CL register

DEC BP ;Subtract 1 from content of BP register

DEC BYTE PTR [BX] ;Subtract 1 from byte at offset [BX] in DS

DEC WORD PTR [SI] ;Subtract 1 from a word pointed by SI


DAA (DECIMAL ADJUST AFTER BCD ADDITION)
Used to make the result of adding two packed BCD numbers to a BCD number

The result of the addition must be in AL for DAA


DAS (DECIMAL ADJUST AFTER BCD
SUBTRACTION)
Used after subtracting one packed BCD number from another packed BCD
number, to make the result is a packed BCD

The result of the subtraction must be in AL


CBW (CONVERT SIGNED BYTE TO SIGNED
WORD)
Copies the sign bit of the byte in AL to all the bits in AH - AH is then said to be the
sign extension of AL

Does not affect any flag

Let AX = 00000000 10011011 (–155 decimal)

CBW Convert signed byte in AL to signed word in AX

AX = 11111111 10011011 (–155 decimal)


CWD (CONVERT SIGNED WORD TO SIGNED
DOUBLE WORD)
Copies the sign bit of a word in AX to all the bits of the DX register, i.e..it extends
the sign of AX into all of DX

CWD affects no flags

Let DX = 00000000 00000000, and AX = 11110000 11000111 (–3897 decimal)

CWD Convert signed word in AX to signed double word in DX:AX

DX = 11111111 11111111

AX = 11110000 11000111 (–3897 decimal)


AAA (ASCII ADJUST FOR ADDITION)
Numerical data coming into a computer from a terminal is usually in ASCII code

The numbers 0 to 9 are represented by the ASCII codes 30H to 39H

8086 allows to add the ASCII codes for two decimal digits without masking off the
“3” in the upper nibble of each. After the addition, the AAA instruction is used to
make sure the result is the correct unpacked BCD

AAA instruction works only on the AL register

AAA instruction updates AF and CF; but OF, PF, SF and ZF are left undefined
AAS (ASCII ADJUST FOR SUBTRACTION)
Numerical data coming into a computer from a terminal is usually in ASCII code

In this code the numbers 0 to 9 are represented by the ASCII codes 30H to 39H

8086 allows to subtract the ASCII codes for two decimal digits without masking the
“3” in the upper nibble of each

AAS instruction is then used to make sure the result is the correct unpacked BCD

AAS instruction works only on the AL register

Updates ZF and CF; but OF, PF, SF, AF are left undefined
AAM (BCD ADJUST AFTER MULTIPLY)
Before multiplying two ASCII digits, we have to mask the upper 4 bit of each - this
leaves unpacked BCD (one BCD digit per byte) in each byte

After the two unpacked BCD digits are multiplied, the AAM instruction is used to
adjust the product to two unpacked BCD digits in AX

AAM works only after the multiplication of two unpacked BCD bytes, and it works
only the operand in AL

AAM updates PF, SF and ZF but AF; CF and OF are left undefined
AAD (BCD-TO-BINARY CONVERT BEFORE
DIVISION)
AAD converts two unpacked BCD digits in AH and AL to the equivalent binary
number in AL

This adjustment must be made before dividing the two unpacked BCD digits in AX
by an unpacked BCD byte

After the BCD division, AL will contain the unpacked BCD quotient and AH will
contain the unpacked BCD remainder
LOGICAL INSTRUCTIONS
AND – AND Destination, Source
Performs bitwise AND operation source byte or word with the same numbered bit
in a destination byte or word, and the result is put in the specified destination

The content of the specified source is not changed

The source can be an immediate number, the content of a register, or the content
of a memory location, but the destination can be a register or a memory location

The source and the destination cannot both be memory locations

CF and OF are both 0 and PF, SF, and ZF are updated by the AND instruction. AF
is undefined. PF has meaning only for an 8-bit operand
OR – OR Destination, Source
Performs OR operation each bit in a source byte or word with the same numbered
bit in a destination byte or word and the result is put in the specified destination

The content of the specified source is not changed

The source can be an immediate number, the content of a register, or the content
of a memory location, whereas the destination can be a register or a memory

The source and destination cannot both be memory locations

CF, OF are both 0, and PF, SF, and ZF are updated by the OR instruction. AF is
undefined. PF has meaning only for an 8-bit operand
XOR – XOR Destination, Source
Exclusive-OR operation of each bit in a source byte or word with the same
numbered bit in a destination byte or word and the result is put in the specified
destination

The content of the specified source is not changed

The source can be an immediate number, the content of a register, or the content
of a memory location whereas the destination can be a register or a memory

The source and destination cannot both be memory locations

CF, OF are both 0 and PF, SF, and ZF are updated. PF has meaning only for an
8-bit operand. AF is undefined
NOT – NOT Destination
Inverts each bit (forms the 1’s complement) of a byte or word in the specified
destination

The destination can be a register or a memory location

Does not affect any flag

NOT BX

NOT BYTE PTR [BX]


NEG – NEG Destination
Replaces the number in a destination with its 2’s complement

The destination can be a register or a memory location

It gives the same result as the invert each bit and add one algorithm

The NEG instruction updates AF, AF, PF, ZF, and OF

NEG AL

NEG BX

NEG BYTE PTR [BX]


CMP – CMP Destination, Source
Compares a byte/word in the specified source with a byte/word in the specified
destination

The source can be an immediate number, a register, or a memory location,


whereas the destination can be a register or a memory location

The source and the destination cannot both be memory locations

The comparison is actually done by subtracting the source byte or word from the
destination byte or word, without changing the source and the destination, but the
flags are set to indicate the results of the comparison

AF, OF, SF, ZF, PF, and CF are updated


TEST – TEST Destination, Source
Performs AND operation between the byte / word in the specified source with the
byte / word in the specified destination

Only flags are updated, but neither operand is changed

The test instruction is often used to set flags before a Conditional jump instruction

Source can be an immediate number, the content of a register, or the content of a


memory location, whereas the destination can be a register or a memory location

The source and the destination cannot both be memory locations

CF and OF are both 0’s after TEST. PF, SF and ZF will be updated to show the
results of the destination. AF is be undefined

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy