MP Practical 10
32 bit Addition:
Code :
.model small
.386
.stack 100
strdisp macro string
lea dx,string
mov ah,09h
int 21h
endm
.data
head db 10,13,"32 bit Addition $"
str1 db 10,10,13,"Num1 : 10023412h$"
str2 db 10,13,"Num2 : 22334411h$"
str3 db 10,10,13,"Result : $"
opr1 dd 10023412h
opr2 dd 22334411h
result dd ?
.code
.startup
mov ax,@data
mov ds,ax
strdisp head
strdisp str1
strdisp str2
strdisp str3
mov eax, opr1
mov ebx, opr2
add eax, ebx
mov result,eax
call displayresult
mov ah, 4ch
int 21h
.exit
proc displayresult near
mov ecx, 08
up :
mov eax, result
MP Practical 10
rol eax, 04
mov result, eax
and al, 0Fh
cmp al, 0ah
jb digit
add al, 07h
digit :
add al, 30h
mov dl, al
mov ah, 02
int 21h
loop up
ret
displayresult endp
end
Output
MP Practical 10
32 bit Subtraction:
Code :
.model small
.386
.stack 100
strdisp macro string
lea dx,string
mov ah,09h
int 21h
endm
.data
head db 10,13,"32 bit Subtraction $"
str1 db 10,10,13,"num1 : 0FF000111h$"
str2 db 10,13,"num2 : 0EE000101h$"
str3 db 10,10,13,"Result : $"
opr1 dd 0FF000111h
opr2 dd 0EE000101h
result dd ?
.code
.startup
mov ax, @data
mov ds, ax
strdisp head
strdisp str1
strdisp str2
strdisp str3
mov eax, opr1
mov ebx, opr2
sub eax, ebx
mov result, eax
call displayresult
mov ah, 4ch
MP Practical 10
int 21h
.exit
proc displayresult near
mov ecx, 08
up :
mov eax, result
rol eax, 04
mov result,eax
and al, 0Fh
cmp al, 0ah
jb digit
add al, 07h
digit :
add al, 30h
mov dl, al
mov ah, 02
int 21h
loop up
ret
endp displayresult
end
Output :
MP Practical 10
32 bit Multiplication:
Code :
.model small
.386
.stack 100
strdisp macro string
lea dx,string
mov ah,09h
int 21h
endm
.data
head db 10,13,"32 bit Multiplication $"
str1 db 10,10,13,"num1 : 20001111h$"
str2 db 10,13, "num2 : 23000202h$"
str3 db 10,10,13, "Result : $"
opr1 dd 20001111h
opr2 dd 23000202h
result dd ?
result1 dd ?
.code
.startup
mov ax,@data
mov ds,ax
strdisp head
strdisp str1
strdisp str2
strdisp str3
mov eax,opr1
mov ebx,opr2
mul ebx
mov result,edx
mov result1,eax
call displayresult
mov eax,result1
mov result, eax
call displayresult
mov ah,4ch
int 21h
.exit
proc displayresult near
MP Practical 10
mov ecx,08
up:
mov eax,result
rol eax,04
mov result,eax
and al,0FH
cmp al,0AH
jb digit
add al,07h
digit:
add al,30h
mov dl,al
mov ah,02
int 21h
loop up
ret
displayresult endp
end
MP Practical 10
Output:
MP Practical 10
32 bit Division:
Code :
.model small
.386
.stack 100
strdisp macro str
lea dx, str
mov ah, 09h
int 21h
endm
.data
str1 db 10,10,13,"Dividend is 0100000000000000h$"
str2 db 10,13, "Divisor is 10000000h$"
str3 db 10,10,13, "Quotient is : $"
str4 db 10,13, "Remainder is: $"
opr1 dd 00000000h,01000000h
opr2 dd 10000000h
result dd ?
result1 dd ?
.code
.startup
mov ax,@data
mov ds,ax
strdisp str1
strdisp str2
strdisp str3
mov eax,opr1
mov edx,opr1+4
mov ebx,opr2
div ebx
mov result,eax
mov result1,edx
call displayresult
lea dx,str4
mov ah,09h
MP Practical 10
int 21h
mov eax,result1
mov result,eax
call displayresult
mov ah,4ch
int 21h
.exit
proc displayresult
mov ecx,08
up:
mov eax,result
ROL eax,04
mov result,eax
and al,0FH
cmp al,0AH
JB digit
add al,07h
digit:
add al,30h
mov dl,al
MOV ah,02
INT 21h
LOOP up
RET
displayresult endp
end
MP Practical 10
Output: