-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhileassembly.s
More file actions
executable file
·67 lines (56 loc) · 816 Bytes
/
whileassembly.s
File metadata and controls
executable file
·67 lines (56 loc) · 816 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
67
.data
.LC0:
.string "Hi!\n"
.LC1:
.string "i = %d\n"
#
# main:
.text
.global main
main:
pushl %ebp
movl %esp, %ebp
# %T1 = MOV $0
movl $0, %eax
movl %eax, -4(%ebp)
# BB1:
BB1:
# CMP %T1, $10
movl -4(%ebp), %eax
cmpl $10, %eax
# BRGE BB3
jge BB3
# BB2:
BB2:
# ARGBEGIN 1
subl $8, %esp
# ARG "Hi!\n"
movl $.LC0, %eax
movl %eax, 0(%esp)
# %T2 = CALL printf
call printf
movl %eax, -8(%ebp)
# ARGBEGIN 2
subl $12, %esp
# ARG "i = %d\n"
movl $.LC1, %eax
movl %eax, 0(%esp)
# ARG %T1
movl -4(%ebp), %eax
movl %eax, 4(%esp)
# %T3 = CALL printf
call printf
movl %eax, -12(%ebp)
# %T1 = ADD %T1, $1
movl -4(%ebp), %eax
movl $1, %edx
add %eax, %edx
movl %edx, -4(%ebp)
# JMP BB1
jmp BB1
# BB3:
BB3:
# RETURN
leave
ret
#