beautypg.com

Motorola DSP96002 User Manual

Page 567

background image

B-48

DSP96002 USER’S MANUAL

MOTOROLA

--- ---

Totals: 4 4

2.

Static rotate right 1-32 bits. The 32 bit integer to be rotated is in d0.l. The number of bits to
rotate is N. The resulting carry is the value of bit N-1 of the register. For example, if N=3 (three
bit rotate right), then the resulting carry will be the value of bit 2 of the register.

Program ICycles

Words

ror d0 d0.l,d1.l ;shift in carry, copy input 1 1

lsr #N-1,d0 ;shift up, pad with zeros 1 1

lsl #33-N,d1 ;shift down, set carry 1 1

or d1,d0 ;put numbers back together 1 1

--- ---

Totals: 4 4

3.

Dynamic rotate left 0-32 bits. The 32 bit integer to be rotated is in d0.l. The number of bits to
rotate is in d2.l. In the following example, the code for checking if the shift count is zero may
be eliminated if it is known that the shift count is greater than zero.

Program ICycles

Words

tst d2 ;see if shift count is zero 1 1

jeq _done ;yes, done 2 2

rol d0 d0.l,d1.l ;shift in carry, copy input 1 1

dec d2 #32,d3.l ;dec shift count, get 32 2 2

sub d2,d3 d2.l,d0.h ;get 32-shift, move count 1 1

lsl d0,d0 d3.l,d1.h ;shift, move shift count 1 1

lsr d1,d1 ;shift, set carry 1 1

or d1,d0 ;or bits together 1 1

_done --- ---

Totals: 10 10

4.

Dynamic rotate right 0-32 bits. The 32 bit integer to be rotated is in d0.l. The number of bits
to rotate is in d2.l. In the following example, the code for checking if the shift is zero count may
be eliminated if it is known that the shift count is greater than zero.

Program ICycles

Words

tst d2 ;see if shift count is zero 1 1 jeq

_done ;yes, done 2 2 ror d0

d0.l,d1.l ;shift in carry, copy input 1 1 dec d2 #32,d3.l

;dec shift count, get 32 2 2 sub d2,d3 d2.l,d0.h ;get

32-shift, move count 1 1 lsr d0,d0 d3.l,d1.h ;shift,

move shift count 1 1 lsl d1,d1 ;shift, set

carry 1 1 or d1,d0 ;or bits together

1 1 _done --- ---