~manxi-david/pyeffect/pyeffect

« back to all changes in this revision

Viewing changes to Examples/primes.s

  • Committer: dvspeed
  • Date: 2011-12-26 13:18:36 UTC
  • Revision ID: manxi.david@gmail.com-20111226131836-mvoy9y32z0ujxvm1
-Change of folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.section .data
2
 
Bytestring00:
3
 
        .byte   0
4
 
Bytestring11:
5
 
        .byte   0
6
 
Bytestring22:
7
 
        .byte   0
8
 
Bytestring33:
9
 
        .byte   0
10
 
Bytestring44:
11
 
        .byte   0
12
 
Bytestring55:
13
 
        .byte   0
14
 
Bytestring66:
15
 
        .byte   0
16
 
Bytestring77:
17
 
        .byte   0
18
 
Bytestring88:
19
 
        .byte   0
20
 
Bytestring99:
21
 
        .byte   0
22
 
Bytestring1010:
23
 
        .byte   0
24
 
Byte0:
25
 
        .byte   3
26
 
Byte1:
27
 
        .byte   0
28
 
Byte2:
29
 
        .byte   0
30
 
Byte3:
31
 
        .byte   0
32
 
Byte4:
33
 
        .byte   0
34
 
Byte5:
35
 
        .byte   0
36
 
Byte6:
37
 
        .byte   0
38
 
Byte7:
39
 
        .byte   0
40
 
Byte8:
41
 
        .byte   3
42
 
Byte9:
43
 
        .byte   0
44
 
Byte10:
45
 
        .byte   0
46
 
Byte11:
47
 
        .byte   0
48
 
Byte12:
49
 
        .byte   0
50
 
Byte13:
51
 
        .byte   0
52
 
Byte14:
53
 
        .byte   0
54
 
Byte15:
55
 
        .byte   0
56
 
Byte16:
57
 
        .byte   0
58
 
Byte17:
59
 
        .byte   0
60
 
Byte18:
61
 
        .byte   0
62
 
Byte19:
63
 
        .byte   0
64
 
Byte20:
65
 
        .byte   0
66
 
Byte21:
67
 
        .byte   0
68
 
Byte22:
69
 
        .byte   0
70
 
Byte23:
71
 
        .byte   0
72
 
Byte24:
73
 
        .byte   0
74
 
Byte25:
75
 
        .byte   0
76
 
Byte26:
77
 
        .byte   0
78
 
Byte27:
79
 
        .byte   0
80
 
Byte28:
81
 
        .byte   0
82
 
Byte29:
83
 
        .byte   0
84
 
Byte30:
85
 
        .byte   0
86
 
Byte31:
87
 
        .byte   0
88
 
Byte32:
89
 
        .byte   0
90
 
Byte33:
91
 
        .byte   0
92
 
Byte34:
93
 
        .byte   0
94
 
Byte35:
95
 
        .byte   0
96
 
Byte36:
97
 
        .byte   0
98
 
Byte37:
99
 
        .byte   0
100
 
Byte38:
101
 
        .byte   0
102
 
Byte39:
103
 
        .byte   0
104
 
Byte40:
105
 
        .byte   0
106
 
Byte41:
107
 
        .byte   0
108
 
Byte42:
109
 
        .byte   0
110
 
Byte43:
111
 
        .byte   0
112
 
Byte44:
113
 
        .byte   0
114
 
Byte45:
115
 
        .byte   0
116
 
Byte46:
117
 
        .byte   0
118
 
Byte47:
119
 
        .byte   0
120
 
Byte48:
121
 
        .byte   0
122
 
Byte49:
123
 
        .byte   0
124
 
Byte50:
125
 
        .byte   0
126
 
Byte51:
127
 
        .byte   0
128
 
Byte52:
129
 
        .byte   0
130
 
Byte53:
131
 
        .byte   0
132
 
Byte54:
133
 
        .byte   0
134
 
Byte55:
135
 
        .byte   0
136
 
Byte56:
137
 
        .byte   0
