Reputation: 303
I'm looking at these problems in my book and I am trying to figure out what they mean exactly.
.data
one WORD 8002h
two WORD 4321h
.code
mov edx,21348041h
movsx edx,one
movsx edx,two
^ EDX starts out with a value of 21348041 hex right? Then because of movsx edx adds FFFFF8002 hex? Then edx adds FFFFF4321 hex? Confusing, but I am assuming the book is explaining that movsx converts to signed?
Upvotes: 2
Views: 601
Reputation: 67499
The first one is correct, but not "adds". mov*
moves data.
Because you request the data to be treated as signed, and you're using less than one word of data (assuming a 32 bit architecture), the actual data moved will be padded to the left with 1
if the source number has the left-most bit set (ie negative).
Note the addendum at the end. Because 0x4321
isn't negative (less than 0x8000
), even if you treat it as signed it's still positive. It will move the literal value you give it.
Upvotes: 4