DSP C perform left shift and right shift operation on a number residing in memory. - Code

Latest

programs

Thursday, November 10, 2011

DSP C perform left shift and right shift operation on a number residing in memory.


SHIFTING

Aim: - To perform left shift and right shift operation on a number residing in memory.

Apparatus: - TMS 320C 5416 processor

Program: -

            .include “5416_IV.asm”
            .data
            .word   0003h,             //  input number //
            .text
            .include “intvect.asm”


Begin   STM    #1000h,AR5   // memory location of first number //
            STM    #1600h,AR2   // memory location of left shifted number //
            STM    #1500h,AR3   // memory location of right shifted number //
            LD       *AR5,A
            LD       *AR5,B
            SFTA  A,-1
            SFTA  B,1
            STL     A,*AR2
            STL     B,*AR3
            .end

Result: - Shifting the number left by one bit is equivalent to multiplying number by 2
               Shifting the number left by one bit is equivalent to dividing number by 2






No comments:

Post a Comment