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?
(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.
Accessing and Modifying Upper Bits in x86 and x64 Registers
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
http://carlosrafaelgn.com.br/asm86/
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.
rol
andror
. The instructionshr
does however keep the sign bit if it's set.