How to perform Arithmetic Operations in Assembly Language


Arithmetic operations in Assembly Language:

Arithmetic operations included different operations like Addition, Subtraction, Multiplication, Division and Modulus. You can perform all arithmetic operations with the use of some basic registers mostly we use registers including Base Registers, Destination Register and Accumulator Registers and many Operands. To perform all of this coding in Assembly Language you must need to do Linker Setting of your Visual Studio 2019 and of any version you like to use. Now we tell you which operands have been used in this program. In this program we will perform all arithmetic operations on 2 different  numbers each time we get input from user and perform operation on it.

Operands used in this Program of Assembly Language:

  • add operand to perform addition of two numbers.
  • sub operand is used to perform subtraction of two numbers.
  • mul operand is used to perform multiplication in Assembly Language.
  • div operand is used to perform division in Assembly Language.

Tutorial of How to perform arithmetic operations on 2 different numbers:

Perform Arithmetic Operations on 2 Different Numbers:

.386
INCLUDE Irvine32.inc
.model small
.stack 100h
.data
msg db "Enter 1st Number for addition",0
msg1 db "Enter 2nd Number for Addition",0
msg2 db "Enter 1st number for subtraction",0
msg3 db "Enter 2nd number for subtraction",0
msg4 db "Enter 1st Number for Multiplication",0
msg5 db "Enter 2nd Number for Multiplication",0
msg6 db "Enter 1st Number for division",0
msg7 db "Enter 2nd Number for division",0
var dd ?
var1 dd ?
.code
main proc
;Perform All Arithmetic operations on 2 different numbers
;Addition Section
mov edx,offset msg
call writestring
call readint
mov var,eax
mov edx,offset msg1
call writestring
call readint
add eax,var
call writeint
call crlf
;Subtraction Section
mov edx,offset msg2
call writestring
call readint
mov var,eax
mov edx,offset msg3
call writestring
call readint
sub eax,var
call writeint
call crlf
; Multiplication Section
mov edx,offset msg4
call writestring
call readint
mov var,eax
mov edx,offset msg5
call writestring
call readint
mov ebx,var
mul ebx
call writeint
call crlf
; Division Section


mov edx,offset msg6
call writestring
call readint
mov var,eax

mov edx,offset msg7
call writestring
call readint
mov var1,eax

mov edx,0
mov eax,var
mov ebx,var1
div ebx
call writeint
call crlf

invoke ExitProcess,0
main endp 
end main

Output:

Perform Arithmetic Operations on 2 Different Numbers

Comments

  1. Arithmetic operations in Assembly Language showcase the foundational building blocks of computation. They provide a deeper understanding of low-level programming, enabling fine-grained control over numerical operations.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Run Assembly Language Programming Code In Visual Studio 2019

How to Display Table of any Number in Assembly Language

How to Display Character in Assembly language