I was debugging a program. When the register di=0x01, cl=0x11, The instruction "shl di,cl" will actually make di=0x1.
Shouldn't the bits that slide off the end disappear?
Reverse Engineering Stack Exchange is a question and answer site for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation. It only takes a minute to sign up.Sign up to join this community
(Disregarding the example in the question as it clearly has typos.)
The higher bits of the shift amount are ignored, unless you're running your program on an original 8086: See "IA-32 Architecture Compatibility" at the bottom of the page.
Full disclosure: I am the author of the following article.
The aim of the article is to provide the reader with a detailed, example- and code-laden explanation of exactly how the shift and rotate instructions work in both x86 and x64 contexts. The examples therein are directly applicable to OP's inquiry.
SHL and SHR work using the following syntax dest, count
now di is a 16 bit register and CL is basically the count (3)
so you are right it should be zeroed out and you can prove this by using a online x86 emulator
and enter the following asm instructions: mov di, 01h mov cl, 11h shl di, cl
so i dont know what would make it behave this way.