1、兰州交通大学毕业设计(论文) - 1 - 11 Shift Instructions 11.1 Overview of Shift Instructions 11.1.1 Description You can use the Shift instructions to move the contents of input IN bit by bit to the left or the right (see also CPU Registers).Shifting to the left multiplies the contents of input IN by 2 to the powe
2、r n (2n);shifting to the right divides the contents of input IN by 2 to the power n (2n). The number that you supply for input parameter N indicates the number of bits by which to shift.The bit places that are vacated by the Shift instruction are either filled with zeros or with the signal state of
3、the sign bit (a0 stands for positive and a1 stands for negative).The signal state of the bit that is shifted last is loaded into the CC1 bit of the status word.The CC0 and OV bits of the status word are reset to 0.You can use jump instructions to evaluate the CC1 bit. The following shift instruction
4、s are available: SHR_I Shift Right Integer SHR_DI Shift Right Double Integer SHL_W Shift Left Word SHR_W Shift Right Word SHL_DW Shift Left Double Word SHR_DW Shift Right Double Word 11.2 SHR_I Shift Right Integer 11.2.1 Symbol E NINNO U TE N OSH R _I Paramete Data Type Memory Area Description EN BO
5、OL I、 Q、 M、 L、 D Enable input ENO BOOL I、 Q、 M、 L、 D Enable output IN INT I、 Q、 M、 L、 D Value to shift N WORD I、 Q、 M、 L、 D Number of bit positions to shift OUT INT I、 Q、 M、 L、 D Result of shift instruction 兰州交通大学毕业设计(论文) - 2 - 11.2.2 Description SHR_I(Shift Right Integer) is activated by a logic 1
6、at the Enable (EN) Input.The SHR_I instruction is used to shift bits 0 to 15 of input IN bit by bit to the right.Bits 16 to 31 are not affected.The input N specifies the number of bits by which to shift.If N is larger than 16,the command acts as if N were equal to 16.The bit positions shifted in fro
7、m the left to fill vacated bit positions are assigned the logic state of bit 15 (sign bit for the integer).This means these bit positions are assigned 0 if the integer is positive and 1 if the integer is negative. The result of the shift instruction can be scanned at output OUT.The CC0 bit and the O
8、V bit are set to 0 by SHR_I if N is not equal to 0. ENO has the same signal state as EN. 1 0 1 01 1 1 1 1 0 1 00 0 0 01 1 1 11 1 1 11 0 1 00 0 0 01 0 1 01 5 . . .I NNO U TT h e v a c a t e d p l a c e s a r ef i l l e d w i t h t h e s i g n a l s t a t eo f t h e s i g n b i t .T h e s e f o u r b
9、i t s a r e l o s t .7 . . . . . 0. . . 8S i g n b i t4 p l a c e s 11.2.3 Example E NI NNO U TE N OS H R _ II 0 . 0M W 0M W 2M W 4( S )Q 4 . 0 The SHR_I box is activated by logic 1 at I0.0.MW0 is loaded and shifted right by the number of bits specified with MW2.The result is written to MW4. 4.0 is set. 11.3 SHR_DI Shift Right Double Integer 11.3.1 Symbol E NINNO U TE N OSH R _D I