Some kind of typo in Intel manuals, or my interpretation is wrong.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm just trying to understand the AMD64 instruction format to write a
codegen for this architecture someday. I've a problem understanding
the description of the ADD instruction given in the manual[1] referring.

REX + 80 /0 ib ADD r/m8,imm8 Add sign-extended imm8 to r/m64

Using above description I generated following instruction bytes:

1: .byte 0x48, 0x31, 0xc0 # xor %rax, %rax
2: .byte 0x40, 0x80, 0xc0, 0xf0 # add $0xf0, %rax

My interpreation of above instruction is following:

1: zeroes the RAX register.
2: Adds sign-extended 0xf0 to RAX, which means RAX =0xfffffffffffffff0.

When I executed above instructions in gdb, after 2nd statement, RAX = 0xf0 .

So can someone pinpoint, what is wrong here ?

References:

1. IA-32 SDM Vol. 2A, Instruction Set: A-M
http://www.intel.com/design/processor/manuals/253666.pdf

TIA
- --
Ashish Shukla आशीष शुक्ल http://wahjava.wordpress.com/
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHSICjHy+EEHYuXnQRAvZJAKDFqCRT8rX4iKmDhHgLXzwyGAJkWwCZAQgn
eTGXHLsqBuZx4jMil57IUAs=
=02bM
-----END PGP SIGNATURE-----

.



Relevant Pages

  • Compiler error with Inline assembly
    ... mov rax, ... no instruction mnemonic suffix given and no register operands; ...
    (comp.os.linux.development.apps)
  • Re: if ax eq 0
    ... instruction in the dependency chain" part is true in any mode, ... the dependency of rax on the result of the instruction. ... Macro-op fusion does not happen in 64-bit mode, ...
    (comp.lang.asm.x86)
  • Re: if ax eq 0
    ... instruction in the dependency chain" part is true in any mode, ... the dependency of rax on the result of the instruction. ... Macro-op fusion does not happen in 64-bit mode, ...
    (comp.lang.asm.x86)
  • Re: if ax eq 0
    ... because my newest CPU is a AMD32-Tbred. ... instruction in the dependency chain" part is true in any mode, ... the dependency of rax on the result of the instruction. ...
    (comp.lang.asm.x86)