Difference between SHL and SAL in 80x86

Hossein Mobasher picture Hossein Mobasher · Dec 4, 2011 · Viewed 45.6k times · Source

I have learned how to work with 80x86 assembler, so in bit-wise shift operation, I faced a problem with SAL and SHL usage. I means the difference between lines of code as follow :

MOV X, 0AAH
SAL X, 4

MOV X, 0AAH
SHL X, 4

When we should use SHL and when use SAL? What is the difference of them?

Answer

Mysticial picture Mysticial · Dec 4, 2011

According to this, they are the same:

The shift arithmetic left (SAL) and shift logical left (SHL) instructions perform the same operation; they shift the bits in the destination operand to the left (toward more significant bit locations). For each shift count, the most significant bit of the destination operand is shifted into the CF flag, and the least significant bit is cleared (see Figure 7-7 in the Intel®64 and IA-32 Architectures Software Developer'sManual, Volume 1).

Both were probably included just for completeness since there is a distinction for right-shifts.