Shift Rotate

Shift Right

D3D2D1D0

Every clock pulse, the data will shifted one bit.

  1. 1-bit shift right
0D2D1D0
  1. 2-bit shift right
00D1D0
  1. 3-bit shift right
000D0
  1. 4-bit shift right
0000

Behavior:

Shift Left

Read the D lines from the above in reverse

Behavior:

Rotate Right

  1. 1-bit rotate right
D0D3D2D1
  1. 2-bit rotate right
D0D1D3D2
  1. 3-bit rotate right
D2D0D1D3
  1. 4-bit rotate right
D3D2D1D0

Behavior:

Rotate Left

You get the drill, just use the same circuit but read different D inputs right-to-left.

Example: How-to Copy A to B?

A3A2A1A0
B3B2B1B0

Examples: Commands

Suppose this 5-address instruction command does R1 <- R2 + R3:

OperationOperand 1Operand 2Operand 3Next Instruction Address
ADDR1R2R30x1234

One optimization is to have the next instruction address stored in its own register.

This is a 4-address instruction command that does R1 <- R2 + R3:

OperationOperand 1Operand 2Operand 3
ADDR1R2R3

How about another reduction? This one will do R1 <- R1 + R2

OperationOperand 1Operand 2
ADDR1R2

If we use a default register like ACC (Accumulator), we can do two-address: ACC <- R1 + ACC

OperationOperand 1
ADDR1

JVM does the extreme, using a stack to make a zero-address language.

Operation
ADD