Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TMS320C2x DSP - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

      In numerical analysis, it is often necessary to square numbers along
      with adding and subtracting. The TMS320C2x has two instructions,
      SQRA and SQRS, that accomplish this in a single machine cycle. The
      result of the previous operation in the PR is first added to the
      accumulator if SQRA is used, or subtracted if SQRS is used. Then the
      data value addressed is squared, and the result is stored in the PR.
      The following illustrates the SQRA instruction:

*  THIS ROUTINE USES THE SQRA INSTRUCTION TO COMPUTE
*  THE SQUARE OF THE DISTANCE BETWEEN TWO POINTS WHERE D**2
*  IS DEFINED AS FOLLOWS:
*
*       D**2 = (XA - XB)**2 + (YA - YB)**2
*
DIST  LAC   XA
      SUB   XB
      SACL  XT          ; XT = XA - XB
*
      LAC   YA
      SUB   YB
      SACL  YT          ; YT = YA - YB
*
      SQRA  XT          ; (P) = XT**2
      ZAC               ; (ACC) = 0
      SQRA  YT          ; (P) = YT**2, (ACC) = XT**2
      APAC              ; (ACC) = XT**2 + YT**2 = D**2
*
      RET               ; RETURN TO MAIN PROGRAM.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson