The Program given below can be used to check whether a 2 digit number is prime or not.
print macro msg
mov ah,09h
mov dx,offset msg
int 21h
endm
readnum macro num
mov ah,01h
int 21h
sub al,'0'
mov bh,0ah
mul bh
mov num,al
mov ah,01h
int 21h
sub al,'0'
add num,al
endm
data segment
cr equ 0dh
lf equ 0ah
msg1 db 'Enter the no:','$'
num1 db ?
msg2 db cr,lf,'prime no','$'
msg3 db cr,lf,'not a prime no','$'
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
print msg1
readnum num1
mov al,num1
cmp al,02h
je go3
mov ah,00h
mov bl,02h
mov bh,00h
mov cl,al
go2:
mov ah,00h
div bl
cmp ah,00h
je go
inc bx
mov al,num1
cmp bl,cl
jne go2
go3: print msg2
jmp exit
go:print msg3
exit:mov ah,4ch
mov al,00h
int 21h
code ends
end start
No comments:
Post a Comment