-
Notifications
You must be signed in to change notification settings - Fork 3
/
extra_question1.asm
72 lines (49 loc) · 1.01 KB
/
extra_question1.asm
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
;PRIME FOR ASCII VALUES 48-148
DATA SEGMENT
MSG1 DB 10,13,'ENTER NUMBER :$'
MSG2 DB 10,13,'PRIME$'
MSG3 DB 10,13,'NOT PRIME $'
TEMP DB ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV BX,04H
LEA DX,MSG1
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
SUB AL,30H ; CHECKS PRIME OF 48<ASCII<148
MOV TEMP,AL
CMP TEMP,07H
JE PRIME
CMP TEMP,01H
JNG NOTPRIME
DIVISION:
CMP BL,TEMP
JG PRIME
MOV AL,TEMP
DIV BX
CMP DX,00H
JE NOTPRIME
INC BX
CMP BX,09H
JE PRIME
JMP DIVISION
NOTPRIME :
LEA DX,MSG3
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
PRIME :
LEA DX,MSG2
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START