-
Notifications
You must be signed in to change notification settings - Fork 1
/
test2.s
59 lines (59 loc) · 770 Bytes
/
test2.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
58
59
.text
.align 4
.globl gcd
gcd:
pushl %EBP
movl %ESP, %EBP
pushl %EBX
pushl %EBP
movl 16(%ESP), %EBP
movl 20(%ESP), %EBX
gcd_bb6:
cmpl $0, %EBX
je gcd_bb4
gcd_bb3:
movl %EBP, %EAX
gcd_bb2:
popl %EBP
popl %EBX
movl %EBP, %ESP
popl %EBP
ret
gcd_bb4:
movl $0, %EDX
movl %EBP, %EAX
idivl %EBX, %EAX
imull %EBX, %EAX
movl %EAX, %ECX
movl %EBP, %EAX
subl %ECX, %EAX
pushl %EAX
pushl %EBX
call gcd
addl $8, %ESP
movl (%EAX), %EAX
gcd_bb5:
.globl main
main:
pushl %EBP
movl %ESP, %EBP
pushl %EBX
main_bb1:
call input
movl (%EAX), %EAX
movl %EAX, %EBX
call input
movl (%EAX), %EAX
pushl %EAX
pushl %EBX
call gcd
addl $8, %ESP
movl (%EAX), %EAX
pushl %EAX
call output
addl $4, %ESP
main_bb2:
popl %EBX
movl %EBP, %ESP
popl %EBP
ret