GUESS .set 64h
*
.text
SQRT SST
ST0
SST1
ST1
LDPK
0
SSXM
SPM 1
SACL
NUMBER
LARP
AR1
LARK
AR1,11
LALK
800h
SACL
GUESS
SACL
TEMPR
SACH
ROOT
LAC
NUMBER
SBLK
200h
BLZ
SQRTLP
LAC
GUESS,3
SACL
GUESS
SACL
TEMPR
LARK
AR1,14
*
*
SQUARE ROOT LOOP
*
SQRTLP SQRA TEMPR
ZALH NUMBER
SPAC
BLZ
NEXTLP
ZALH TEMPR
SACH ROOT
NEXTLP LAC
GUESS,15
SACH GUESS
ADDH ROOT
SACH TEMPR
BANZ SQRTLP
LAC
ROOT
LST1 ST1
LST
ST0
RET
The hardware stack is allocated for use in interrupts, subroutine calls, pipe-
lined instructions, and debugging. The TMS320C2x disables all interrupts
when it takes an interrupt trap. If interrupts are enabled more than one instruc-
tion before the return of the interrupt service routine, the routine can also be
interrupted, thus using another level of the hardware stack. This condition
should be considered when managing the use of the stack. When nesting sub-
routine calls, each call uses a level of the stack. The number of levels used by
the interrupt must be remembered as well as the depth of the nesting of sub-
routines. One level of the stack is reserved for debugging, to be used for break-
point/single-step operations. If debugging is not used, this extra level is avail-
able for internal use.
; SQUARE ROOT OF X*
; SAVE STATUS REGISTER ST0.
; SAVE STATUS REGISTER ST1.
; LOAD DATA PAGE POINTER = 0.
; SET SIGN-EXTENSION MODE.
; LEFT-SHIFT PR OUTPUT TO ACCUMULATOR.
; SAVE X.
; INITIALIZE VARIABLES FOR SQUARE ROOT.
; 12 ITERATIONS
; ASSUME X IS LESS THAN 200h.
; SET INITIAL GUESS TO 800h.
; SET FIRST INTERMEDIATE ROOT TO 800h.
; SET SQUARE ROOT VALUE TO 0.
; LOAD X INTO THE ACCUMULATOR.
; TEST IF X IS LESS THAN 200h.
; IF YES, TAKE THE ROOT;
; IF NO, THEN REINITIALIZE.
; SET INITIAL GUESS TO 4000h.
; SET FIRST INTERMEDIATE ROOT TO 4000h.
; 15 ITERATIONS
; SQUARE TEMPORARY (INTERMEDIATE) ROOT.
; CHECK IF RESULT IS LESS THAN X.
; IF IT'S NOT, SKIP ROOT UPDATE.
; IF IT IS, SET ROOT EQUAL TEMPR.
; SCALE DOWN GUESS BY 2 TO CONVERGE.
; ADD CURRENT ROOT ESTIMATE.
; UPDATE TEMPORARY ROOT VALUE.
; REPEAT SPECIFIED NO. OF ITERATIONS.
; LOAD THE ROOT OF X.
; RESTORE STATUS REGISTER ST1.
; RESTORE STATUS REGISTER ST0.
Program Control
5-23
Need help?
Do you have a question about the TMS320C2x and is the answer not in the manual?