3 ms·
sar/sal is for signed numbers, shr/shl is for unsigned numbers. Which one you want depends on the types you are working on. Also, "sal" and "shl" perform the e
by 0x0 11y ago
sar/sal is for signed numbers, shr/shl is for unsigned numbers. Which one you want depends on the types you are working on.
Also, "sal" and "shl" perform the exact same operation with the exact same side-effects. Some sources seem to hint that "sal" is the one going out of fashion - https://code.google.com/p/corkami/wiki/x86oddities#sal https://code.google.com/p/corkami/wiki/x86oddities#sal and http://stackoverflow.com/a/8373438/2412419 http://stackoverflow.com/a/8373438/2412419
- vardump 11y agoOh, I thought SAL only existed as a mnemonic, I was rather surprised to find out SAL actually has x86 instruction encoding different from SHL!
- userbinator 11y agoIt's an undocumented one, that just happens to fill the encoding space of: - shift right and insert 0 ("logical right") - shift right and insert sign bit ("arithmetic right") - shift left and insert 0 ("logical left") - shift left and insert... 0 ("arithmetic left") ** My guess is that it causes the hardware to attempt to sign-extend and shift left, but the latter means the former doesn't have any effect. The Z80 has a similar gap in the encoding but rather more unusual undocumented behaviour here, where it would shift left and insert a 1 in the lowest bit.