-
Notifications
You must be signed in to change notification settings - Fork 0
/
orafli.asm
65 lines (61 loc) · 904 Bytes
/
orafli.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
.MODEL HUGE ;100000以内的素数
.STACK 16384
.CODE
MAIN PROC FAR
.386
MOV EAX,1
while_true:
INC EAX
MOV EBX, 2
CMP EAX, 100000
JNC done
while_true_2:
CMP EBX, EAX ;<
JNC got_prime
CMP EBX, 314
JNC got_prime
div_try:
PUSH EAX
MOV EDX,0
DIV EBX
POP EAX
CMP EDX,0
JZ while_true
INC EBX
JMP while_true_2
got_prime:
MOV ECX, EAX
PUSH EAX
CALL far ptr fun_output
back1:
CALL far ptr print_space
back2:
POP EAX
JMP while_true
print_space:
MOV EDX,20H
MOV EAX,200H
INT 21H ;输出空格
RET
fun_output: ; ECX是待打印
CMP ECX, 10 ; 后者大,CF=1,相等则ZF=1
JC print
MOV EAX, ECX
MOV EBX, 10
MOV EDX, 0
DIV EBX
MOV ECX, EAX
PUSH EDX
CALL far ptr fun_output
POP ECX
print:
MOV EDX,ECX
ADD EDX,30H
MOV EAX,200H
INT 21H
RET
done:
MOV EAX,4C00H
INT 21H
MAIN ENDP
END