【发布时间】:2015-10-28 01:39:44
【问题描述】:
我很难将 switch 语句从汇编代码逆向工程为 C 程序。
.file
"switch_prob2-soln.c"
.text
.globl switch_prob
.type switch_prob, @function
switch_prob:
.LFB0:
.cfi_startproc
subq $60, %rsi
cmpq $5, %rsi
ja .L2
jmp *.L7(,%rsi,8)
.section .rodata
.align 8
.align 4
.L7:
.quad .L3
.quad .L2
.quad .L3
.quad .L4
.quad .L5
.quad .L6
.text
.L3:
leaq 0(,%rdi,8), %rax
ret
.L4:
movq %rdi, %rax
sarq $3, %rax
ret
.L5:
movq %rdi, %rax
salq $4, %rax
subq %rdi, %rax
movq %rax, %rdi
.L6:
imulq %rdi, %rdi
.L2:
leaq 75(%rdi), %rax
ret
.cfi_endproc
.LFE0:
.size switch_prob, .-switch_prob
.ident "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
.section .note.GNU-stack,"",@progbits
这是我拥有的基本 C 程序:
long switch_prob(long x, long n)
{
long result = x;
switch(n) {
}
return result;
}
我所要求的只是入门的有用建议。我知道我可以使用 -S 或 -O1 进行编译。感谢您的宝贵时间。
这是我的 c 代码在汇编中显示的内容
这是我的 c 代码
如果有人可以帮助我,那就太棒了,我正在尝试让四边形显示 3 2 3 4 5 6
【问题讨论】:
标签: c assembly switch-statement reverse-engineering