-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.asm
More file actions
57 lines (33 loc) · 739 Bytes
/
main.asm
File metadata and controls
57 lines (33 loc) · 739 Bytes
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
global _start
extern printf
extern asm_prime
section .text
_start:
xor rbx, rbx
xor rcx, rcx
range_iter:
cmp rbx, 1000000
jge print_result
xor rax, rax
mov rdi, rbx
push rbx
push rcx
call asm_prime
pop rcx
pop rbx
add rcx, rax ; Our result is either a 1 or zero
inc rbx
jmp range_iter
print_result:
mov rdi, format
mov rsi, rcx
xor rax, rax
call printf
mov rax, 60
mov rdi, 0
syscall
ret
section .data
format:
db "%ld", 10, 0
; vim: ft=nasm :