0% found this document useful (0 votes)
31 views7 pages

Basic Arithmetic Operations Program in Assembly Language

This document presents a program in assembly language that performs basic arithmetic operations (addition, subtraction, multiplication, division, and modulus) using two numbers entered by the user. It requests the numbers, stores the results of each operation in variables, and finally displays the results on the screen.
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)
31 views7 pages

Basic Arithmetic Operations Program in Assembly Language

This document presents a program in assembly language that performs basic arithmetic operations (addition, subtraction, multiplication, division, and modulus) using two numbers entered by the user. It requests the numbers, stores the results of each operation in variables, and finally displays the results on the screen.
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

MICROPROCESSORS

ASSEMBLY LANGUAGE

IRVING YAIR SALAS CHAVEZ


ITIT 5A
Mixed
Basic Arithmetic Operations Program in Assembly Language

org 100h (COM TEMPLATE format, loads 256 bytes)


.model small (small memory model)
.stack 64 (reserve a memory space of 64 kb)
data segment (Start of the data segment)
declaring global variables
number1 db 0 (variable name and assignment of value 0)
number2 db 0 (variable name and assignment of the value 0)
Operations variables
sum db 0 (variable name and assignment of value 0)
resta db 0 (variable name and assignment of the value 0)
multiplication db 0 (variable name and assignment of the value 0)
division db 0 (variable name and assignment of value 0)
module db 0 (variable name and assignment of value 0)
#
Enter the first number=
msjn2 db 10,13, "Enter the second number= ",'$'; enter n2 (Request for value n2)

;message to show the results (All results are displayed)

msjnS db 10,13, "The sum is= ",'$'


The subtraction= $
msjnM db 10,13, "The multiplication is= ",'$'
the division is = '$'
msjnMod db 10,13, "The module is = ",'$'

.code (beginning of the code segment)


begin proc far (Processing call)

addressing of the procedure


mov ax, @data (initialization of the data in)
move ds, ax (the data segment)

request number 1 from the keyboard

code to display a message on the screen


mov ah, 09 (Request to display)
lea dx, msjn1 (load the address of msjn1)
int 21h (DOS call)
# code to read characters
mov ah, 01 (request to read character from keyboard)
int 21h (DOS call)
Code to save value
subtract al, 30h (remainder 30H (48Dec) to obtain the number)
move number1, al (I store it in variable number1)

request number 2 from the keyboard


# code to display a message on screen
mov ah, 09 (Request to display)
lea dx, msjn2 (load the address of msjn2)
int 21h (DOS call)
# code to read characters
mov ah, 01 (request to read character from keyboard)
int 21h (DOS call)
Code to save value
subtract al, 30h (rest 30H (48Dec) to obtain the number)
move number2,al (I store it in variable number2)

arithmetic operations

SUM
mov al,number1 (load the value of the variable number1)
add to it, number2 (sum the value of the variable number2)
mov suma,al (Copy into the variable suma)

RESTA
mov al,number1 (load the value of the variable number1)
subtract al, number2 (subtract the value of the variable number2)
move resta, al (Copy to the variable resta)

MULTIPLICATION
mov al,number1 (loads the value of the variable number1)
multiply number2 (multiply the value of the variable number2)
move multiplication, al (Copy into the variable multiplication)

;DIVISION
mov al,number1 (load the value of the variable number1)
divide by the value of the variable numero2
move division, al (Copy to the variable division)

MODULE
mov al, number1 (load the value of the variable number1)
divide by the value of the variable number2
move modulo, ah (Copy the value of the modulo into the variable modulo)

Show the result messages

showing the sum


# code to display a message on screen
mov ah,09 (Request to display)
lea dx, msjnS (load the address of msjnS)
int 21h (DOS call)
code to print result
mov dl, sum (Print the value of sum)
add dl,30h (add 30 (48Dec) to get the character)
mov ah,02 (function to print a character on screen)
int 21h (DOS call)
showing the subtraction
code to display a message on screen
mov ah,09 (Request to display)
lea dx,msjnR (load the address of msjnR)
int 21h (DOS call)
code to print result
mov dl,resta (Print the value of resta)
add dl,30h (add 30 (48Dec) to obtain the character)
mov ah,02 (function to print a character on screen)
int 21h (DOS call)

showing the multiplication


code to display a message on screen
mov ah,09 (Request to display)
lea dx,msjnM (load the address of msjnM)
int 21h (DOS call)
# code to print result
mov dl, multiplication (Print the value of multiplication)
add dl,30h (add 30 (48Dec) to get the character)
mov ah,02 (function to print a character on screen)
int 21h (DOS call)

showing the division


# code to display a message on screen
mov ah,09 (Request to display)
load dx, msjnD (load the address of msjnD)
int 21h (DOS call)
# code to print result
mov dl, division (Print the value of division)
add dl,30h (add 30 (48Dec) to obtain the character)
mov ah,02 (function to print a character on screen)
int 21h (DOS call)

showing the module


code to display a message on the screen
mov ah,09 (Request to display)
lea dx, msjnMod (load the address of msjnMod)
int 21h (DOS call)
# code to print result
mov dl, modulo (Print the value of modulo)
add dl, 30h (add 30 (48Dec) to get the character)
mov ah,02 (function to print a character on screen)
int 21h (DOS call)

program closure
mov ah,4ch (function to terminate process)
int 21h (DOS call)
begin endp (completion of processing)
end
Screenshots

You might also like