Manipulating bits and bytes
7KH IROORZLQJ FRPPDQGV HQDEOH \RX WR PDQLSXODWH ELQDU\ LQWHJHUV RQH ELW
RU RQH E\WH DW D WLPH 7KH FRPPDQGV DUH DYDLODEOH E\ SUHVVLQJ >ì
>ì
8QOHVV RWKHUZLVH VWDWHG HDFK H[DPSOH DVVXPHV WKH
25
%<7(
ZRUGVL]H LV VHW WR
Commands
ASR Arithmetic Shift Right. Per-
forms 1 bit arithmetic right shift.
The most significant bit is regener-
ated.
RL Rotate Left. Binary integer
rotates left one bit. (The example
assumes that the wordsize is 4.)
RLB Rotate Left Byte. Binary inte-
ger rotates left one byte.
RR Rotate Right. Binary integer
rotates right one bit. (The example
assumes that the wordsize is 4.)
RRB Rotate Right Byte.
Binary integer rotates right one
byte.
SL Shift Left. Binary integer shifts
left one bit.
SLB Shift Left Byte. Binary integer
shifts left one byte.
SR Shift Right. Binary integer
shifts right one bit.
SRB Shift Right Byte. Binary inte-
ger shifts right one byte.
Page 8-6
Example
Input
# 1100010b
# 1100b
# FFFFh
# 1101b
# A0B0C0h
# 1101b
# A0B0h
# 11011b
# A0B0C0h
%,7
Output
# 110001b
# 1001b
# FFFF00h
# 1110b
C0A0B0h
# 11010b
# A0B000h
# 1101b
# A0B0h
Number bases