-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmidtermQ1.asm
69 lines (49 loc) · 846 Bytes
/
midtermQ1.asm
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
;! print all pairs a and b which a*b = x
%include "in_out.asm"
section .data
Msg db 'Hello World', 0
section .bss
section .text
global _start
writeDivs:
push rcx
push rdx
push r9
mov r9,rax
mov rcx,1
writeDivsLoop:
cmp rcx,r9
JAE writeDivsExt
mov rax,r9
xor rdx,rdx
div rcx
cmp rdx, 0
JE writeDivsloopPrint
inc rcx
JMP writeDivsLoop
writeDivsloopPrint:;print (rcx rax)
cmp rcx, rax
JA writeDivsExt
mov rdx,rax
mov rax, rcx
call writeNum
xor rax,rax
mov al, ' '
call putc
mov rax, rdx
call writeNum
call newLine
inc rcx
JMP writeDivsLoop
writeDivsExt:
pop r9
pop rdx
pop rcx
ret
_start:
call readNum
call writeDivs
Exit:
mov rax, 1
mov rbx, 0
int 0x80