Shift left and Shift right instruction are used to move bits in a register ,This will used for multiplication and division of registers.
Example Shift left DLX program
1: ;before execution r1=3=0000 0011
2: ;before execution r2=0=0000 0000
3: .start main
4: main:
5: addi r1,r0,3 ;r1=3
6: slai r2,r1,2 ;move 2 bits left from R1 and save it to R2
7: halt
8: ;After execution r1=3=0000 0011
9: ;After execution r2=0=0000 1100
Example Shift Right DLX program
1: ;before execution r1=2=0000 0010
2: ;before execution r2=0=0000 0000
3: .start main
4: main:
5: addi r1,r0,2 ;r1=2
6: srai r2,r1,1 ;move 2 bits right from R1 and save it to R2
7: halt
8: ;After execution r1=2=0000 0010
9: ;After execution r2=1=0000 0001
Shift DLX program commands
Shift right Arithmatic
sra rk,ri,rj rk
Shift right Arithmatic Immediate
srai rj,ri,u rj
Shift right Logical
srl rk,ri,rj rk
Shift right logical Immediate
srli rj,ri,u rj
Shift Left Arithmatic
sla rk,ri,rj rk
Shift Left Arithmatic Immediate
slai rj,ri,u rj
Shift light Logical
sll rk,ri,rj rk
Shift light Logical immediate
slli rj,ri,u rj
Tags:Shift left and Shift right instruction on DLX Program,Shift left DLX,Shift Right DLX,DLX program