-
Notifications
You must be signed in to change notification settings - Fork 0
/
prime.s
110 lines (110 loc) · 2.18 KB
/
prime.s
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
.file "prime.c"
.intel_syntax
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "%d\12\0"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
push ebp
mov ebp, esp
push ebx
sub esp, 52
and esp, -16
mov eax, 0
add eax, 15
add eax, 15
shr eax, 4
sal eax, 4
mov DWORD PTR [ebp-36], eax
mov eax, DWORD PTR [ebp-36]
call __alloca
call ___main
mov eax, DWORD PTR [ebp+12]
add eax, 4
mov eax, DWORD PTR [eax]
mov DWORD PTR [ebp-8], eax
mov eax, DWORD PTR [ebp-8]
mov DWORD PTR [esp], eax
call _atol
mov DWORD PTR [ebp-12], eax
mov DWORD PTR [ebp-16], 3
mov eax, DWORD PTR [ebp-12]
mov DWORD PTR [esp], eax
call _malloc
mov DWORD PTR [ebp-20], eax
mov eax, DWORD PTR [ebp-20]
mov DWORD PTR [eax], 3
mov eax, DWORD PTR [ebp-20]
add eax, 4
mov DWORD PTR [eax], 3
mov eax, DWORD PTR [ebp-20]
add eax, 8
mov DWORD PTR [eax], 5
mov eax, DWORD PTR [ebp-20]
add eax, 12
mov DWORD PTR [eax], 7
mov DWORD PTR [ebp-24], 0
mov BYTE PTR [ebp-25], 0
mov DWORD PTR [ebp-24], 7
L2:
mov eax, DWORD PTR [ebp-24]
cmp eax, DWORD PTR [ebp-12]
jge L3
mov DWORD PTR [ebp-32], 0
mov BYTE PTR [ebp-25], 0
L5:
mov eax, DWORD PTR [ebp-32]
cmp eax, DWORD PTR [ebp-16]
jge L6
mov eax, DWORD PTR [ebp-32]
lea ecx, [0+eax*4]
mov edx, DWORD PTR [ebp-20]
mov DWORD PTR [ebp-40], edx
mov eax, DWORD PTR [ebp-24]
mov ebx, DWORD PTR [ebp-40]
cdq
idiv DWORD PTR [ecx+ebx]
mov DWORD PTR [ebp-40], edx
cmp DWORD PTR [ebp-40], 0
jne L7
mov BYTE PTR [ebp-25], 1
jmp L6
L7:
lea eax, [ebp-32]
inc DWORD PTR [eax]
jmp L5
L6:
movzx eax, BYTE PTR [ebp-25]
cmp eax, 1
jne L9
jmp L4
L9:
lea eax, [ebp-16]
inc DWORD PTR [eax]
mov eax, DWORD PTR [ebp-16]
lea ecx, [0+eax*4]
mov edx, DWORD PTR [ebp-20]
mov eax, DWORD PTR [ebp-24]
mov DWORD PTR [ecx+edx], eax
L4:
lea eax, [ebp-24]
add DWORD PTR [eax], 2
jmp L2
L3:
mov eax, DWORD PTR [ebp-16]
lea edx, [0+eax*4]
mov eax, DWORD PTR [ebp-20]
mov eax, DWORD PTR [edx+eax]
mov DWORD PTR [esp+4], eax
mov DWORD PTR [esp], OFFSET FLAT:LC0
call _printf
mov eax, 0
mov ebx, DWORD PTR [ebp-4]
leave
ret
.def _printf; .scl 2; .type 32; .endef
.def _malloc; .scl 2; .type 32; .endef
.def _atol; .scl 2; .type 32; .endef