
5-16
Seiko Epson Corporation
S1C17 CORE MANUAL
(REV. 1.2)
5.7 Shift and Swap Instructions
The S1C17 Core supports instructions to shift or swap the register data.
sr
Logical shift right
sl
Logical shift left (= Arithmetic shift left)
sa
Arithmetic shift right
swap
Swap upper and lower bytes
The shift operation is effective for bits 15 to 0 in the specified register and bits 23 to 16 are set to 0.
The number of bits to be shifted can be specified to 0–3 bits, 4 bits, or 8 bits using the operand
imm5
or the
rs
reg-
ister.
%rs
/
imm7
= 0–3:
Shift 0 to 3 bits
%rs
/
imm7
= 4–7:
Shift 4 bits (fixed)
%rs
/
imm7
= 8 or more: Shift 8 bits (fixed)
Example:
sr %rd,1
Bits 15–0 in
%rd
logically shifted one bit to the right
sl %rd,7
Bits 15–0 in
%rd
logically shifted four bits to the left
sa %rd,0xf
Bits 15–0 in
%rd
arithmetically shifted eight bits to the right
15
0
C
rd
sr
Logical shift right
0
0
15
C
rd
15
0
C
rd
sa
Arithmetic shift right
MSB
Sign bit
0
sl
Logical shift left
0 0
0
0
0
0
0
0
23
16
0 0
0
0
0
0
0
0
23
16
0 0
0
0
0
0
0
0
23
16
The
swap
instruction replaces the contents of general-purpose registers with each other, as shown below.
8 7
15
Byte 0
Byte 1
0
rs
8 7
15
Byte 1
Byte 0
0
rd
X X
X
X
X
X
X
X
23
16
0 0
0
0
0
0
0
0
23
16