Byte rotation instructions in assembler

Programming, for all ages and all languages.
Post Reply
ManOfSteel

Byte rotation instructions in assembler

Post by ManOfSteel »

Hello,
I was re-reading an old assembler programming book when I saw something that I've never really though of before. I saw that the byte rotation instructions (shl, shr, sal, sar, ...) are used in two ways: when the operand is 1 I use 'shr ax,1' and when it is more than 1, I have to use cl 'mov cl,5 / shr ax,cl'. I checked another book and the Intel manuals and saw the same thing.
Why do I have to use the second way when I have the same result using the first one (shr ax,5)?
Thank you in advance.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Byte rotation instructions in assembler

Post by df »

an XT ism, didnt let you shift beyond 1
but a a 286 or 386 instruction, let you shift by any number..

unless you want compatability with xt/286, use the shift CL method. if you dont think anyone with a PCjr is gonna run it, use the shift ax, 15 method......
-- Stu --
Post Reply