You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in section 2.6,you noted "something simple and very common like inc rax takes one byte".
In the x86_64 architecture, the machine code for the inc rax instruction is actually \x48\xff\xc0 and inc eax is \xff\xc0, which is not 1 byte long. The confusion likely arises from mixing up with the 32-bit version of the instruction.
In the x86 (32-bit) architecture, the instruction inc eax has the machine code \x40, which is indeed 1 byte. However, when moving to the x86_64 (64-bit) architecture, the instruction inc rax requires a REX prefix (\x48), followed by \xff\xc0, making the total size 3 bytes.
To clarify:
In x86 (32-bit): inc eax machine code is \x40 (1 byte).
In x86_64 (64-bit): inc rax machine code is \x48\xff\xc0 (3 bytes), with the \x48 prefix indicating the use of the 64-bit register (rax instead of eax).
This distinction is important for understanding how machine code differs between 32-bit and 64-bit architectures. Therefore, the statement that "inc rax takes 1 byte" should be corrected to reflect that it actually requires 3 bytes in x86_64.
The text was updated successfully, but these errors were encountered:
in section 2.6,you noted "something simple and very common like inc rax takes one byte".
In the x86_64 architecture, the machine code for the inc rax instruction is actually \x48\xff\xc0 and inc eax is \xff\xc0, which is not 1 byte long. The confusion likely arises from mixing up with the 32-bit version of the instruction.
In the x86 (32-bit) architecture, the instruction inc eax has the machine code \x40, which is indeed 1 byte. However, when moving to the x86_64 (64-bit) architecture, the instruction inc rax requires a REX prefix (\x48), followed by \xff\xc0, making the total size 3 bytes.
To clarify:
In x86 (32-bit): inc eax machine code is \x40 (1 byte).
In x86_64 (64-bit): inc rax machine code is \x48\xff\xc0 (3 bytes), with the \x48 prefix indicating the use of the 64-bit register (rax instead of eax).
This distinction is important for understanding how machine code differs between 32-bit and 64-bit architectures. Therefore, the statement that "inc rax takes 1 byte" should be corrected to reflect that it actually requires 3 bytes in x86_64.
The text was updated successfully, but these errors were encountered: