32 bit registers act as 8 bit ones

前端 未结 1 1104
别跟我提以往
别跟我提以往 2020-12-22 02:05

I\'ve been having the strangest problem. In x86 assembly, the 32 bit registers (eax, ebx, etc.) have been overflowing at 256, suggesting that they\'re actually 8 bit, for so

相关标签:
1条回答
  • 2020-12-22 02:34

    It's not the register wrapping around, it's the exit system call, which only uses the lower eight bits of ebx for the return code.

    From the exit man-page:

    The exit() function causes normal process termination and the value of status & 0377 is returned to the parent (see wait(2)).

    That 0377 is the octal equivalent of 0xff (binary 1111 1111), meaning that only the lower eight bits are used. The other bits in what you get back from wait() (in the parent) are used for things such as whether the child process was terminated, what signal was used if so, whether a core dump occurred, and so on.

    0 讨论(0)
提交回复
热议问题