SHAR

Arithmetic shift to the right

SHAR

SHift Arithmetic Right


[Syntax]

(1)SHAR src, dest

(2)SHAR src, src2, dest

 

[Operation]

(1)dest = ( signed long ) dest >> ( src & 31 );

(2)dest = ( signed long ) src2 >> ( src & 31 );

 

[Function]

-

(1)This instruction arithmetically shifts dest to the right by the number of bit positions specified by src and saves the value in dest.

-

Bits overflowing from the LSB are transferred to the C flag.

-

src is an unsigned in the range of 0 ? src ? 31.

-

When src is in register, only five bits in the LSB are valid.

-

(2)After this instruction transfers src2 to dest, it arithmetically shifts dest to the right by the number of bit positions specified by src and saves the value in dest.

-

Bits overflowing from the LSB are transferred to the C flag.

-

src is an unsigned integer in the range of 0 ? src ? 31.

 

[Instruction Format]

Syntax

Processng Size

src

src2

dest

Code size

(Byte)

(1)SHAR src, dest

L

#IMM:5

Rd

2

L

Rs

Rd

3

(1)SHAR src, src2, dest

L

#IMM:5

Rs

Rd

3

[Flag Change]

Flag

C

Z

S

O

Change

 

 

 

 

Conditions

C : The flag is set if the shifted-out bit is 1; otherwise it is cleared. However, when src is 0, this flag is also cleared.

Z : The flag is set if dest is 0 after the operation; otherwise it is cleared.

S : The flag is set if the MSB of dest after the operation is 1; otherwise it is cleared.

O : The flag is cleared to 0.

 

[Description Example]

SHAR #3, R2

SHAR R1, R2

SHAR #3, R1, R2