Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 尝试将switch语句的汇编指令转换为c代码_Assembly_Switch Statement_Translate - Fatal编程技术网

Assembly 尝试将switch语句的汇编指令转换为c代码

Assembly 尝试将switch语句的汇编指令转换为c代码,assembly,switch-statement,translate,Assembly,Switch Statement,Translate,我试图为这个函数的汇编指令找到等效的c代码 装配说明: 0x400698: 0x00000000004005ad 0x00000000004005c3 0x4006a8: 0x00000000004005c3 0x00000000004005c3 0x4006b8: 0x00000000004005a8 0x00000000004005be 0x4006c8: 0x00000000004005a8 0x00000000004005b7 0x000000000040057c

我试图为这个函数的汇编指令找到等效的c代码

装配说明:

0x400698: 0x00000000004005ad 0x00000000004005c3  
0x4006a8: 0x00000000004005c3 0x00000000004005c3  
0x4006b8: 0x00000000004005a8 0x00000000004005be  
0x4006c8: 0x00000000004005a8 0x00000000004005b7


   0x000000000040057c <+0>:     push   %rbp
   0x000000000040057d <+1>:     mov    %rsp,%rbp
   0x0000000000400580 <+4>:     mov    %rdi,-0x18(%rbp)
   0x0000000000400584 <+8>:     mov    %rsi,-0x20(%rbp)
   0x0000000000400588 <+12>:    mov    -0x20(%rbp),%rax
   0x000000000040058c <+16>:    mov    %rax,-0x8(%rbp)
   0x0000000000400590 <+20>:    mov    -0x18(%rbp),%rax
   0x0000000000400594 <+24>:    sub    $0x52,%rax
   0x0000000000400598 <+28>:    cmp    $0x7,%rax
   0x000000000040059c <+32>:    ja     0x4005c3 <switch_prob+71>
   0x000000000040059e <+34>:    mov    0x400698(,%rax,8),%rax
   0x00000000004005a6 <+42>:    jmpq   *%rax
   0x00000000004005a8 <+44>:    subq   $0xa,-0x8(%rbp)
   0x00000000004005ad <+49>:    movq   $0x3e,-0x8(%rbp)
   0x00000000004005b5 <+57>:    jmp    0x4005cb <switch_prob+79>
   0x00000000004005b7 <+59>:    sarq   $0x4,-0x8(%rbp)
   0x00000000004005bc <+64>:    jmp    0x4005cb <switch_prob+79>
   0x00000000004005be <+66>:    subq   $0x1,-0x8(%rbp)
   0x00000000004005c3 <+71>:    movq   $0x3b,-0x8(%rbp)
   0x00000000004005cb <+79>:    mov    -0x8(%rbp),%rax
   0x00000000004005cf <+83>:    pop    %rbp
   0x00000000004005d0 <+84>:    retq

在sub$82之后,它检查结果是否大于7。如果是,则转到默认情况。否则它会跳转到跳转表中,因此案例数为82-89。这些案例中的一些具有相同的代码,而另一些案例也属于以下情况

long switch_prob(long x, long n){
    long result = n;
    switch(x){
        case 82:
            break;
        case 7:
            break;
        case 89:
            break;
        case 59:
            break;
        case 87:

        default:
            break;
    }
    return result;
}