0% found this document useful (0 votes)
88 views15 pages

Expt 1 Arithmetic Instructions

The document describes experiments to verify arithmetic operations in 8086 using registers and instructions like ADD, SUB, MUL, DIV. It provides examples of code to perform 8-bit and 16-bit addition, subtraction, multiplication and division. The effects on flags for each operation are also described. An exercise is given to write code for various arithmetic operations using different registers and to interpret the results and flags.

Uploaded by

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

Expt 1 Arithmetic Instructions

The document describes experiments to verify arithmetic operations in 8086 using registers and instructions like ADD, SUB, MUL, DIV. It provides examples of code to perform 8-bit and 16-bit addition, subtraction, multiplication and division. The effects on flags for each operation are also described. An exercise is given to write code for various arithmetic operations using different registers and to interpret the results and flags.

Uploaded by

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

Experiment 2: Verification of

Arithmetic Operations in 8086


BITS Pilani
Hyderabad Campus
ALPs to be completed

Registers to be used
Operation
8-bit 16-bit
Addition CL, DL AX, BX
Subtraction CL, DL BX, CX
Multiplication AL, BL AX, BX
Division AL, BL AX, BX

Title| Presenter 2 BITS Pilani, Hyderabad Campus


2.1 Addition of two numbers
Instruction to be used: ADD

Instruction Operands Usage Description


REG, memory Operand 1 = Operand 1 + Operand 2
memory, REG
Example:
ADD REG, REG ADD AL,BL
memory, immediate ADD AL,-5
Operates on both 8-bit or 16-bit numbers.
REG, immediate

Effect on Flags
C Z S O P A r: flag value depends on
r r r r r r result of the instruction

Title| Presenter 3 BITS Pilani, Hyderabad Campus


2.1 Addition of two 8-bit numbers

3. Interpret the results of the


Example Code

flags of the mp.


org 100h

1. Click here and check the


MOV AL,0F0H
changes in the registers.
MOV BL,010H
ADD AL,BL

ret

CF: Carry is generated when performing n


bit operations and the result is more than n 2. Click here to check the
bits, then it is 1, otherwise 0.
conditions of flags of the mp.
ZF: After any arithmetical or logical
operation results 0 (00)H, the zero flag is 1, PF: 1 accumulator has even number of 1 bits
otherwise 0. 0 accumulator has odd parity

Title| Presenter 4 BITS Pilani, Hyderabad Campus


2.2 Addition of two 16-bit numbers

3. Interpret the results of the


Example Code

flags of the mp.


org 100h
1. Click here and check the
MOV CX,1234H
changes in the registers.
MOV DX,5678H
ADD CX,DX

ret

2. Click here to check the


conditions of flags of the mp.

Title| Presenter 5 BITS Pilani, Hyderabad Campus


2.3 Subtraction of two numbers
Instruction to be used: SUB

Instruction Operands Usage Description


REG, memory Operand 1 = Operand 1 - Operand 2
memory, REG
Example:
SUB REG, REG SUB AL,BL
memory, immediate SUB AL,1
Operates on both 8-bit or 16-bit numbers.
REG, immediate

Effect on Flags
C Z S O P A r: flag value depends on
r r r r r r result of the instruction

Title| Presenter 6 BITS Pilani, Hyderabad Campus


2.3 Subtraction of two 8-bit numbers

3. Interpret the results of the


Example Code

flags of the mp.


org 100h
1. Click here and check the
MOV AL,009H
changes in the registers.
MOV BL,006H
SUB AL,BL

ret

2. Click here to check the


conditions of flags of the mp.

Title| Presenter 7 BITS Pilani, Hyderabad Campus


2.4 Subtraction of two 16-bit numbers

3. Interpret the results of the


Example Code

flags of the mp.


org 100h
1. Click here and check the
MOV AX,0FCBAH
changes in the registers.
MOV BX,01D3FH
SUB AX,BX
ret

2. Click here to check the


SF: 1- MSB is 1 (negative)
0- MSB is 0 (positive) conditions of flags of the mp.

AF: 1-carry out from bit 3 on addition or borrow into bit 3 on subtraction
0-otherwise

Title| Presenter 8 BITS Pilani, Hyderabad Campus


2.5 Multiplication of two numbers
Instruction to be used: MUL

Instruction Operands Usage Description


REG When operand is a byte:
AX = AL × operand.
MUL memory When operand is a word:
(DX AX) = AX × operand.

Effect on Flags
C Z S O P A r: flag value depends on ?: flag value is undefined
r ? ? r ? ? result of the instruction. (maybe 1 or 0).

CF = OF = 0 when high section of the result is zero.

Title| Presenter 9 BITS Pilani, Hyderabad Campus


2.5 Multiplication of two 8-bit numbers

Example Code

org 100h

MOV AX,04H
MOV BX,05H
MUL BX

ret

Title| Presenter 10 BITS Pilani, Hyderabad Campus


2.6 Multiplication of two 16-bit numbers

Example Code

org 100h

MOV AX, 0111H


MOV BX, 1212H
MUL BX
ret

Check the content


of both AX and DX
registers.

Title| Presenter 11 BITS Pilani, Hyderabad Campus


2.7 Division of two numbers
Instruction to be used: DIV
Instruction Operands Usage Description
REG When operand is a byte:
AL = AX / operand
AH = remainder (modulus)
DIV
memory When operand is a word:
AX = (DX AX) / operand
DX = remainder (modulus)

Effect on Flags

C Z S O P A ?: flag value is undefined


? ? ? ? ? ? (maybe 1 or 0).

Title| Presenter 12 BITS Pilani, Hyderabad Campus


2.7 Division of two 8-bit numbers
Example Code

org 100h

MOV AX,20H
MOV BX,10H
DIV BX

ret

Check the content


of both AL and DL
registers.

Title| Presenter 13 BITS Pilani, Hyderabad Campus


2.8 Division of two 16-bit numbers

Example Code

org 100h

MOV AX,2312H
MOV BX,1010H
DIV BX

ret

Check the content


of both AX and DX
registers.
Title| Presenter 14 BITS Pilani, Hyderabad Campus
Exercise
Write ALP codes for the following arithmetic operations:
Problem No. Arithmetic Instructions Which registers are to be used?

1 12H + CAH CL, DL

2 1A4CH + B1DEH AX, BX

3 7AH – 4CH CL, DL

4 3B7AH – C142H BX, CX

5 1DH × 77H AL, BL

6 EF1AH × CD50H AX, BX

7 19H ÷ 03H AL, BL

8 1927H ÷ 1201H AX, BX

In each case interpret the results of different flags. Crosscheck your results
by converting them into decimal numbers.

Title| Presenter 15 BITS Pilani, Hyderabad Campus

You might also like