SAL?
Seairth
Posts: 2,474
in Propeller 2
How is SAL supposed to work? How does it differ from SHL?
Comments
Not sure in the case of the P2.
What's the use case for this?
Note that the binary values of the opcodes of ROR, ROL, SHR, SHL, RCR, RCL, SAR, and SAL. They are all the same except for bits 23-21. Bit 21 means L if 1 and R if 0. Bits 23 and 22 presumably go to a mux or something which decides where the new bits that get shifted in come from. The meanings of bits 23-22 are as follows: (0) whatever got shifted out (rotate), (1) all 0 (shift), (2) the value of the C flag (RCx), or (3) the value of result[31] for R or result[0] for L (sign-extend shift).
Removing the SAL instruction would mean telling the instruction decoder that if the instruction matched %CCCC_0000111_CZI_DDDDDDDDD_SSSSSSSSS it should disregard the output of the shifter and instead do something undefined.
What would be more useful would be a sign extend instruction IMHO.
It may have no mathematical purpose, but could find use somewhere.
It was free, anyway.
Not sure what it should be called, but definitely not SAL.
It should be called NOTSAR
I like "RAS" better.
I agree.
Would could just stop using 'A'rithmetic in 'SAR' and, instead, have some mnemonics that mean 'extend'.
SER - shift extend right
SEL - shift extend left
-or-
SMR - smear right
SML - smear left
Why can't we keep SAR, and just rename SAL?
What should we call it?
So that could be Shift Left duplicating b0 = SL0
Of course, many may misread 0 as O, so it could also be
Shift Left duplicating Lowest = SLL
It is still Clearly a Shift Left operation.
Or maybe SLR for shift left replicate LSB.
I kind of like SMR/SML the best, because a child could understand them.
ie SMR/SML and also SAR work.
SEL also works.
Also, I still can't think of a real use case for it...
Then, it's multiplication by power of 2 for signed numbers...
I guess it should set a flag if msb would have otherwise changed
A change would indicate overflow, I think...
Right justified masks can be built of varied lengths
shift number of bits - 1
So, I guess the answer is still, there is no such thing as a real SAL instruction.