-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmult35.asm
More file actions
67 lines (42 loc) · 965 Bytes
/
mult35.asm
File metadata and controls
67 lines (42 loc) · 965 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
57
58
59
60
61
62
63
64
65
66
; Find all the multiples of 3 or 5 below 1000
global _start
extern printf
section .text
_start:
mov r8, 3
mov r9, 5
xor rbx, rbx ; sum
mov rax, 1 ; counter
iter_mult:
cmp eax, 1000 ; Limit 1000
jge print_result
xor rdx, rdx
push rax
idiv r8
pop rax
cmp rdx, 0
je short_eval
xor rdx, rdx
push rax
idiv r9
pop rax
cmp rdx, 0
jne no_multiple
short_eval:
add rbx, rax ; sum += counter
no_multiple:
inc eax
jmp iter_mult
print_result:
mov rdi, format
mov esi, ebx
xor rax, rax
call printf
mov rax, 60
mov rdi, 0
syscall
ret
section .data
format:
db "%d", 10, 0
; vim: ft=nasm :