2

I understood the difference between movz and movs. movz fills the empty bytes with zeros while movs fills them with sign bit (zeros or ones).

However, I came accross the following example

  1. movabsq $0x0011223344556677, %rax
  2. movb $0xAA, %dl
  3. movb %dl, %al
  4. movsbq %dl, %rax

After line 3, %rax = 00112233445566AA. I undertood untill this. But I could not get why %rax is equal to FFFFFFFFFFFFFFAA after line 4. Shouldn't it be 00000000000000AA because empty bits are filled with zero as %dl is positive ?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 5
    `%dl` is not positive. `0xAA` has the sign bit set. That will be used to fill the extended bits. – Jester Oct 07 '21 at 13:08
  • 2
    0xAA, as a signed byte, is -86. 0xFFFFFFFFFFFFFFAA is also -86. As a signed byte, any hex value at or above 0x80 is negative. Positive values for signed byte range from 0x00 to 0x7F, and negative from 0x80 to 0xFF. – Erik Eidt Oct 07 '21 at 13:14

0 Answers0