0% found this document useful (0 votes)
29 views2 pages

12 Rime

This program takes in a hexadecimal number as input from the user and checks if it is a prime number or not. It uses division and modulo operations to check for factors from 2 up to the number itself. If no factors are found, it displays a message that the number is prime, otherwise it displays that the number is not prime. The program exits normally after displaying the result message.

Uploaded by

Pratik Dhameliya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views2 pages

12 Rime

This program takes in a hexadecimal number as input from the user and checks if it is a prime number or not. It uses division and modulo operations to check for factors from 2 up to the number itself. If no factors are found, it displays a message that the number is prime, otherwise it displays that the number is not prime. The program exits normally after displaying the result message.

Uploaded by

Pratik Dhameliya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Date:

PRACTICAL:Aim:- Write 8086 assembly level language program to check that given number is prime or not.
Display message on monitor.
Program:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

0000

.model small
dis1 macro msg
mov dx, offset msg
mov ah,09h
int 21h
endm
0000
.data
0000 45 6E 74 65 72 20 48+ msg1 db "Enter HEX No:- $"
45 58 20 4E 6F 3A 2D+
20 24
0010 0A 0D 45 6E 74 65 72+ msg2 db 10, 13,"Entered No is Prime...!$"
65 64 20 4E 6F 20 69+
73 20 50 72 69 6D 65+
2E 2E 2E 21 24
002A 0A 0D 45 6E 74 65 72+ msg3 db 10, 13, "Entered No is Not Prime...!?!$"
65 64 20 4E 6F 20 69+
73 20 4E 6F 74 20 50+
72 69 6D 65 2E 2E 2E+
21 3F 21 24
004A
.code
0000 B8 0000s
mov ax,@data
0003 8E D8
mov ds,ax
dis1 msg1
0005 BA 0000r
mov dx, offset msg1
0008 B4 09
mov ah,09h
000A CD 21
int 21h
000C BA 0000
mov dx, 0000h
000F
repeat:
000F B4 01
mov ah,01h
0011 CD 21
int 21h
0013 3C 0D
cmp al, 13
0015 74 0E
je check4
0017 D1 D2 D1 D2 D1 D2 D1+ rcl dx,04
D2
001F 2C 30
sub al,30h
0021 02 D0
add dl,al
0023 EB EA
jmp repeat
0025
check4:
0025 B3 02
mov bl,02h
0027
l1:
0027 B8 0000
mov ax,0000h
002A 8A C2
mov al, dl
002C F6 F3
div bl

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

002E
0031
0033
0035
0037

80 FC 00
74 10
FE C3
3A DA
75 EE

0039
003C
003E
0040
0043

BA 0010r
B4 09
CD 21
EB 08 90

0043 BA 002Ar
0046 B4 09
0048 CD 21
004A
004A B4 4C
004C CD 21

cmp ah,00h
je notprime
inc bl
cmp bl, dl
jne l1
dis1 msg2
mov dx, offset msg2
mov ah,09h
int 21h
jmp exit
notprime:
dis1 msg3
mov dx, offset msg3
mov ah,09h
int 21h
exit:
mov ah,4ch
int 21h
end

Output:D:\1\TASM>debug pr.exe
-l
-r
AX=0000 BX=0000 CX=0098 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000
DS=13BD ES=13BD SS=13CD CS=13CD IP=0000 NV UP EI PL NZ NA PO NC
13CD:0000 B8D113
MOV AX,13D1
-g
Enter HEX No:- 11
Entered No is Prime...!
Program terminated normally
-g
Enter HEX No:- 55
Entered No is Not Prime...!?!

You might also like