/* This assembly file contains various support routines that are used throughout the libraries. The Run Time Library for the C Language. Gordon A. Sterling (617) 461 - 3076 DSP Development Tools Engineering Created on 1/2/93 Updated on 3/95 by AS - separated functions */ #include "lib_glob.h" #include "str_glob.h" .SEGMENT/CODE Code_Space_Name; .FILE RTL_FILENAME; /* This routine determines the length of an input string that is located in program memory (___lib_strlenpm). Calling Parameters R2 --> Input String dm_lnt = 0 Return Registers pm_ptr --> End of String (NULL) R0 = Length of string Altered Registers R0, R2, pm_ptr Cycle Count length of string + 5 */ .GLOBAL ___lib_strlenpm; /* This can get a bit confusing because there is a two iteration delay */ /* before the loop exits, so we need to decrement the length by two. We*/ /* do this by incrementing the starting pointer by one, and decrementing*/ /* the ending pointer by one before the math. There is a final */ /* of the ending point so that it actually points to the NULL character */ /* */ /* This routine does not check for NULL input pointers. If a NULL */ /* pointer is sent as input to this routine, a negative number will be */ /* returned for the length. Watch out! */ ___lib_strlenpm:R0=PASS R2, pm_ptr=R2; /* Hold string start */ DO find_pm_end UNTIL EQ; /* Loop until NULL */ find_pm_end: IF NE R2=PASS R2, R2=PM(pm_ptr,pm_1); MODIFY(pm_ptr, pm_M1); /* Back up to NULL */ RTS (DB), R0=R0+1; /* Return to Caller */ R2=pm_ptr; R0=R2-R0, MODIFY(pm_ptr, pm_M1);/* Compute length */ .ENDSEG;