138
 
Byte57:
139
 
        .byte   0
140
 
Byte58:
141
 
        .byte   0
142
 
Byte59:
143
 
        .byte   0
144
 
Byte60:
145
 
        .byte   0
146
 
Byte61:
147
 
        .byte   0
148
 
Byte62:
149
 
        .byte   0
150
 
Byte63:
151
 
        .byte   0
152
 
.section .text
153
 
.globl _start
154
 
_start:
155
 
#Begin of program:
156
 
        #       x=3
157
 
        #       div=3
158
 
        #       while 1000>x:
159
 
        loop_while_0:
160
 
        cmpq    $1000,  Byte0
161
 
        jnl returnWhile0
162
 
        #               if x%div==0:
163
 
        #x % div
164
 
        xorq    %rdx,   %rdx
165
 
        movq    Byte0,  %rax
166
 
        divq    Byte8
167
 
        movq    %rdx,   Byte16
168
 
        cmpq    $0,     Byte16
169
 
        jne if1_0
170
 
        #                       x=x+2
171
 
        #x + 2
172
 
        movq    $2,     Byte24
173
 
        movq    Byte24, %rdi
174
 
        movq    %rdi,   Byte24
175
 
        movq    Byte0,  %rdi
176
 
        addq    %rdi,   Byte24
177
 
        movq    Byte24, %rdi
178
 
        movq    %rdi,   Byte0
179
 
        #                       div=3
180
 
        movq    $3,     Byte8
181
 
        jmp return0
182
 
        if1_0:
183
 
        #               elif div*2>x:
184
 
        #div * 2
185
 
        movq    $2,     Byte32
186
 
        movq    Byte32, %rax
187
 
        mulq    Byte8
188
 
        movq    %rax,   Byte32
189
 
        movq    Byte32, %rdi
190
 
        cmpq    %rdi,   Byte0
191
 
        jnl if2_0
192
 
        #                       print(x)
193
 
        movq    Byte0,  %rax
194
 
        movb    $10,    Bytestring1010
195
 
        movq    $Bytestring99,  %rdi
196
 
        movq    $Bytestring1010,        %rsi
197
 
        loop_x_1:
198
 
        movq    $10,    Byte40
199
 
        xorq    %rdx,   %rdx
200
 
        divq    Byte40
201
 
        addq    $48,    %rdx
202
 
        movb    %dl,    (%rdi)
203
 
        decq    %rdi
204
 
        cmpq    $0,     %rax
205
 
        jne loop_x_1
206
 
        subq    %rdi,   %rsi
207
 
        movq    %rsi,   %rdx
208
 
        incq    %rdi
209
 
        movq    %rdi,   %rsi
210
 
        movq    $1,     %rax
211
 
        movq    $1,     %rdi
212
 
        syscall
213
 
        #                       x=x+2
214
 
        #x + 2
215
 
        movq    $2,     Byte48
216
 
        movq    Byte48, %rdi
217
 
        movq    %rdi,   Byte48
218
 
        movq    Byte0,  %rdi
219
 
        addq    %rdi,   Byte48
220
 
        movq    Byte48, %rdi
221
 
        movq    %rdi,   Byte0
222
 
        #                       div=3
223
 
        movq    $3,     Byte8
224
 
        jmp return0
225
 
        if2_0:
226
 
        #else:
227
 
        #                       div=div+2
228
 
        #div + 2
229
 
        movq    $2,     Byte56
230
 
        movq    Byte56, %rdi
231
 
        movq    %rdi,   Byte56
232
 
        movq    Byte8,  %rdi
233
 
        addq    %rdi,   Byte56
234
 
        movq    Byte56, %rdi
235
 
        movq    %rdi,   Byte8
236
 
        return0:
237
 
        jmp loop_while_0
238
 
        returnWhile0:
239
 
        #       exit(0)
240
 
        xorq    %rdi,   %rdi
241
 
        movq    $60,    %rax
242
 
        syscall
243
 
#End of program