-
Notifications
You must be signed in to change notification settings - Fork 0
/
reversed_bits.s
78 lines (78 loc) · 1.29 KB
/
reversed_bits.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
.file "reversed_bits.c"
.text
.globl reverseBits
.type reverseBits, @function
reverseBits:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl %edi, -20(%rbp)
movl $32, -4(%rbp)
movl $0, -12(%rbp)
movl $0, -8(%rbp)
jmp .L2
.L3:
movl -8(%rbp), %eax
andl -20(%rbp), %eax
movl %eax, %esi
xorl $2, %esi
movl -8(%rbp), %eax
movl -4(%rbp), %edx
movl %edx, %ecx
subl %eax, %ecx
movl %ecx, %eax
subl $1, %eax
movl %esi, %edx
movl %eax, %ecx
sall %cl, %edx
movl %edx, %eax
orl %eax, -12(%rbp)
addl $1, -8(%rbp)
.L2:
movl -8(%rbp), %eax
cmpl -4(%rbp), %eax
jb .L3
movl -12(%rbp), %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size reverseBits, .-reverseBits
.section .rodata
.LC0:
.string "%u"
.text
.globl main
.type main, @function
main:
.LFB1:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl $2, -4(%rbp)
movl -4(%rbp), %eax
movl %eax, %edi
call reverseBits
movl %eax, %esi
movl $.LC0, %edi
movl $0, %eax
call printf
call getchar
movl $0, %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE1:
.size main, .-main
.ident "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3"
.section .note.GNU-stack,"",@progbits