MPMC EXP 07 Code & Output Print
MPMC EXP 07 Code & Output Print
MPMC EXP 07 Code & Output Print
PROGRAMS:
EXP 07[a]. Write an assembly language program to perform addition of multi-digit numbers.
Code:
section .data mov esi,2 ;for digits of number
string1 db 'Enter the first number: ' mov ecx,3 ;for digits of number
string1len equ $-string1 clc
string2 db 'Enter the second number: '
string2len equ $-string2 add_loop:
string3 db 'The sum is ' mov al,[num1+esi]
string3len equ $-string3 adc al,[num2+esi]
newline db ' ',10 aaa
newlinelen equ $-newline pushf
or al,30h
section .bss popf
num1 resb 9
num2 resb 9 mov[sum+esi],al
sum resb 9 dec esi
loop add_loop
section .data
global _start mov eax,4
mov ebx,1
_start: mov ecx,newline
mov eax,4 mov edx,newlinelen
mov ebx,1 int 80h
mov ecx,string1
mov edx,string1len mov eax,4
int 80h mov ebx,1
mov ecx,string3
mov eax,3 mov edx,string3len
mov ebx,2 int 80h
mov ecx,num1
mov edx,9 mov eax,4
int 80h mov ebx,1
mov ecx,sum
mov eax,4 mov edx,5
mov ebx,1 int 80h
mov ecx,string2
mov edx,string2len mov eax,4
int 80h mov ebx,1
mov ecx,newline
mov eax,3 mov edx,newlinelen
mov ebx,2 int 80h
mov ecx,num2
mov edx,9 mov eax,1
int 80h mov ebx,0
int 80h
Output:
EXP 07[b]. Write an assembly language program to perform subtraction of multi-digit numbers.
Code:
section .data mov ebx,2
string1 db 'Enter the first number: ' mov ecx,num2
string1len equ $-string1 mov edx,9
string2 db 'Enter the second number: ' int 80h
string2len equ $-string2
string3 db 'The sum is ' mov esi,2 ;for digits of number
string3len equ $-string3 mov ecx,3 ;for digits of number
newline db ' ',10 clc
newlinelen equ $-newline
add_loop:
section .bss mov al,[num1+esi]
num1 resb 9 adc al,[num2+esi]
num2 resb 9 aaa
sum resb 9 pushf
or al,30h
section .data popf
global _start
mov[sum+esi],al
_start: dec esi
mov eax,4 loop add_loop
mov ebx,1
mov ecx,string1 mov eax,4
mov edx,string1len mov ebx,1
int 80h mov ecx,newline
mov edx,newlinelen
mov eax,3 int 80h
mov ebx,2
mov ecx,num1 mov eax,4
mov edx,9 mov ebx,1
int 80h mov ecx,string3
mov edx,string3len
mov eax,4 int 80h
mov ebx,1
mov ecx,string2 mov eax,4
mov edx,string2len mov ebx,1
int 80h mov ecx,sum
mov edx,5
mov eax,3 int 80h
Nidhi Shanbhag 211105036 |Page
EXPERIMENT NO: 7 ARITHMETIC OPERATIONS ON MULTI-DIGIT NUMBERS Date:29/05/23
int 80h
mov eax,4
mov ebx,1 mov eax,1
mov ecx,newline mov ebx,0
mov edx,newlinelen int 80h
Output:
Conclusion:
All programs were executed successfully