0% found this document useful (0 votes)
38 views3 pages

Prime Composite

The document is an assembly language program that checks whether a given number is prime, composite, or neither. It includes procedures for input, output, and the main logic for determining the number's classification. The program uses DOS interrupts for user interaction and displays the results accordingly.

Uploaded by

Atif Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views3 pages

Prime Composite

The document is an assembly language program that checks whether a given number is prime, composite, or neither. It includes procedures for input, output, and the main logic for determining the number's classification. The program uses DOS interrupts for user interaction and displays the results accordingly.

Uploaded by

Atif Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

data segment

nl db 10,13,'$'
dataenter db 'Enter the number:$'
notpnotc db ' :is neither prime nor composite$'
prme db ' :is prime $'
cmposite db ' :is composite$'

x dw ?

ends

stack segment
dw 128 dup(0)
ends

code segment
start:

; You may customize this and other start-up templates;


; The location of this template is c:\emu8086\inc\0_com_template.txt

main proc
mov ax, @data
mov ds,ax
lea di,x

lea dx,dataenter
mov ah,9
int 21h
lea DX,nl
MOV AH,9
INT 21H
call INPUUT
mov x,bx
cmp bx,1
jz npnc
cmp bx,0
jz npnc
mov si,0
mov bx,1
cheeeck:
inc bx
mov dx,0
mov ax,x

div bx

cmp dx,0
jnz fact

inc si

fact:
cmp bx,x
jz exiit
cmp si,2
jz exiit

jmp cheeeck

exiit:
mov ax,x
pusha
call PRINTT
popa

cmp si,2
jz cmpst

lea dx,prme
mov ah,9
int 21h
jmp oouutt

cmpst:

lea dx,cmposite
mov ah,9
int 21h
jmp oouutt

npnc:
mov dx,x
add dx,30h
mov ah,2
int 21h
lea dx,notpnotc
mov ah,9
int 21h

oouutt:

mov ax, 4c00h


int 21h

INPUUT proc
mov cx,0
mov ah,1
mov bx,0

Linp:
int 21h
cmp al,13
jz out1
mov bl,al
sub bl, 30h
push bx
inc cx
jmp Linp

out1:
mov Si,1
mov bx,0

L2:
pop Ax
mul si
Add bx,ax
mov ax,si
mov si,10
mul si
mov si,ax
loop L2
ret
INPUUT endp

PRINTT PROC
MOV si,10
MOV CX,0

L:
MOV DX,0
DIV si
PUSH DX
INC CX
CMP AX,0
JZ OUTT
JMP L
OUTT:
MOV AH,2
POP DX
ADD DX,30H
INT 21H
LOOP OUTT

RET

PRINTT ENDP

ends

end start

You might also like