3 ms·
Two distinct opcode extensions for SAL/SHL How those came about is pretty straightforward: SHR - shift right with zero-fill SAR - shift right with sig
by userbinator 9y ago
Two distinct opcode extensions for SAL/SHL
How those came about is pretty straightforward:
SHR - shift right with zero-fill
SAR - shift right with sign-fill
SHL - shift left with zero-fill
SAL - shift left with sign-fill
Of course, the sign-fill hardware is useless for left shift, so we effectively have two opcodes doing the same thing. The Z80 has a similar instruction, except that it, more oddly, always inserts a 1 in the LSB.
- JdeBP 9y agoVHDL has an arithmetic shift that duplicates in the LSB.
- DSMan195276 9y agoThis is a small note, but IIRC that instruction on the z80 is actually undocumented. It's easy to tell what it should be though since all the shifts are the same opcode except for two bits representing the direction and type (arithmetic/logical). But that would be why the behavior is so weird - it's just whatever happens in the CPU when both those settings happen to be set.
- 0xcde4c3db 9y agoIn a similar vein, some processors have encodings for branch conditions that work out along the lines of: Branch if zero Branch if nonzero Branch if less than zero Branch if greater than zero Branch if greater than or equal to zero Branch if less than or equal to zero Branch always Branch never (actually documented on the Motorola 68HC11, I believe)
- userbinator 9y agoBranch never (actually documented on the Motorola 68HC11, I believe) The early ARM cores which have conditional execution of all instructions had a corresponding "never" condition, but in the later revisions they decided that 16 million different NOP instructions was not a good use of opcode space and reused that as an extension for new instructions.