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

MPI assignment

ABDULLAH KAMAL
FAIZAN ASHRAF
SALMAN KHAN

.model small
.data
a db 10,13,'ENTER NUMBER RANGING FROM 0 TO 65535
= $'
b db 10,13,'FOR BINARY PRESS 1 ,FOR OCTAL PRESS 2 ,
FOR HEXA DECIMAL PRESS 3 = $'
c db 10,13,'RESULT = $'
d dw ?
e dw ?
f db 10,13,'$'
g db 10,13,'INVALID INPUT THE PROGRAM WILL NOW
TERMINATE $'
h db 10
i db 'TO ENTER NEW NUMBER PRESS 1 ,PRESS ANY
OTHER KEY TO EXIT $'
.code
main proc
mov ax,@data
mov ds,ax
program:

; main program

mov ah,09h
lea dx,f
int 21h
mov ah,09h
lea dx,a
int 21h
mov bx,10
mov ah,01h
int 21h
mov ah,00h
sub al,30h
mov d,ax
loop1:
mov ah,01h
int 21h

;take input

mov ah,00h
cmp al,0dh
pressed.
jne loop2
jmp next
loop2:
sub ax,30h
mov e,ax
mov ax,d
mul bx
add ax,e
mov d,ax
jmp loop1
next:
mov ah,09h
lea dx,f

;loop will not break untill enter is

int 21h
mov ah,09h
lea dx,b
int 21h
mov ah,01h
int 21h
mov bh,00h
mov ah,00h
mov dx,0
mov cx,0
cmp al,31h
for binary.
je binary

;this command will check the user input

;this command will check the user input for


binary.
cmp al,32h
je octal
;this command will check the user input for
binary.
cmp al,33h
je hexadecimal
jmp invalid
binary:
mov ax,d
mov bx,02
jmp conversion
octal:
mov ax,d
mov bx,08

jmp conversion
hexadecimal:
mov ax,d
mov bx,16
jmp conversion
conversion:
div bx
push dx

;here number is pushed in the stack.

mov dx,0
inc cx
cmp ax,0
zero.
jnz conversion
mov ah,09h
lea dx,f
int 21h

;loop will not break untill ax equal to

mov ah,09h
lea dx,c
int 21h
display:
pop dx
cmp dl,h
will break.
jl dis
add dl,07
jmp dis
dis:
add dx,30h
mov ah,2
int 21h
loop display

;here number poped from the stack.


;if number is greater than 9 then loop

jmp pend
invalid:
valid or not.

;will check that the selscted option is

mov ah,09h
lea dx,g
int 21h

pend:
mov ah,09h
lea dx,f
int 21h
mov ah,09h
lea dx,i
int 21h
mov ah,09h

;termination of program

lea dx,f
int 21h
mov ah,01h
int 21h
cmp al,31h
je program
mov ah,4ch
int 21h
main endp
end main

You might also like