简体   繁体   English

X86汇编代码从未使用过从内存中加载的值

[英]X86 assembly code never used the loaded value from memory

I am studying the assembly code of a program for my research. 我正在研究用于我的研究的程序的汇编代码。 I've just noticed an assembly code snippet of a JPEG program which is a bit confusing for me. 我刚刚注意到JPEG程序的汇编代码片段,这对我来说有点令人困惑。 At some point a value is loaded into register (%rcx) but again later in the code it is assigned with another value without ever using the previous value. 在某个时候,一个值会被加载到寄存器(%rcx)中,但在代码的稍后部分又会为它分配另一个值,而无需使用以前的值。 Is it something that I am missing or is it a normal thing in the compiler? 是我缺少的东西还是编译器中的正常东西?

I use the gcc 4.7.3 for compiling the code with -O3 optimization. 我使用gcc 4.7.3通过-O3优化来编译代码。 For getting the assembly code I am using the following command: 为了获取汇编代码,我使用以下命令:

objdump --prefix-addresses --disassemble -dSlr objdump-前缀地址--disassemble -dSlr

I have highlighted the part of the code that I am talking about. 我已经强调了我正在谈论的代码部分。

00000000004186d7 <jpc_encsigpass.isra.0+0x847> mov    (%rbx),%rdx
00000000004186da <jpc_encsigpass.isra.0+0x84a> movzbl %dl,%eax
00000000004186dd <jpc_encsigpass.isra.0+0x84d> test   %eax,%eax
00000000004186df <jpc_encsigpass.isra.0+0x84f> je     00000000004181b4
00000000004186e5 <jpc_encsigpass.isra.0+0x855> test   $0x50,%dh
00000000004186e8 <jpc_encsigpass.isra.0+0x858> jne    00000000004181b4

00000000004186ee mov (%r15),%rcx 00000000004186ee mov(%r15),%rcx

00000000004186f1 <jpc_encsigpass.isra.0+0x861> mov    %ecx,%edi
00000000004186f3 <jpc_encsigpass.isra.0+0x863> sar    $0x1f,%edi
00000000004186f6 <jpc_encsigpass.isra.0+0x866> xor    %edi,%ecx
00000000004186f8 <jpc_encsigpass.isra.0+0x868> sub    %edi,%ecx
00000000004186fa <jpc_encsigpass.isra.0+0x86a> test   %ecx,0x94(%rsp)
0000000000418701 <jpc_encsigpass.isra.0+0x871> setne  %cl
0000000000418704 <jpc_encsigpass.isra.0+0x874> or     0x98(%rsp),%eax
000000000041870b <jpc_encsigpass.isra.0+0x87b> movzbl %cl,%ecx
000000000041870e <jpc_encsigpass.isra.0+0x87e> cltq   
0000000000418710 <jpc_encsigpass.isra.0+0x880> movslq 0x669ba0(,%rax,4),%rdi
0000000000418718 <jpc_encsigpass.isra.0+0x888> mov    0x20(%rbp),%rax
000000000041871c <jpc_encsigpass.isra.0+0x88c> lea    (%rax,%rdi,8),%rax
0000000000418720 <jpc_encsigpass.isra.0+0x890> mov    %rax,0x28(%rbp)
0000000000418724 <jpc_encsigpass.isra.0+0x894> mov    (%rax),%rax
0000000000418727 <jpc_encsigpass.isra.0+0x897> cmp    0x8(%rax),%ecx
000000000041872a <jpc_encsigpass.isra.0+0x89a> je     0000000000418188
0000000000418730 <jpc_encsigpass.isra.0+0x8a0> mov    %rbp,%rdi
0000000000418733 <jpc_encsigpass.isra.0+0x8a3> mov    %rdx,0x30(%rsp)
0000000000418738 <jpc_encsigpass.isra.0+0x8a8> mov    %ecx,0x28(%rsp)
000000000041873c <jpc_encsigpass.isra.0+0x8ac> mov    %rsi,0x20(%rsp)
0000000000418741 <jpc_encsigpass.isra.0+0x8b1> mov    %r8,0x18(%rsp)
0000000000418746 <jpc_encsigpass.isra.0+0x8b6> mov    %r9,0x10(%rsp)
000000000041874b <jpc_encsigpass.isra.0+0x8bb> mov    %r10,(%rsp)
000000000041874f <jpc_encsigpass.isra.0+0x8bf> mov    %r11,0x8(%rsp)
0000000000418754 <jpc_encsigpass.isra.0+0x8c4> callq  0000000000421600 <jpc_mqenc_codelps>
0000000000418759 <jpc_encsigpass.isra.0+0x8c9> mov    0x28(%rsp),%ecx
000000000041875d <jpc_encsigpass.isra.0+0x8cd> mov    0x8(%rsp),%r11
0000000000418762 <jpc_encsigpass.isra.0+0x8d2> mov    (%rsp),%r10
0000000000418766 <jpc_encsigpass.isra.0+0x8d6> mov    0x10(%rsp),%r9
000000000041876b <jpc_encsigpass.isra.0+0x8db> mov    0x18(%rsp),%r8
0000000000418770 <jpc_encsigpass.isra.0+0x8e0> mov    0x20(%rsp),%rsi
0000000000418775 <jpc_encsigpass.isra.0+0x8e5> test   %ecx,%ecx
0000000000418777 <jpc_encsigpass.isra.0+0x8e7> mov    0x30(%rsp),%rdx
000000000041877c <jpc_encsigpass.isra.0+0x8ec> je     00000000004181ab
0000000000418782 <jpc_encsigpass.isra.0+0x8f2> cmpl   $0x0,0x9c(%rsp)

000000000041878a mov 0x160(%rsp),%rcx 000000000041878A MOV 0x160(%RSP),%RCX

0000000000418792 <jpc_encsigpass.isra.0+0x902> mov    (%r15),%rax
0000000000418795 <jpc_encsigpass.isra.0+0x905> mov    (%rcx),%rdi
0000000000418798 <jpc_encsigpass.isra.0+0x908> mov    %eax,%ecx

The first instruction you've highlighted loads a value into rcx . 您突出显示的第一条指令将值加载到rcx The next instruction uses the value in ecx , which is the 32 least significant bits of rcx . 下一条指令使用ecx的值,它是rcx的32个最低有效位。

The second instruction you've highlighted loads a value into rcx , then uses it as an address two instructions later (the mov (%rcx), %rdi ). 您突出显示的第二条指令将一个值加载到rcx ,然后在两条指令之后将其用作地址( mov (%rcx), %rdi )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM