-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15.S
57 lines (42 loc) · 898 Bytes
/
15.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
section .data
num db 9
prime_msg db "Prime", 10
prime_len equ $ - prime_msg
not_prime_msg db "Not Prime", 10
not_prime_len equ $ - not_prime_msg
section .text
global _start
_start:
movzx rax, byte [num]
cmp rax, 2
jl not_prime
je is_prime
mov rbx, 2
check_divisor:
cmp rbx, rax
jge is_prime
mov rdx, 0
mov rcx, rax
div rbx
cmp rdx, 0
je not_prime
mov rax, rcx
inc rbx
jmp check_divisor
is_prime:
mov rax, 1
mov rdi, 1
mov rsi, prime_msg
mov rdx, prime_len
syscall
jmp exit
not_prime:
mov rax, 1
mov rdi, 1
mov rsi, not_prime_msg
mov rdx, not_prime_len
syscall
exit:
mov rax, 60
xor rdi, rdi
syscall