%ebx寄存器的操作码

时间:2018-10-15 05:09:55

标签: assembly x86 cpu-registers machine-code instruction-set

我编写了以下汇编程序来获取各种寄存器的操作码:

if (hasExperience === true) {
    // only hasExperience is true
    if (amountOfExperience > 5) {
        // hasExperience is true and amountOfExperience is greater than 5
        return true;
    } else {
        // hasExperience is false and amountOfExperience is less than 5
        return false;
    }
} else {
    // hasExperience is false and we have no idea what amountOfExperience is
  return false;
}

我编译并链接到:

.section .text
.globl _start
_start:
add $1,%eax                                                          
add $1,%ebx                                                          
add $1,%ecx                                                          
add $1,%edx                                                          
add $1,%esp                                                             
add $1,%ebp                                                             
add $1,%esi                                                          
add $1,%edi                                                          
int $0x80

对象转储为:


0000000000400078 <_start>:
  400078:   83 c0 01                add    $0x1,%eax
  40007b:   83 c3 01                add    $0x1,%ebx
  40007e:   83 c1 01                add    $0x1,%ecx
  400081:   83 c2 01                add    $0x1,%edx
  400084:   83 c4 01                add    $0x1,%esp
  400087:   83 c5 01                add    $0x1,%ebp
  40008a:   83 c6 01                add    $0x1,%esi
  40008d:   83 c7 01                add    $0x1,%edi
  400090:   cd 80                   int    $0x80

我希望gcc -c prog.s && ld prog.o 拥有操作码%ebx,事实并非如此。所以我的问题是:对于这些c1指令,c3为什么是%ebx的操作码?

0 个答案:

没有答案