<<< Sign Extending Signed Value | Index | Sign Extending with MOVSX and MOVZX >>> |
If sign extension was not what you had in mind, that is, if you need to extend the unsigned value, explicitly set the higher register to zero:
.DATA mem8 BYTE 251 mem16 WORD 251 .CODE . . . mov al, mem8 ; Load 251 (FBh) from 8-bit memory sub ah, ah ; Zero upper half (AH) mov ax, mem16 ; Load 251 (FBh) from 16-bit memory sub dx, dx ; Zero upper half (DX) sub eax, eax ; Zero entire extended register (EAX) mov ax, mem16 ; Load 251 (FBh) from 16-bit memory
<<< Sign Extending Signed Value | Index | Sign Extending with MOVSX and MOVZX >>> |