0

Anyone can explain me how the assembly right shift operation works? An example is:

mov ax, 0BFA4h
mov cl, 0Fh
shr ax, cl

The result is: ax=5FD2

But if I put:

mov ax, 0BFA4h
mov cl, 02Fh 
shr ax, cl

the result isn't ax=0000 but is 0001? Anyone can explain this?

Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
ZBMZ
  • 3
  • 2
  • 3
    `0BFA4h >> 15` is 1, not `5FD2`, so your first example is wrong. Also, 186 and later mask the shift count with `& 1Fh`, so those two shifts are equivalent except on 8086. https://www.felixcloutier.com/x86/sal:sar:shl:shr – Peter Cordes Sep 29 '21 at 18:22

0 Answers0