Experiment 3

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Heaven’s Light is Our Guide

Rajshahi University of Engineering & Technology

Department of Electrical & Electronic Engineering

: Microprocessor, Interfacing and System design


Course Title Sessional

Course No : EEE 3210


Experiment No : 03
Name of the Experiment : Arithmetic Operation in Assembly Language
Programming.

Date of Experiment : 15 October, 2023


Date of Submission : 29 October, 2023

Submitted by Submitted to

Name : Zahid Hossain Belal Hossain

Roll : 1901145 Assistant Professor

Section : C Department of EEE

Session : 2019-20 RUET


Experiment No. 03
3.1 Experiment Name
Arithmetic Operation in Assembly Language Programming.

3.2 Objectives
1. To learn and use Arithmetic operation like Division, Multiplication etc.
2. To Observe the outputs on MDA-8086 .

3.3 Theory
These instructions are used to perform arithmetic operations like addition, subtraction,
multiplication, division, etc.
Following is the list of instructions under this group −
Instructions to perform addition
 ADD: Used to add the provided byte to byte/word to word.
 ADC: Used to add with carry.
 INC: Used to increment the provided byte/word by 1.
Instructions to perform subtraction
 SUB: Used to subtract the byte from byte/word from word.
 SBB: Used to perform subtraction with borrow.
 DEC: Used to decrement the provided byte/word by 1.
 NEG: replaces the value of a register or memory operand with its two's
complement.
 CMP: Used to compare 2 provided byte/word.
Instruction to perform multiplication
 MUL: Used to multiply unsigned byte by byte/word by word.
Byte with Byte multiplication: This instruction is Used to multiply unsigned byte by
byte/word by word. In this operation, one operand is stored in AL register and the other
one is source and their result is stored in AX register. 8-bit register. Example:
𝑀𝑈𝐿 𝐵𝐻 𝑀𝑈𝐿 𝐶𝑋
Word with Word multiplication: In this operation, one operand is stored in AX register
and the source must be a 16-bit register or a memory address. The result is stored in DX
register. 8 or 16- bit register. This instruction is Used to multiply signed byte by byte/word
by word. Example:
𝐼𝑀𝑈𝐿 𝐶𝑋

 IMUL: Used to multiply signed byte by byte/word by word.


Instructions to perform division
 DIV − Used to divide the unsigned word by byte or unsigned double word by word.
 IDIV − Used to divide the signed word by byte or signed double word by word.
3.4 Programs and Outputs for Different Instructions:
ADD/ADC:
_CODE SEGMENT
ASSUME CS:_CODE
MOV AL,11101100B
MOV BL,11110011B
ADD AL,BL
ADC AL,00000110B
HLT
_CODE ENDS

Fig. 3.1: ADD and ADC instructions

SUB/SBB:
_CODE SEGMENT
ASSUME CS:_CODE
MOV AL,11101100B
MOV BL,11110011B
SUB AL,BL
SBB AL,00000110B
HLT
_CODE ENDS

Fig. 3.2: SUB and SBB instructions


INC: DEC:

Fig. 3.3: SUB and SBB instructions

MUL:
CODE SEGMENT
ASSUME CS:_CODE
MOV AX,123H
MOV BX,1C8H
MUL BX
HLT
_CODE ENDS

Fig. 3.5: MUL instructions

IMUL:

_CODE SEGMENT
ASSUME CS:_CODE
MOV AX,0000000000010111B
MOV BX,1111111111100010B
IMUL BX
HLT
_CODE ENDS

Fig. 3.6: IMUL instructions

DIV:
_CODE SEGMENT
ASSUME CS:_CODE
MOV AX,500d
MOV BX,250d
DIV AX,BX
HLT
_CODE END

Fig. 3.7: DIV instructions

IDIV:
_CODE SEGMENT
ASSUME CS:_CODE
MOV AX,500d
MOV BX,250d
IDIV AX,BX
HLT
_CODE END

Fig. 3.8: IDIV instructions

CMP:
_CODE SEGMENT
ASSUME CS:_CODE
MOV AX,24D
MOV BX,35D
CMP AX,BX
HLT
_CODE ENDS

Fig. 3.9: CMP instructions


3.5 Discussion & Conclusion
In this experiment, we have been familiarized with assembly language programming on
emu8086. Programming language of arithmetic and logical operation were discussed in
details. Program for 1-byte or 2-byte data in multiplication and division were studied. The
operand for signed and unsigned number is also different (MUL for unsigned and IMUL
for signed bit). The division operation is same as multiplication, only the difference is
operand (DIV for unsigned and IDIV for signed bit).For logical operation, shift left
instruction shifts the bit to the left and shift right operation shift the bit to the right. ROR
and ROL are used to rotate bits in right and left order respectively.

You might also like