!<arch>
boot.asm/       624131614   0     0     0       2623      `
        .length 85
        .width  132
***************************************************************
* BOOT v2.10  - C startup routine
* Copyright (c) 1989 Texas Instruments Inc.
***************************************************************
*
* This is the initial boot routine for TMS320C30 C Programs.
* It must be linked and loaded with all C programs.  The
* entry point for C programs is called "_c_int00", defined
* in this module.
*
* This module performs the following actions:
*    1) Allocate and initialize the system stack
*    2) Perform auto-initialization
*    3) Call the function _main to start the user's program
***************************************************************

STACK_SIZE  .set  400h            ;size of system stack
FP          .set  AR3             ;frame pointer

            .global cinit, .bss, _main, _exit
            .global _c_int00

;
; Allocate space for the system stack.
; Initialize the first words in .text to point to the stack
; and initialization tables.
;
stack       .usect  ".stack",STACK_SIZE

            .text
stack_addr  .word  stack          ;address of stack
init_addr   .word  cinit          ;address of init tables

***************************************************************
* _C_INT00 - C entry point function
***************************************************************
_c_int00:
;
; Set up the initial stack pointer
;
        LDP     stack_addr        ;get page of stored address
        LDI     @stack_addr,SP    ;load the address into SP
        LDI     SP,FP             ;and into FP too
;
; Do autoinitialization
;
        LDP     init_addr         ;get page of stored address
        LDI     @init_addr,AR0    ;get address of init tables
        CMPI    -1,AR0            ;if RAM model, skip init
        BEQ     done
        LDI     *AR0++,R1         ;get first count
        BZD     done              ;if 0, nothing to do
        LDI     *AR0++,AR1        ;get dest address
        LDI     *AR0++,R0         ;get first word
        SUBI    1,R1              ;count - 1
do_init:
        RPTS    R1                ;block copy
        STI     R0,*AR1++
    ||  LDI     *AR0++,R0
        LDI     R0,R1             ;move next count into R1
        BNZD    do_init           ;if there is more, repeat
        LDI     *AR0++,AR1        ;get next dest address
        LDI     *AR0++,R0         ;get next first word
        SUBI    1,R1              ;count - 1
done:
;
; For the small model, set up the DP to point to the .bss section
;
        LDP     .bss
;
; Call main()
;
        CALL    _main
        CALL    _exit
        RETI
        .end

divf.asm/       624131614   0     0     0       3882      `
	.length  85
	.width   132
*********************************************************************
* DIVF  v2.10   - Floating point divide function
* Copyright (c) 1989 Texas Instruments Inc.
*********************************************************************
*    Inputs:           u in R0, v in R1
*    Outputs:          u/v in R0
*    Status:           Set from result in R0
*    Registers used:   R0-R3, IR0
*    Cycles:           36
*    Operation:        Result = (1/v) * u.  Calculate (1/v) as follows:
*       
*       Given v = a * 2**e
*       x[0] = 1.0 * 2**(-e-1)
*       for (i = 1; i <= 5; i++)
*         x[i] = x[i-1] * (2.0 - v * x[i-1])
*
*       The single-precision floating-point format is accurate to 6.9 
*       decimal places.  The single-precision format is accurate to 
*       2**-23 = 1.192E-7, so we would like to have that much accuracy 
*       in the final result.
*
*       The algorithm's error at an iteration i (e[i]) is defined as
*          e[i] = 1 - v * x[i]
*       It can also be shown that e[i+1] = e[i] * e[i].
**********************************************************************
        .global DIV_F
 
**********************************************************************
*  DIV_F - Floating point division
**********************************************************************
DIV_F:  
	LDI     R1,IR0      ; Save the sign of v in top bit of IR0.
        ABSF    R1          ; The algorithm uses v = |v|.
;
;   Extract the exponent of v.
;
        PUSHF   R1
        POP     R2
        ASH     -24,R2      ; The 8 LSBs of R2 contain the exponent of v.
;
; A few comments on boundary conditions.  If e = -128, then v = 0.  The
; following x[0] calculation yields R2 = --128 - 1 = 127 and the algorithm will
; overflow and saturate since x[0] is large.  This seems reasonable.  If e =
; 127, the R2 = -127 - 1 = -128.  Thus x[0] = 0 and this will cause the
; algorithm to yield zero.  Since the mantissa of v is always between 1 and 2,
; this is also reasonable.  As a result, boundary conditions are handled
; automatically in a reasonable fashion.
;
;   x[0] formation given the exponent of v.
;
        NEGI    R2
        SUBI    1,R2            ; Now we have -e-1, the exponent of x[0].
        ASH     24,R2
        PUSH    R2
        POPF    R2              ; Now R2 = x[0] = 1.0 * 2**(-e-1).
;
; Now the iterations begin.
;
        MPYF    R2,R1,R3        ; R3 = v * x[0]
        SUBRF   2.0,R3          ; R3 = 2.0 - v * x[0]
        MPYF    R3,R2           ; R2 = x[1] = x[0] * (2.0 - v * x[0])
 
        MPYF    R2,R1,R3        ; R3 = v * x[1]
        SUBRF   2.0,R3          ; R3 = 2.0 - v * x[1]
        MPYF    R3,R2           ; R2 = x[2] = x[1] * (2.0 - v * x[1])
 
        MPYF    R2,R1,R3        ; R3 = v * x[2]
        SUBRF   2.0,R3          ; R3 = 2.0 - v * x[2]
        MPYF    R3,R2           ; R2 = x[3] = x[2] * (2.0 - v * x[2])
 
        MPYF    R2,R1,R3        ; R3 = v * x[3]
        SUBRF   2.0,R3          ; R3 = 2.0 - v * x[3]
        MPYF    R3,R2           ; R2 = x[4] = x[3] * (2.0 - v * x[3])
 
        RND     R2              ; This minimizes error in the LSBs.
;
; For the last iteration we use the formulation:
; x[5] = (x[4] * (1.0 - (v * x[4]))) + x[4]
;
        MPYF    R2,R1,R3        ; R3 = v * x[4] = 1.0..01.. => 1
        SUBRF   1.0,R3          ; R3 = 1.0 - v * x[4] = 0.0..01... => 0
        MPYF    R2,R3           ; R3 = x[4] * (1.0 - v * x[4])
        ADDF    R3,R2           ; R3 = x[5] = (x[4]*(1.0-(v*x[4])))+x[4]
 
        RND     R2,R1           ; Round since this is follow by a MPYF.
;
; Now the case of v < 0 is handled.
;
        NEGF    R1,R3           ; R3 = -(1/v)
        CMPI    0,IR0           ; See if v was negative
        LDFN    R3,R1           ; If v < 0, then R1 = -R1
;
; R1 contains 1/v.  Multiply by u to get result.
;
	MPYF    R1,R0
        RETS
        .end
divi.asm/       624131614   0     0     0       2382      `
	.length  85
	.width   132
********************************************************
* DIVI    v2.10  - Integer divide routine (signed)
* Copyright (c) 1989 Texas Instruments Inc.
********************************************************
*    Inputs:          Signed integer dividend in R0, 
*                     Signed integer divisor in R1.
*    Output:          R0 / R1 into R0.
*    Status:          Set from result in R0.
*    Registers used:  R0-R3, IR0, IR1
*
*    Operation:       1. Normalize divisor with dividend
*                     2. Repeat SUBC
*                     3. Quotient is in LSBs of result
*
*    Cycles:          31-62 (depends on amount of normalization)
*********************************************************
	.globl  DIV_I

SIGN    .set   R2
TEMPF   .set   R3 
TEMP    .set   IR0
COUNT   .set   IR1

*********************************************************
* DIV_I - Signed division
*********************************************************
DIV_I:
; 
; Determine sign of result.  Get absolute value of operands.
; 
	XOR     R0,R1,SIGN     ;get the sign
	ABSI    R0
	ABSI    R1

        CMPI    R0,R1          ;divisor > dividend ? 
	BHID    zero           ;  if so, return 0
; 
; Normalize operands.  Use difference in exponents as shift count
; for divisor, and as repeat count for SUBC.
;
        FLOAT   R0,TEMPF       ;normalize dividend
        PUSHF   TEMPF          ;push as float
        POP     COUNT          ;pop as int 
	LSH     -24,COUNT      ;get dividend exponent

        FLOAT   R1,TEMPF       ;normalize divisor
        PUSHF   TEMPF          ;push as float 
	POP     TEMP           ;pop as int
	LSH     -24,TEMP       ;get divisor exponent
	SUBI    TEMP,COUNT     ;get difference in exponents
	LSH     COUNT,R1       ;align divisor with dividend
; 
; Do COUNT+1 subtract & shifts.
;
	RPTS    COUNT
	SUBC    R1,R0
;
;  Mask off the lower COUNT+1 bits of R0
;
	SUBRI   31,COUNT       ;shift count is (32 - (COUNT+1))
	LSH     COUNT,R0       ;shift left
	NEGI    COUNT
	LSH     COUNT,R0       ;shift right to get result
;
;  Check sign and negate result if necessary.
;
	NEGI    R0,R1          ;negate result
        ASH     -31,SIGN       ;check sign 
	LDINZ   R1,R0          ;if set, use negative result
        CMPI    0,R0           ;set status from result
        RETS
;
;  Return zero.
;
zero:
	LDI     0,R0
	RETS
        .end
divu.asm/       624131614   0     0     0       3788      `
	.length  85
	.width   132
********************************************************
* DIVU  v2.10    - Integer divide routine (unsigned)
* Copyright (c) 1989 Texas Instruments Inc.
********************************************************
*    Inputs:          Unsigned dividend in R0, 
*                     unsigned divisor in R1.
*
*    Output:          R0 / R1 into R0.
*    Status:          Set from result in R0.
*    Registers used:  R0-R3, IR0, IR1
*    Operation:       1. Normalize divisor with dividend
*                     2. Repeat SUBC
*                     3. Quotient is in LSBs of result 
*
*    Cycles:          31-65
*********************************************************
	.globl  DIV_U

TEMPF   .set   R2
COUNT   .set   R3
TEMP    .set   IR0
MSBQ    .set   IR1

*********************************************************
* DIV_U - Unsigned division
*********************************************************
DIV_U:
        CMPI    R0,R1          ;divisor > dividend ? 
	BHI     zero           ;   if so, return 0
;
; If top bit of dividend is set, handle specially.
;
        CMPI    0,R0	       ;check top bit
	BLTD    div_32         ;get divisor exponent, then jump.
;
; Get divisor exponent by converting to float.
;
	FLOAT   R1,TEMPF       ;normalize divisor
	PUSHF   TEMPF          ;push as float
	POP     COUNT          ;pop as int to get exponent
;
; 31 or less bits in dividend.  Get dividend exponent.
;
        FLOAT   R0,TEMPF       ;normalize dividend
	PUSHF   TEMPF          ;push as float
	POP     TEMP           ;pop as int to get exponent
;
; Use difference in exponents as shift count to line up MSBs.
;
	LSH     -24,COUNT      ;divisor exponent
	LSH     -24,TEMP       ;dividend exponent
	SUBRI   TEMP,COUNT     ;difference
        LSH     COUNT,R1       ;shift divisor up
; 
; Do COUNT+1 subtract & shifts.
;
	RPTS    COUNT
	SUBC    R1,R0
;
;  Mask off the lower COUNT+1 bits of R0 and return.
;
	SUBRI   31,COUNT       ;shift count is (32 - (COUNT+1))
	LSH     COUNT,R0       ;shift left
	NEGI    COUNT
	LSH     COUNT,R0       ;shift right to get result
        RETS
        .page
;
; The following code handles cases of a full 32-bit dividend.  Before
; SUBC can be used, the top bit must be cleared (otherwise SUBC can
; possibly shift a significant 1 out the top of the dividend).  This
; is accomplished by first doing a normal subtraction, then proceeding
; with SUBCs. 
;
div_32:
;
; If the top bit of the divisor is set too, the quotient is 1.  
; Otherwise, shift the divisor up to line up the MSBs. 
;
	CMPI    0,R1           ;check divisor
	BLTD    one            ;if top bit set, quotient is 1
	LSH     -24,COUNT      ;divisor exponent
	SUBRI   31,COUNT       ;shift count 
	LSH     COUNT,R1       ;shift up to line up MSBs
;
; Now MSBs are aligned.  Do first SUBC by hand, and save off the first
; quotient digit.  Then, shift divisor right rather than shifting dividend
; left.  This leaves a 0 in the top bit of the dividend.
;
	LDI     1,MSBQ            ;initialize MSB of quotient
	LSH     COUNT,MSBQ,TEMP   ;create a mask for the MSBs
	SUBI    1,TEMP            ;mask is (2 << COUNT) - 1

	SUBI    R1,R0,TEMPF    ;subtract 
	LDIHS   TEMPF,R0       ;if positive, replace dividend
	LDILO   0,MSBQ         ;if negative, set quotient to 0
	LSH     COUNT,MSBQ     ;shift MSB into position

	LSH     -1,R1          ;shift divisor down
	SUBI    1,COUNT        ;first iteration is done
; 
; Do COUNT subtract & shifts.
;
	RPTS    COUNT
	SUBC    R1,R0
;
; MSB of the quotient is in MSBQ.  LSBs are in the lower COUNT bits of
; R0.
;
        AND     TEMP,R0        ;mask off LSBs
	OR      MSBQ,R0        ;MSB of quotient
        RETS
;
;  Return one.
;
one:    LDI     1,R0
	RETS
;
;  Return zero.
;
zero:   LDI     0,R0
	RETS
        .end
modi.asm/       624131618   0     0     0       2376      `
	.length  85
	.width   132
********************************************************
* MODI    v2.10    - Integer modulo (signed)
* Copyright (c) 1989 Texas Instruments Inc.
********************************************************
*    Inputs:          Signed integer dividend in R0, 
*                     Signed integer divisor in R1.
*    Output:          R0 % R1 into R0.
*    Status:          Set from result in R0.
*    Registers used:  R0-R3, IR0, IR1
*
*    Operation:       1. Normalize divisor with dividend
*                     2. Repeat SUBC
*                     3. Remainder is in MSBs of result
*
*    Cycles:          31-62 (depends on normalization)
*********************************************************
	.globl  MOD_I

SIGN    .set   R2
TEMPF   .set   R3 
TEMP    .set   IR0
COUNT   .set   IR1

*********************************************************
* MOD_I - Signed integer modulo
*********************************************************
MOD_I:
; 
; Determine sign of result.  Get absolute value of operands.
; 
	XOR     R0,R1,SIGN     ;get the sign
	LDI     R0,TEMP        ;save off dividend
	ABSI    R0
	ABSI    R1

        CMPI    R0,R1          ;divisor > dividend ? 
	BHID    skip           ;  if so, return 0
; 
; Normalize operands.  Use difference in exponents as shift count
; for divisor, and as repeat count for SUBC.
;
        FLOAT   R0,TEMPF       ;normalize dividend
        PUSHF   TEMPF          ;push as float
        POP     COUNT          ;pop as int 
	LSH     -24,COUNT      ;get dividend exponent

        FLOAT   R1,TEMPF       ;normalize divisor
        PUSHF   TEMPF          ;push as float 
	POP     TEMP           ;pop as int
	LSH     -24,TEMP       ;get divisor exponent
	SUBI    TEMP,COUNT     ;get difference in exponents
	LSH     COUNT,R1       ;align divisor with dividend
; 
; Do COUNT+1 subtract & shifts.
;
	RPTS    COUNT
	SUBC    R1,R0
;
;  Remainder is in upper bits of R0
;
	ADDI    1,COUNT        ;shift count is -(COUNT+1)
	NEGI    COUNT 
	LSH     COUNT,R0       ;shift right
;
;  Check sign and negate result if necessary.
;
	NEGI    R0,R1          ;negate result
        ASH     -31,SIGN       ;check sign 
	LDINZ   R1,R0          ;if set, use negative result
        CMPI    0,R0           ;set status on result
        RETS
;
;  Quotient is 0 - return dividend
;
skip:
	LDI     TEMP,R0
	RETS
        .end
modu.asm/       624131618   0     0     0       3572      `
	.length  85
	.width   132
********************************************************
* MODU  v2.10    - Integer modulo (unsigned)
* Copyright (c) 1989 Texas Instruments Inc.
********************************************************
*    Inputs:          Unsigned dividend in R0, 
*                     unsigned divisor in R1.
*
*    Output:          R0 / R1 into R0.
*    Status:          Set from result in R0.
*    Registers used:  R0-R3, IR0
*    Operation:       1. Normalize divisor with dividend
*                     2. Repeat SUBC
*                     3. Remainder is in MSBs of result
*
*    Cycles:          30-60
*********************************************************
	.globl  MOD_U

TEMPF   .set   R2
TEMP    .set   R3
COUNT   .set   IR0

*********************************************************
* MOD_U - Unsigned modulo
*********************************************************
MOD_U:
        CMPI    R0,R1          ;divisor > dividend ? 
	BHI     zero           ;   if so, return dividend
;
; If top bit of dividend is set, handle specially.
;
        CMPI    0,R0	       ;check top bit
	BLTD    mod_32         ;get divisor exponent, then jump.
;
; Get divisor exponent by converting to float.
;
	FLOAT   R1,TEMPF       ;normalize divisor
	PUSHF   TEMPF          ;push as float
	POP     COUNT          ;pop as int to get exponent
;
; 31 or less bits in dividend.  Get dividend exponent.
;
        FLOAT   R0,TEMPF       ;normalize dividend
	PUSHF   TEMPF          ;push as float
	POP     TEMP           ;pop as int to get exponent
;
; Use difference in exponents as shift count to line up MSBs.
;
	LSH     -24,COUNT      ;divisor exponent
	LSH     -24,TEMP       ;dividend exponent
	SUBRI   TEMP,COUNT     ;difference
        LSH     COUNT,R1       ;shift divisor up
; 
; Do COUNT+1 subtract & shifts.
;
	RPTS    COUNT
	SUBC    R1,R0
;
;  Remainder is in upper 31-COUNT bits.
;
	ADDI    1,COUNT        ;shift count is COUNT+1
	NEGI    COUNT          ;negate for right shift
	LSH     COUNT,R0       ;shift to get result
        RETS
        .page
;
; The following code handles cases of a full 32-bit dividend.  Before
; SUBC can be used, the top bit must be cleared (otherwise SUBC can
; possibly shift a significant 1 out the top of the dividend).  This
; is accomplished by first doing a normal subtraction, then proceeding
; with SUBCs. 
;
mod_32:
;
; If the top bit of the divisor is set too, the remainder is simply
; the difference between the dividend and divisor.  Otherwise, shift 
; the divisor up to line up the MSBs.
;
	CMPI    0,R1           ;check divisor
	BLTD    one            ;if negative, remainder is diff

	LSH     -24,COUNT      ;divisor exponent
	SUBRI   31,COUNT       ;shift count = 31 - exp
	NEGI    COUNT,TEMPF    ;used later as shift count
	LSH     COUNT,R1       ;shift up to line up MSBs
;
; Now MSBs are aligned.  Do first SUBC by hand using a plain subtraction.
; Then, shift divisor right rather than shifting dividend left.  This leaves
; a 0 in the top bit of the dividend.
;
	SUBI    R1,R0,TEMP     ;subtract 
	LDIHS   TEMP,R0        ;if positive, replace dividend
	SUBI    1,COUNT        ;first iteration is done
	LSH     -1,R1          ;shift divisor down
; 
; Do COUNT subtract & shifts.
;
	RPTS    COUNT
	SUBC    R1,R0
;
;  Quotient is in COUNT+1 LSBs; shift remainder (in MSBs) down.
;
	LSH     TEMPF,R0      ;TEMPF contains -(COUNT+1)
        RETS
;
;  Return (dividend - divisor).
;
one:    SUBI    R1,R0  
	RETS
;
;  Return dividend.
;
zero:   CMPI    0,R0           ;set status from result
	RETS
        .end
mpyi.asm/       624131618   0     0     0       1998      `
	.length  85
	.width   132
********************************************************
* MPYI   v2.10    - 32x32 Integer Multiply
* Copyright (c) 1989 Texas Instruments Inc.
********************************************************
*    Inputs:         x in R0, y in R1.
*    Outputs:        x*y in R0.
*    Status:         Set from result in R0.
*    Registers used: R0 - R3
*
*    Operation:
*       Let x0 = 16 MSBs of x, x1 = 16 LSBs of x
*           y0 = 16 MSBs of y, y1 = 16 LSBs of y
*      
*       result = (x0 * y1) + (y0 * x1) + (x1 * y1)
*
*    Cycles:  16
*********************************************************
	.globl  MPY_I

MPY_I:
        LDI     R0,R2         ;x
        LDI     R1,R3         ;y
        LSH     -16,R0        ;x0
        LSH     -16,R1        ;y0
        AND     0FFFFh,R2     ;x1
        AND     0FFFFh,R3     ;y1
        MPYI    R3,R0         ;y1 * x0
        MPYI    R2,R1         ;x1 * y0
        MPYI    R2,R3         ;x1 * y1
        ADDI    R1,R0         ;MSW of product
        LSH     16,R0         ;shift up
        ADDI    R3,R0         ;add in LSW

        RETS

*********************************************************
* THE FOLLOWING VERSION OF MPYI IS PROVIDED FOR USE WITH
* EARLY TMS320C30 DEVICES.  THIS VERSION AVOIDS USING
* THE "AND" INSTRUCTION WITH A 16-BIT IMMEDIATE OPERAND.
* TO USE THIS VERSION, COMPILE WITH THE -x CODEGEN OPTION.
*********************************************************
	.globl  MPY_X

MPY_X:
        LDI     R0,R2         ;x
        LDI     R1,R3         ;y
        LSH     -16,R0        ;x0
        LSH     -16,R1        ;y0

	; here's the difference
        LSH     16,R2
        LSH     -16,R2
        LSH     16,R3
        LSH     -16,R3

        MPYI    R3,R0         ;y1 * x0
        MPYI    R2,R1         ;x1 * y0
        MPYI    R2,R3         ;x1 * y1
        ADDI    R1,R0         ;MSW of product
        LSH     16,R0         ;shift up
        ADDI    R3,R0         ;add in LSW

        RETS
        .end
sysmem.asm/     624131622   0     0     0       947       `
	.length 85
	.width  132
***************************************************************
* SYSMEM   v2.10   - System memory allocation
* Copyright (c) 1989 Texas Instruments Inc.
***************************************************************
*
* This module declares the memory area used by the memory
* allocation functions malloc(), etc.  The memory area is 
* declared as a usect named ".sysmem" -- use the linker to
* position it in memory.  The heap size can be changed 
* by changing the constant __SYSMEM_SIZE.
*
***************************************************************
__SYSMEM_SIZE  .set  800h          ;size of memory - 2K default 

	       .global __sys_memory, __SYSMEM_SIZE

__sys_memory   .usect  ".sysmem",__SYSMEM_SIZE
 
;
; Auto-initialize the first two words with a free packet for the
; whole memory size.
;
	       .sect   ".cinit"
	       .word   2, __sys_memory
	       .word   -(__SYSMEM_SIZE - 1)
	       .word   0

abs.c/          624131612   0     0     0       425       `
/****************************************************************************/
/*  abs labs v2.10                                                          */
/*  Copyright (c) 1989 Texas Instruments Inc.				    */
/****************************************************************************/
#include "stdlib.h"

int abs(i)
    int i;
{
    return i < 0 ? -i : i;
}

long labs(i)
    long i;
{
    return i < 0 ? -i : i;
}


asctime.c/      624131612   0     0     0       933       `
/****************************************************************************/
/*  asctime v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "time.h" 

char *asctime(timeptr)
   struct tm *timeptr;

{
    register struct tm *tptr = timeptr;
    static char result[26];
    static char *day[7]  = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
    static char *mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", 
			     "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

    mktime(timeptr);      /* MAKE SURE THIS A SANE TIME */

    sprintf(result, "%s %s%3d %02d:%02d:%02d %d\n",
		    day[tptr->tm_wday], mon[tptr->tm_mon], tptr->tm_mday, 
		    tptr->tm_hour, tptr->tm_min, tptr->tm_sec,
		    tptr->tm_year + 1900);

    return (result);
}

atof.c/         624131614   0     0     0       404       `
/****************************************************************************/
/*  atof v2.10                                                              */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "stdlib.h"

double atof(st)
  char *st;
{
    return strtod(st, (char **)0);
}
atoi.c/         624131614   0     0     0       814       `
/****************************************************************************/
/*  atoi v2.10                                                              */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "ctype.h"

int atoi(st)
  register char *st;
{
    register int  result = 0;
    register char cp;
    register int  sign;

    while (_isspace(*st)) ++st;      /* SKIP WHITE SPACE */

    if (sign = ((cp = *st) == '-')) cp = *++st;
    else if (cp == '+')             cp = *++st;

    while (_isdigit(cp))
    {
        result *= 10;
        result += cp - '0';
        cp      = *++st;
    }

    if (sign) result = -result;
    return result;
}

long atol(st)
{
    return(atoi(st));
}
bsearch.c/      624131614   0     0     0       1181      `
/****************************************************************************/
/*  bsearch v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "stdlib.h"

void *bsearch(key, base, nmemb, size, compar)
   register char *key;         /* ITEM TO SEARCH FOR           */
   register char *base;        /* POINTER TO ARRAY OF ELEMENTS */
   int   nmemb;                /* NUMBER OF ELEMENTS TO SORT   */
   int   size;                 /* SIZE IN WORDS OF EACH ITEM   */
   int (*compar)();            /* COMPARE FUNCTION             */

{
   register int i       = 0;             /* left scan index  */
   register int j       = nmemb - 1;     /* right scan index */

   while( i <= j )
   {
      register int pivot = (j + i) / 2;            
      int offset = pivot * size;
      int result = (*compar)(key, base + offset);

      if (result == 0) return(base + offset);
      if (result < 0) j = pivot - 1;
		 else i = pivot + 1;
   }

   return ((void *)0);   /* IF WE GET TO HERE, WE FAILED */
}



clock.c/        624131614   0     0     0       692       `
/****************************************************************************/
/*  clock v2.10                                                             */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

/****************************************************************************/
/* OBVIOUSLY, THIS IS SIMPLY A STUB, WHICH BY DEFINITION RETURNS -1         */
/* IF THE SYSTEM TIME IS UNAVAILABLE.                                       */ 
/****************************************************************************/
#include "time.h" 

clock_t clock()   
{
    return -1;
}
ctime.c/        624131614   0     0     0       414       `
/****************************************************************************/
/*  ctime   v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "time.h"

char *ctime(timer)
   time_t *timer;
{
   return(asctime(localtime(timer)));
}
ctype.c/        624131614   0     0     0       6989      `
/****************************************************************************/
/*  ctype.c v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "ctype.h"

/****************************************************************************/
/*  DECLARATION OF CHARACTER TYPING LOOKUP TABLE                            */
/****************************************************************************/
unsigned char _ctypes_[] = {
                     /*  -1   EOF   */     _C_,
                     /* 0x00  NUL   */     _C_,
                     /* 0x01  SOH   */     _C_,
                     /* 0x02  STX   */     _C_,
                     /* 0x03  ETX   */     _C_,
                     /* 0x04  EOT   */     _C_,
                     /* 0x05  ENQ   */     _C_,
                     /* 0x06  ACK   */     _C_,
                     /* 0x07  BEL   */     _C_,
                     /* 0x08  BS    */     _C_,
                     /* 0x09  HT    */     _C_ | _S_,
                     /* 0x0A  LF    */     _C_ | _S_,
                     /* 0x0B  VT    */     _C_ | _S_,
                     /* 0x0C  FF    */     _C_ | _S_,
                     /* 0x0D  CR    */     _C_ | _S_,
                     /* 0x0E  SO    */     _C_,
                     /* 0x0F  SI    */     _C_,

                     /* 0x10  DLE   */     _C_,
                     /* 0x11  DC1   */     _C_,
                     /* 0x12  DC2   */     _C_,
                     /* 0x13  DC3   */     _C_,
                     /* 0x14  DC4   */     _C_,
                     /* 0x15  NAK   */     _C_,
                     /* 0x16  SYN   */     _C_,
                     /* 0x17  ETB   */     _C_,
                     /* 0x18  CAN   */     _C_,
                     /* 0x19  EM    */     _C_,
                     /* 0x1A  SUB   */     _C_,
                     /* 0x1B  ESC   */     _C_,
                     /* 0x1C  FS    */     _C_,
                     /* 0x1D  GS    */     _C_,
                     /* 0x1E  RS    */     _C_,
                     /* 0x1F  US    */     _C_,

                     /* 0x20  ' '   */     _S_ | _B_,
                     /* 0x21  '!'   */     _P_,
                     /* 0x22  '"'   */     _P_,
                     /* 0x23  '#'   */     _P_,
                     /* 0x24  '$'   */     _P_,
                     /* 0x25  '%'   */     _P_,
                     /* 0x26  '&'   */     _P_,
                     /* 0x27  '''   */     _P_,
                     /* 0x28  '('   */     _P_,
                     /* 0x29  ')'   */     _P_,
                     /* 0x2A  '*'   */     _P_,
                     /* 0x2B  '+'   */     _P_,
                     /* 0x2C  ','   */     _P_,
                     /* 0x2D  '-'   */     _P_,
                     /* 0x2E  '.'   */     _P_,
                     /* 0x2F  '/'   */     _P_,

                     /* 0x30  '0'   */     _N_ | _H_,
                     /* 0x31  '1'   */     _N_ | _H_,
                     /* 0x32  '2'   */     _N_ | _H_,
                     /* 0x33  '3'   */     _N_ | _H_,
                     /* 0x34  '4'   */     _N_ | _H_,
                     /* 0x35  '5'   */     _N_ | _H_,
                     /* 0x36  '6'   */     _N_ | _H_,
                     /* 0x37  '7'   */     _N_ | _H_,
                     /* 0x38  '8'   */     _N_ | _H_,
                     /* 0x39  '9'   */     _N_ | _H_,
                     /* 0x3A  ':'   */     _P_,
                     /* 0x3B  ';'   */     _P_,
                     /* 0x3C  '<'   */     _P_,
                     /* 0x3D  '='   */     _P_,
                     /* 0x3E  '>'   */     _P_,
                     /* 0x3F  '?'   */     _P_,

                     /* 0x40  '@'   */     _P_,
                     /* 0x41  'A'   */     _U_ | _H_,
                     /* 0x42  'B'   */     _U_ | _H_,
                     /* 0x43  'C'   */     _U_ | _H_,
                     /* 0x44  'D'   */     _U_ | _H_,
                     /* 0x45  'E'   */     _U_ | _H_,
                     /* 0x46  'F'   */     _U_ | _H_,
                     /* 0x47  'G'   */     _U_,
                     /* 0x48  'H'   */     _U_,
                     /* 0x49  'I'   */     _U_,
                     /* 0x4A  'J'   */     _U_,
                     /* 0x4B  'K'   */     _U_,
                     /* 0x4C  'L'   */     _U_,
                     /* 0x4D  'M'   */     _U_,
                     /* 0x4E  'N'   */     _U_,
                     /* 0x4F  'O'   */     _U_,

                     /* 0x50  'P'   */     _U_,
                     /* 0x51  'Q'   */     _U_,
                     /* 0x52  'R'   */     _U_,
                     /* 0x53  'S'   */     _U_,
                     /* 0x54  'T'   */     _U_,
                     /* 0x55  'U'   */     _U_,
                     /* 0x56  'V'   */     _U_,
                     /* 0x57  'W'   */     _U_,
                     /* 0x58  'X'   */     _U_,
                     /* 0x59  'Y'   */     _U_,
                     /* 0x5A  'Z'   */     _U_,
                     /* 0x5B  '['   */     _P_,
                     /* 0x5C  '\'   */     _P_,
                     /* 0x5D  ']'   */     _P_,
                     /* 0x5E  '^'   */     _P_,
                     /* 0x5F  '_'   */     _P_,

                     /* 0x60  '`'   */     _P_,
                     /* 0x61  'a'   */     _L_ | _H_,
                     /* 0x62  'b'   */     _L_ | _H_,
                     /* 0x63  'c'   */     _L_ | _H_,
                     /* 0x64  'd'   */     _L_ | _H_,
                     /* 0x65  'e'   */     _L_ | _H_,
                     /* 0x66  'f'   */     _L_ | _H_,
                     /* 0x67  'g'   */     _L_,
                     /* 0x68  'h'   */     _L_,
                     /* 0x69  'i'   */     _L_,
                     /* 0x6A  'j'   */     _L_,
                     /* 0x6B  'k'   */     _L_,
                     /* 0x6C  'l'   */     _L_,
                     /* 0x6D  'm'   */     _L_,
                     /* 0x6E  'n'   */     _L_,
                     /* 0x6F  'o'   */     _L_,

                     /* 0x70  'p'   */     _L_,
                     /* 0x71  'q'   */     _L_,
                     /* 0x72  'r'   */     _L_,
                     /* 0x73  's'   */     _L_,
                     /* 0x74  't'   */     _L_,
                     /* 0x75  'u'   */     _L_,
                     /* 0x76  'v'   */     _L_,
                     /* 0x77  'w'   */     _L_,
                     /* 0x78  'x'   */     _L_,
                     /* 0x79  'y'   */     _L_,
                     /* 0x7A  'z'   */     _L_,
                     /* 0x7B  '{'   */     _P_,
                     /* 0x7C  '|'   */     _P_,
                     /* 0x7D  '}'   */     _P_,
                     /* 0x7E  '~'   */     _P_,
                     /* 0x7F  DEL   */     _C_
                  };

difftime.c/     624131614   0     0     0       426       `
/****************************************************************************/
/*  difftime v2.10                                                          */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "time.h" 

double difftime(time1, time0)
   time_t time1, 
	  time0;
{
    return (time1 - time0);
}
div.c/          624131614   0     0     0       622       `
/****************************************************************************/
/*  div ldiv    v2.10                                                       */
/*  Copyright (c) 1989 Texas Instruments Inc.				    */
/****************************************************************************/
#include "stdlib.h"

div_t div(numer, denom)
    int numer, denom;
{
    div_t local;
    local.quot = numer / denom;
    local.rem  = numer % denom;
    return (local);
}

ldiv_t ldiv(numer, denom)
    long numer, denom;
{
    ldiv_t local;
    local.quot = numer / denom;
    local.rem  = numer % denom;
    return (local);
}

dtos.c/         624131614   0     0     0       849       `
/****************************************************************************/
/*  dtos v2.10                                                              */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
dtos(num, buf, prec)

   register double num;
   register char  *buf;
   int      prec;

   {
       int    ival;
       int    pow = 0;
       double max = 0x7FFFFFFF;

       if (num < 0) 
       { 
	     *buf++ = '-'; 
	     num    = -num;
       }

       while (num > max) { num /= 10; pow++; }

       ival = num;
       buf += ltoa(ival = num, buf);
       num -= ival;

       while (prec--)
       {
	    if (pow-- == 0) *buf++ = '.';
	    *buf++ = (ival = num *= 10) + '0';
	    num -= ival;
       }
       *buf = 0;
   }

ecvt.c/         624131616   0     0     0       2479      `
/****************************************************************************/
/*  ecvt v2.10                                                              */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
char *ecvt(value, ndigit, decpt, sign)

    double       value; 
    register int ndigit;
    int         *decpt;
    int         *sign;

{
    static char out[100]; 

    register int   digits = 0;         /* NUMBER OF DIGITS BEFORE .       */
    register char *pos    = out + 1;     
    register int   temp;

    out[0] = '0';                      /* JUST IN CASE WE ROUND.          */
    ndigit++;                          /* DO ONE EXTRA DIGIT FOR ROUNDING */

    /*--------------------------------------------------------------------*/
    /* PERFORM PRESCALING - MAKE SURE NUMBER HAS INTEGRAL WHOLE PART      */
    /*--------------------------------------------------------------------*/
    if (*sign = (value < 0)) value = -value;
    while (value > 0x7FFFFFFF) { value /= 10; digits++; }
    while (value && value < 1) { value *= 10; digits--; }

    /*--------------------------------------------------------------------*/
    /* WRITE OUT INTEGRAL PART OF NUMBER.                                 */
    /*--------------------------------------------------------------------*/
    pos    += temp    = ltoa((int)value, pos);
    *decpt  = digits + temp;
    value  -= (int)value;

    /*--------------------------------------------------------------------*/
    /* WRITE OUT FRACTIONAL PART OF NUMBER                                */
    /*--------------------------------------------------------------------*/
    if (temp >= ndigit) 
	 pos = out + ndigit;
    else
         for (ndigit -= temp, pos--; ndigit--; value -= (int)value) 
              *++pos = (value *= 10) + '0';

    /*--------------------------------------------------------------------*/
    /* PERFORM ROUNDING.  NOTE THAT pos IS CURRENTLY POINTING AT AN EXTRA */
    /* DIGIT WHICH WAS CONVERTED FOR THIS PURPOSE.                        */
    /*--------------------------------------------------------------------*/
    if (*pos >= '5')
    {
	register char *ptr = pos;
	while ((*--ptr += 1) > '9') *ptr = '0';
	if (ptr == out) { *--pos = 0; *decpt += 1; return(out); }
    }
	
    *pos = 0;
    return(out + 1);
}


errno.c/        624131616   0     0     0       319       `
/********************************************************************/
/* errno    v2.10                                                   */
/* Copyright (c) 1989 Texas Instruments Inc.                        */
/********************************************************************/
#include <errno.h>
int errno = 0;


exit.c/         624131616   0     0     0       1455      `
/****************************************************************************/
/*  exit v2.10                                                              */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

#define MAX_FUN   32
static int    at_exit_count = 0;
static void (*at_exit_fun[MAX_FUN])();

void exit(status)        
     int status;
{
    register int i = at_exit_count;
    /*********************************************************************/
    /* HANDLE FUNCTIONS REGISTERED THROUGH atexit().                     */
    /*********************************************************************/
    while (i) (*at_exit_fun[--i])(); 

    for (;;);   /* CURRENTLY, THIS SPINS FOREVER */
}

/****************************************************************************/
/* atexit - attempt to register a function for calling at program end       */
/****************************************************************************/
int atexit(fun)
   void (*fun)();

{
   if (at_exit_count >= MAX_FUN) return 1;
   at_exit_fun[at_exit_count++] = fun;
   return 0;
}

/****************************************************************************/
/* abort - currently the same as exit.                                      */
/****************************************************************************/
void abort()
{
    exit(0); 
}


fcvt.c/         624131616   0     0     0       2536      `
/****************************************************************************/
/*  fcvt v2.10                                                              */
/*  Copyright (c) 1988 Texas Instruments Inc.                               */
/****************************************************************************/
#include "ctype.h"

char *fcvt(value, ndigit, decpt, sign)

    double       value; 
    register int ndigit;
    int         *decpt;
    int         *sign;

{
    static char out[100]; 

    register int   digits = 0;         /* NUMBER OF DIGITS BEFORE .       */
    register char *pos    = out + 1;     
    register int   temp;

    out[0] = '0';                      /* JUST IN CASE WE ROUND.          */
    ndigit++;                          /* DO ONE EXTRA DIGIT FOR ROUNDING */

    /*--------------------------------------------------------------------*/
    /* PERFORM PRESCALING - MAKE SURE NUMBER HAS INTEGRAL WHOLE PART      */
    /*--------------------------------------------------------------------*/
    if (*sign = (value < 0)) value = -value;
    while (value > 0x7FFFFFFF) { value /= 10; digits++; }
    while (value && value < 1) { value *= 10; digits--; }

    /*--------------------------------------------------------------------*/
    /* WRITE OUT INTEGRAL PART OF NUMBER.                                 */
    /*--------------------------------------------------------------------*/
    pos   += temp    = ltoa((int)value, pos);
    *decpt = digits + temp; 

    if (digits < 0) ndigit += digits;

    /*--------------------------------------------------------------------*/
    /* WRITE OUT FRACTIONAL PART OF NUMBER                                */
    /*--------------------------------------------------------------------*/
    while (ndigit--)
    {
         value -= (int)value;
         *pos++ = (value *= 10) + '0';
    }

    /*--------------------------------------------------------------------*/
    /* PERFORM ROUNDING.  NOTE THAT pos IS CURRENTLY POINTING AT AN EXTRA */
    /* DIGIT WHICH WAS CONVERTED FOR THIS PURPOSE.                        */
    /*--------------------------------------------------------------------*/
    if (*--pos >= '5')
    {
	register char *ptr = pos;
	while ((*--ptr += 1) > '9') *ptr = '0';
	if (ptr == out) 
	   if (--pos > out) { *pos   = 0; *decpt += 1; return(out); }
	   else             { out[1] = 0;              return(out); }
    }
	
    *pos = 0;
    return(out + 1);
}

floor.c/        624131616   0     0     0       514       `
/****************************************************************************/
/*  floor  v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include <math.h>

double floor(x) 
double x;
{
     double y; 
     return (modf(x, &y) < 0 ? y - 1 : y);
}

double ceil(x)
double x;
{
     double y; 
     return (modf(x, &y) > 0 ? y + 1 : y);
}
gmtime.c/       624131616   0     0     0       601       `
/****************************************************************************/
/*  gmtime v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "time.h"

struct tm *gmtime(timer)
   time_t *timer;
{
    time_t gtime = 6 * 60 * 60;  /* IN TEXAS, 'WE ALL' ARE 6 HOURS BEHIND */
                                 /* (THATS JEST A WEE BIT, Y'ALL)         */

    if (timer) gtime += *timer;
    return (localtime(&gtime));
}

isxxx.c/        624131616   0     0     0       969       `
/****************************************************************************/
/*  isxxx v2.10                                                             */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "ctype.h" 

int isalnum(c)  { return(_isalnum(c));  }
int isalpha(c)  { return(_isalpha(c));  }
int isascii(c)  { return(_isascii(c));  }
int iscntrl(c)  { return(_iscntrl(c));  }
int isdigit(c)  { return(_isdigit(c));  }
int isgraph(c)  { return(_isgraph(c));  }
int islower(c)  { return(_islower(c));  }
int isprint(c)  { return(_isprint(c));  }
int ispunct(c)  { return(_ispunct(c));  }
int isspace(c)  { return(_isspace(c));  }
int isupper(c)  { return(_isupper(c));  }
int isxdigit(c) { return(_isxdigit(c)); }

int toupper(c)  { return(_toupper(c));  }
int tolower(c)  { return(_tolower(c));  }
int toascii(c)  { return(_toascii(c));  }


localtim.c/     624131616   0     0     0       1083      `
/****************************************************************************/
/*  localtime v2.10                                                         */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "time.h"

struct tm *localtime(timer)
   time_t *timer;
{
   static struct tm local;
   time_t ltime  = timer ? *timer : 0;

   local.tm_sec  = 0;
   local.tm_min  = 0;
   local.tm_hour = 0;
   local.tm_mday = 1;
   local.tm_mon  = 0;
   local.tm_year = 0;

   if (timer == 0 || ltime == (time_t)-1) return &local;

   /********************************************************************/
   /* MAKE SURE THE NUMBER OF SECONDS SINCE Jan 1, 1900 CAN BE         */
   /* REPRESENTED IN A SIGNED INT.                                     */
   /********************************************************************/
   if ((int)ltime < 0)
   {
       local.tm_sec  = ltime % 60; 
       local.tm_min  = ltime / 60; 
   }

   mktime(&local);
   return &local;
}


ltoa.c/         624131616   0     0     0       711       `
/****************************************************************************/
/*  ltoa v2.10								    */
/*  Copyright (c) 1989 Texas Instruments Inc.				    */
/****************************************************************************/

int ltoa(val, buffer)
  long	 val;
  char	*buffer;
{
#define BUFLEN 20
    char           tempc[BUFLEN];
    register char *bufptr;
    register int   neg = val < 0;
    register int   uval = neg ? -val : val;

    *(bufptr = &tempc[BUFLEN - 1]) = 0;

    do {*--bufptr = (uval % 10) + '0';}  while(uval /= 10);
    if (neg) *--bufptr = '-';

    movmem(bufptr, buffer, uval = (tempc + BUFLEN) - bufptr);
    return uval - 1;    /* DON'T COUNT NULL TERMINATION */
}


memchr.c/       624131618   0     0     0       622       `
/****************************************************************************/
/*  memchr v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

void *memchr(mem, ch, length)
     char *mem;   
     char  ch;
     int   length;
{
     register char *str = mem - 1;
     register char  rch = ch;
     register char  tch;
     register int   len = length;

     while (len-- > 0) 
        if ((tch = *++str) == rch) return(str);
   
     return (0);
}
memcmp.c/       624131618   0     0     0       559       `
/****************************************************************************/
/*  memcmp v2.10	                                         	    */
/*  Copyright (c) 1989 Texas Instruments Inc.				    */
/****************************************************************************/

int memcmp(mem1, mem2, length)
     char *mem1;
     char *mem2;
     unsigned int  length;
{
     register char *r1 = mem1 - 1;
     register char *r2 = mem2 - 1;
     register unsigned int rn = length;

     while (rn--) if (*++r1 != *++r2) return *r1 - *r2;
     return 0;
}

memmov.c/       624131618   0     0     0       765       `
/****************************************************************************/
/*  memmov v2.10							    */
/*  Copyright (c) 1989 Texas Instruments Inc.				    */
/****************************************************************************/

void *movmem(from, to, length)
    char *from;
    char *to;
    int  length;
{
    register char *ps = from;
    register char *pd = to;
    register int   ln = length + 1;

    if (ps > pd)
	while (--ln) *pd++ = *ps++;
    else
    {
	ps += ln - 1;
	pd += ln - 1;
	while (--ln) *--pd = *--ps;
    }
    return to;
}

void *memcpy(s1, s2, n)
    char *s1;
    char *s2;
    int  n;
{
    return(movmem(s2, s1, n));
}

void *memmove(s1, s2, n)
    char *s1;
    char *s2;
    int  n;
{
    return(movmem(s2, s1, n));
}


memory.c/       624131618   0     0     0       15948     `
/*****************************************************************************/
/*  memory.c v2.10							     */
/*  Copyright (c) 1989 Texas Instruments Inc.				     */
/*---------------------------------------------------------------------------*/
/*  This module contains the functions which implement the dynamic memory    */
/*  management routines for 320C30 C.  The following assumptions/rules       */
/*  apply:                                                                   */
/*									     */
/*   1) Packets are allocated a minimum of one word, max 2^31 words. 	     */
/*   2) The allocation system can be reset at any time by calling the        */
/*      function "minit()".                                                  */
/*                                                                           */
/*   The system memory area is declared in the file "sysmem.asm", as a       */
/*   .usect called ".sysmem".  The size of the heap is also defined there,   */
/*   as an absolute symbol called _SYSMEM_SIZE.  Change the value of this    */
/*   symbol to change the size of the memory area.                           */
/*                                                                           */
/*  The following items are defined in this module :			     */
/*    minit()	   : Function to initialize dynamic memory management.       */
/*    malloc()	   : Function to allocate memory from mem mgmt system.	     */
/*    calloc()	   : Allocate an clear memory from mem mgmt system.	     */
/*    realloc()    : Reallocate a packet				     */
/*    free()	   : Function to free allocated memory.			     */
/*									     */
/*    minsert()    : Insert a packet into free list, sorted by size	     */
/*    mremove()    : Remove a packet from the free list.		     */
/*									     */
/*    sys_free	   : Pointer to free list 				     */
/*									     */
/*  The following items are defined in SYSMEM.ASM:                           */
/*    _SYSMEM_SIZE : Size of system memory area.                             */
/*    _sys_memory  : Array to contain all memory allocate by system.	     */
/*****************************************************************************/
/*---------------------------------------------------------------------------*/
/*  _SYSMEM_SIZE is declared as an absolute external label.  By taking its   */
/*  "address" here in the C file, we get the actual value assigned to the    */
/*   symbol, which is the size of the system memory area.                    */
/*---------------------------------------------------------------------------*/
extern int _SYSMEM_SIZE;

#define MEMORY_SIZE ((int)&_SYSMEM_SIZE) 
#define NIL	    (PACKET *)0

/*---------------------------------------------------------------------------*/
/* "PACKET" is the template for a data packet.  Packet size contains         */
/* the number of words allocated for the user, excluding the size            */
/* required for management of the packet (1 word).  Packets are always       */
/* allocated memory in words.  A negative size indicates a free packet.      */
/*---------------------------------------------------------------------------*/
typedef struct pack 
{
   int           packet_size;	      /* in words */
   struct pack  *size_ptr;
} PACKET;

extern int    _sys_memory[]; 
static PACKET *sys_free = (PACKET *)_sys_memory;

static void minsert();
static void mremove();
void        minit();
void       *malloc();
void       *calloc();
void        free();

/*****************************************************************************/
/*									     */
/*  MINSERT - Insert a packet into the free list.  This list is sorted by    */
/*	      size in increasing order. 				     */
/*									     */
/*****************************************************************************/
static void minsert(ptr)

   PACKET *ptr;

   {
    register PACKET *current = (PACKET *) sys_free;
    register PACKET *last    = NIL;

    /********************************************************************/
    /* CHECK SPECIAL CASE, EMPTY FREE LIST.				*/
    /********************************************************************/
    if (current == NIL)
    {
       sys_free = ptr;
       ptr->size_ptr = NIL;
       return;
    }

    /********************************************************************/
    /* SCAN THROUGH LIST, LOOKING FOR A LARGER PACKET.			*/
    /********************************************************************/
    while ((current != NIL) && (current->packet_size > ptr->packet_size))
    {
	last	= current;
	current = current->size_ptr;
    }

    /********************************************************************/
    /* LINK THE NEW PACKET INTO THE LIST. THERE ARE THREE CASES :	*/
    /*	 THE NEW POINTER WILL EITHER BE THE FIRST, THE LAST, OR IN THE	*/
    /*	 MIDDLE SOMEWHERE.						*/
    /********************************************************************/
    if (current == NIL) 	 /* PTR WILL BE LAST IN LIST */
    {
       last->size_ptr = ptr;
       ptr->size_ptr  = NIL;
    }

    else if (last == NIL)	 /* PTR WILL BE FIRST IN THE LIST */
    {
       ptr->size_ptr  = sys_free;
       sys_free       = ptr;
    }

    else			 /* PTR IS IN THE MIDDLE OF THE LIST */
    {
       ptr->size_ptr  = current;
       last->size_ptr = ptr;
    }
   }


/*****************************************************************************/
/*									     */
/* MREMOVE - REMOVE AN ITEM FROM THE FREE LIST. 			     */
/*									     */
/*****************************************************************************/

static void mremove(ptr)

   PACKET *ptr;

   {
    register PACKET *current = sys_free;
    register PACKET *last    = NIL;

    /********************************************************************/
    /* SCAN THROUGH LIST, LOOKING FOR PACKET TO REMOVE			*/
    /********************************************************************/
    while ((current != NIL) && (current != ptr))
    {
	last	= current;
	current = current->size_ptr;
    }

    /********************************************************************/
    /* REMOVE THE PACKET FROM THE LIST.   THERE ARE TWO CASES : 	*/
    /*	 THE OLD POINTER WILL EITHER BE THE FIRST, OR NOT THE FIRST.	*/
    /********************************************************************/
    if (current == NIL) 	 /* POINTER NOT FOUND IN LIST		*/
       sys_free = NIL;		 /* FATAL ERROR 			*/

    else if (last == NIL)	 /* PTR WAS BE FIRST IN THE LIST	*/
       sys_free = ptr->size_ptr;

    else			 /* PTR IS IN THE MIDDLE OF THE LIST	*/
       last->size_ptr = ptr->size_ptr;
   }


/*****************************************************************************/
/*									     */
/*  MINIT - This function can be called by the user to completely reset the  */
/*	    memory management system.					     */
/*									     */
/*****************************************************************************/

void minit()

   {
    /************************************************************************/
    /* TO INITIALIZE THE MEMORY SYSTEM, DEALLOCATE ONE PACKET WHICH USES    */
    /* AVAILABLE MEMORY, INITIALIZE THE FREE LIST TO POINT TO IT.	    */
    /************************************************************************/
    sys_free = (PACKET *)_sys_memory;

    sys_free->packet_size = -(MEMORY_SIZE - 1);
    sys_free->size_ptr	  = NIL;
   }


/*****************************************************************************/
/*									     */
/*  MALLOC - Allocate a packet of a given size, and return pointer to it.    */
/*	     This function only allocates in multiple of ints.      	     */
/*									     */
/*****************************************************************************/
void *malloc(size)

   register int size;

 {
    register PACKET *current = sys_free;
    register int  oldsize;

    if (size  < 0) return(0);
    if (size == 0) size = 1;

    /***********************************************************************/
    /* SCAN THROUGH FREE LIST FOR PACKET LARGE ENOUGH TO CONTAIN PACKET    */
    /* REMEMBER THAT FREE PACKAGE SIZES ARE NEGATIVE, SO NEGATE SIZE.      */
    /***********************************************************************/
    size = -size;
    while ((current != NIL) && (current->packet_size > size))
       current = current->size_ptr;

    if (current == NIL) return (char *) 0;

    oldsize = current->packet_size;	 /* REMEMBER OLD SIZE		 */
    mremove(current);		         /* REMOVE PACKET FROM FREE LIST */

    /******************************************************************/
    /* IF PACKET IS LARGER THAN NEEDED, FREE EXTRA SPACE AT END	      */
    /* BY INSERTING REMAINING SPACE INTO FREE LIST.                   */
    /******************************************************************/
    if (size - oldsize >= 2)
    {
       register PACKET *next = (PACKET *) ((char *) current + 1 - size);
       next->packet_size = oldsize - size + 1;
       minsert(next);
       current->packet_size = -size;
    }
    else current->packet_size = -oldsize;

    return (char *) &(current->size_ptr);
 }


/*****************************************************************************/
/*									     */
/*  CALLOC - Allocate a packet of a given size, set the data in the packet   */
/*	     to nulls, and return a pointer to it.			     */
/*									     */
/*****************************************************************************/
void *calloc(num, size)

   unsigned int num, size;

   {
    register int  i	   = size * num;
    register int  *current = malloc(i);
    register char *save    = (char *)current;

    if (current == 0) return 0;
    while (i--) *current++ = 0;
    return save;
   }




/*****************************************************************************/
/*									     */
/*  REALLOC - Reallocate a packet to a new size.			     */
/*									     */
/*****************************************************************************/
char *realloc(packet, newsize)

    char *packet;		 /* POINTER TO PACKET TO REALLOCATE */
    register int  newsize;	 /* NEW SIZE TO ALLOCATE	    */

   {
    register char *pptr = packet - 1;          /* PTR TO START OF PACKET */
    register int oldsize;

    /****************************************************************/
    /* HANDLE SPECIAL CASES                                         */
    /****************************************************************/
    if (newsize < 0)        return(0);
    if (packet == 0)        return(malloc(newsize));
    if (newsize == 0)     { free(packet);  return (0); }
    oldsize = ((PACKET *)pptr)->packet_size;
    if (oldsize <= 0)       return(0);
    if (newsize == oldsize) return(packet);

    /****************************************************************/
    /* IF NEW SIZE IS LESS THAN CURRENT PACKET SIZE,		    */
    /* TRUNCATE THE PACKET AND RETURN END TO FREE LIST		    */
    /****************************************************************/
    if (newsize < oldsize)
    {
       if (oldsize - newsize < 2) return(packet);
       ((PACKET *)pptr)->packet_size = newsize;   /* SET NEW PACKET SIZE   */
       pptr += newsize + 1;                       /* SET PTR TO NEW PACKET */
       ((PACKET *)pptr)->packet_size = oldsize - newsize - 1; 
       free(pptr + 1);      			  /* FREE TRAILING PACKET  */
       return(packet);
    }

    /****************************************************************/
    /* IF NEW SIZE IS BIGGER THAN CURRENT PACKET,		    */
    /*	1) CHECK NEXT PACKET IN LIST, SEE IF PACKET CAN BE EXPANDED */
    /*	2) IF NOT, MOVE PACKET TO NEW LOCATION. 		    */
    /****************************************************************/
    else
    {
      PACKET *next = (PACKET *)(pptr + oldsize + 1);
      int temp;

      if (((int *)next < &_sys_memory[MEMORY_SIZE - 2]) &&
	 ((next->packet_size < 0)                       &&
	 ((temp = oldsize - next->packet_size - newsize + 1) >= 0)))
      {
	  mremove(next);
	  if (temp < 2)
	  {
	     ((PACKET *)pptr)->packet_size = newsize + temp;
	     return(packet);
	  }

	  /*********************************************************/
          /* FREE TRAILING PACKET                                  */
	  /*********************************************************/
	  ((PACKET *)pptr)->packet_size = newsize;
	  pptr += newsize + 1;
	  ((PACKET *)pptr)->packet_size = -(temp - 1);
	  minsert(pptr);
	  return(packet);
      }
      else
      {
	  /************************************************************/
	  /* ALLOCATE NEW PACKET AND MOVE DATA INTO IT. 	      */
	  /************************************************************/
	  register char *new = malloc(newsize);
	  if (new == 0) return (0);
	  movmem(pptr+1, new, oldsize);
	  free(packet);
	  return(new);
      }
    }
   }


/*****************************************************************************/
/*									     */
/*  FREE - Return a packet allocated by malloc to free memory pool.	     */
/*									     */
/*****************************************************************************/

void free(ptr)

   register char *ptr;

   {
    PACKET *last;	 /* POINT TO PREVIOUS PACKET  */
    register PACKET *current;	 /* POINTER TO THIS PACKET    */
    register PACKET *next;	 /* POINTER TO NEXT PACKET    */

    last = next = NIL;		 /* INITIALIZE POINTERS 		*/
    ptr--;			 /* ADJUST POINT TO BEGINNING OF PACKET */

    current = (PACKET *)_sys_memory;

    /*********************************************************************/
    /* SEARCH FOR THE POINTER IN THE PACKET POINTED TO			 */
    /*********************************************************************/
    while (current < (PACKET *) ptr)
    {
      int tempsize = current->packet_size;
      last = current;
      if (tempsize < 0) tempsize = -tempsize; 
      current = (PACKET *)((char *)current + tempsize + 1);
    }

    /*********************************************************************/
    /* CHECK FOR POINTER OR PACKET ERRORS.				 */
    /*********************************************************************/
    if ((current != (PACKET *) ptr) || (current->packet_size < 0))
       return;

    current->packet_size = -current->packet_size; /* MARK PACKET AS FREE */

    /*********************************************************************/
    /* GET POINTER TO NEXT PACKET IN MEMORY, IF ANY.			 */
    /*********************************************************************/
    next = (PACKET *) ((char *)current - current->packet_size + 1);
    if (next > (PACKET *) &_sys_memory[MEMORY_SIZE - 1]) next = NIL;

    /*********************************************************************/
    /* ATTEMPT TO COLLESCE THE THREE PACKETS (PREVIOUS, CURRENT, NEXT)	 */
    /*********************************************************************/
    if ((last != NIL) && (last->packet_size < 0))
    {
       if ((next != NIL) && (next->packet_size < 0))
       {
	  mremove(last);
	  mremove(next);
	  last->packet_size += next->packet_size + current->packet_size - 2;
	  minsert(last);
	  return;
       }
       else
       {
	  mremove(last);
	  last->packet_size += current->packet_size - 1;
	  minsert(last);
	  return;
       }
    }

    /*********************************************************************/
    /* ATTEMPT TO COLLESCE THE CURRENT WITH NEXT PACKET. (CURRENT, NEXT) */
    /*********************************************************************/
    else if ((next != NIL) && (next->packet_size < 0))
    {
       mremove(next);
       current->packet_size += next->packet_size - 1;
       minsert(current);
       return;
    }

    /*********************************************************************/
    /* NO COLLESCENCE POSSIBLE, JUST INSERT THIS PACKET INTO LIST	 */
    /*********************************************************************/
    else minsert(current);
    return;
   }

memset.c/       624131618   0     0     0       518       `
/****************************************************************************/
/*  memset v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

void *memset(mem, ch, length)
     char *mem;   
     register char ch;
     register int  length;
{
     register char *str = mem - 1;

     while (length-- > 0) *++str = ch;
   
     return (mem);
}
mktime.c/       624131618   0     0     0       4106      `
/****************************************************************************/
/*  mktime v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "time.h" 

static unsigned int  mon_len[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
static unsigned int  mon_day[] = { 0,31,59,80,120,151,181,212,243,273,304,334 };

#define JAN11900    0                   
#define DAYS_IN_YR  365     
#define SECS_IN_DAY (60 * 60 * 24)
#define SECS_IN_YR  (DAYS_IN_YR * SECS_IN_DAY)

time_t mktime(tptr)    
   register struct tm *tptr;
{
   time_t       result;
   register int daycount;
   unsigned     returnval;
    
   /*-----------------------------------------------------------------*/
   /* HANDLE SECONDS.  IF TOO MANY OR TOO FEW, MODIFY MINUTES.        */
   /*-----------------------------------------------------------------*/
   if (tptr->tm_sec  < 0)
   { 
	tptr->tm_min -= (-tptr->tm_sec / 60) + 1;
	tptr->tm_sec  = 60 - (-tptr->tm_sec % 60);
   }
   tptr->tm_min  += tptr->tm_sec  / 60; tptr->tm_sec  %= 60; 

   /*-----------------------------------------------------------------*/
   /* HANDLE MINUTES.  IF TOO MANY OR TOO FEW, MODIFY HOURS           */
   /*-----------------------------------------------------------------*/
   if (tptr->tm_min  < 0)
   { 
	tptr->tm_hour -= (-tptr->tm_min / 60) + 1;
	tptr->tm_min   = 60 - (-tptr->tm_min % 60);
   }
   tptr->tm_hour += tptr->tm_min  / 60; tptr->tm_min  %= 60; 

   /*-----------------------------------------------------------------*/
   /* HANDLE HOURS.    IF TOO MANY OR TOO FEW, MODIFY DAYS            */
   /*-----------------------------------------------------------------*/
   if (tptr->tm_hour < 0)
   { 
	tptr->tm_mday -= (-tptr->tm_hour / 24) + 1;
	tptr->tm_hour  = 24 - (-tptr->tm_hour % 60);
   }
   tptr->tm_mday += tptr->tm_hour / 24; tptr->tm_hour %= 24; 

   for (;;)
   {
      /*-----------------------------------------------------------------*/
      /* HANDLE MONTHS.   IF TOO MANY OR TOO FEW, MODIFY YEARS           */
      /*-----------------------------------------------------------------*/
      if (tptr->tm_mon < 0)
      { 
	   tptr->tm_year -= (-tptr->tm_mon / 12) + 1;
	   tptr->tm_mon   = 12 - (-tptr->tm_mon % 12);
      }
      tptr->tm_year += tptr->tm_mon / 12; tptr->tm_mon %= 12; 

      /*-----------------------------------------------------------------*/
      /* HANDLE DAYS.     IF TOO MANY OR TOO FEW, MODIFY MONTHS          */
      /*-----------------------------------------------------------------*/
      if (tptr->tm_mday <= 0)
      { 
	   tptr->tm_mon--;  
           tptr->tm_mday += mon_len[tptr->tm_mon < 0 ? 11 : tptr->tm_mon] + 
		        ((tptr->tm_mon == 1) && ((tptr->tm_year % 4) == 0));
	   continue;
      }

      /*-----------------------------------------------------------------*/
      /* CALCULATE NUMBER OF DAYS IN THIS MONTH.                         */
      /*-----------------------------------------------------------------*/
      daycount = mon_len[tptr->tm_mon] + 
		((tptr->tm_mon == 1) && ((tptr->tm_year % 4) == 0));

      if (tptr->tm_mday > daycount) 
	{ tptr->tm_mday -= daycount; tptr->tm_mon++; }
      else break;
   }

   /*--------------------------------------------------------------------*/
   /* WE CAN NOW BE SURE THAT ALL FIELDS IN THE TIME STRUCTURE ARE RIGHT */
   /*--------------------------------------------------------------------*/
   tptr->tm_yday = mon_day[tptr->tm_mon]  + tptr->tm_mday +
                   (((tptr->tm_year % 4) == 0) && (tptr->tm_mon > 1));

   daycount      = tptr->tm_year * DAYS_IN_YR  + 
	           ((tptr->tm_year - 1) / 4)   + tptr->tm_yday;

   result        = daycount      * SECS_IN_DAY + 
	           tptr->tm_hour * (60 * 60)   +
	           tptr->tm_min  * 60          + tptr->tm_sec;

   tptr->tm_wday = (JAN11900 + daycount) % 7;
   tptr->tm_isdst= 0;    /* OF COURSE, THIS IS ONLY INVALID IN W. INDIANA */

   return (result);
}

qsort.c/        624131618   0     0     0       1751      `
/****************************************************************************/
/*  qsort v2.10                                                             */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
static void swap_item();

void qsort(base, nmemb, size, compar)
   register char *base;         /* POINTER TO ARRAY OF ELEMENTS */
   int            nmemb;        /* NUMBER OF ELEMENTS TO SORT   */
   int            size;         /* SIZE IN BYTES OF EACH ITEM   */
   int          (*compar)();    /* COMPARE FUNCTION             */

{
   register int   i      = 0;             /* left scan index  */
   register int   j      = nmemb - 1;     /* right scan index */
   register int   pivot  = (nmemb / 2);
   register char *pivp   = base + (pivot * size);

   while( i < j )
   {
      while( (*compar) (base + (i * size), pivp) < 0 ) ++i;
      while( (*compar) (base + (j * size), pivp) > 0 ) --j;
      if( i < j )
      {
	 swap_item(base + (i * size), base + (j * size), size);
	 if     ( pivot == i ) { pivot = j; pivp = base + (pivot * size); }
	 else if( pivot == j ) { pivot = i; pivp = base + (pivot * size); } 
	 ++i; --j;
      }
      else if ( i == j ) { ++i; --j;  break; }
   }

   if( j > 0)     qsort(base, j + 1, size, compar);
   if( i < nmemb-1) qsort(base + (i * size), nmemb - i, size, compar);
}


static void swap_item(from, to, size)
    char *from;
    char *to;  
    int   size;
{
    register char *src   = from - 1;
    register char *dest  = to - 1;
    register int   rsize = size + 1;
    register int temp;       

    while (--rsize)
    {
	temp  = *++src;
	*src  = *++dest;
	*dest = temp; 
    }
}


rand.c/         624131618   0     0     0       701       `
/****************************************************************************/
/*  rand.c v2.10							    */
/*  Copyright (c) 1989 Texas Instruments Inc.				    */
/****************************************************************************/

/***************************************************************/
/* THIS IS AN IMPLEMENTATION WHICH IS INTENDED TO BE PORTABLE, */
/* AS PER THE ANSI STANDARD C SPECIFICATION                    */
/***************************************************************/
static unsigned long next = 1;

int rand()
{
     next = next * 1103515245 + 12345;
     return (unsigned int)(next/65536) % 32768; 
}

void srand(seed)
     int seed; 
{
     next = seed;
}


strcat.c/       624131620   0     0     0       639       `
/****************************************************************************/
/*  strcat v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

char *strcat(string1, string2)
     char *string1;
     char *string2;
{
     register char *r1 = string1 - 1;
     register char *r2 = string2 - 1;

     while (*++r1);                           /* FIND END OF STRING   */
     for (r1--; *++r1 = *++r2; );             /* APPEND SECOND STRING */
     return (string1);
}


strchr.c/       624131620   0     0     0       574       `
/****************************************************************************/
/*  strchr v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

char *strchr(string, ch)
     char *string;
     char  ch;
{
     register char *str = string - 1;
     register char  rch = ch;
     register char  tch;

     for (;;)
        if ((tch = *++str) == rch) return(str);
        else if (tch == 0) return(0);
}
strcoll.c/      624131620   0     0     0       562       `
/****************************************************************************/
/*  strcoll v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

int   strcoll(string1, string2)
     char *string1;
     char *string2;
{
     register char *r1 = string1 - 1;
     register char *r2 = string2 - 1;
     register char cp;

     while ((*++r2 == (cp = *++r1)) && cp);
     return (*r1 - *r2);
}
strcpy.c/       624131620   0     0     0       501       `
/****************************************************************************/
/*  strcpy v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

char *strcpy(to, from)
     char *to;
     char *from;
{
     register char *rto   = to - 1;
     register char *rfrom = from - 1;

     while (*++rto = *++rfrom);
     return (to);
}

strcspn.c/      624131620   0     0     0       770       `
/****************************************************************************/
/*  strcspn v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

int strcspn(string, chs)
     char *string;
     char *chs;
{
     register char *str = string - 1;
     register char ch;
     int count = 0;

     while (ch = *++str)  /* FOR EACH CHARACTER IN STRING */
     {
        register char *check = chs;
	register char  tch   = *check;

        while(tch)    /* FOR EACH CHARACTER IN LOOKUP STRING */
           if (ch == tch) return (count);
	   else tch = *++check;

	count++;
     }

     return(count);
}
strerror.c/     624131620   0     0     0       389       `
/****************************************************************************/
/*  strerror  v2.10                                                         */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

char *strerror(errno)
     int errno;
{
     return ("string error");
}

strftime.c/     624131620   0     0     0       3101      `
/****************************************************************************/
/*  strftime v2.10                                                          */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "time.h" 

static char *fday[] = { "Sunday",   "Monday", "Tuesday", "Wednesday", 
			"Thursday", "Friday", "Saturday" };
static char *fmon[] = { "January", "February", "March", "April", "May", "June",
			"July", "August", "September", "October", "November",
			"December" };
			

int strftime(out, maxsize, format, time)
   register char *out;
            int   maxsize;
   register char *format;
   register struct tm *time;
{
    register int count = 0;
    char buf[30];

    mktime(time);     /* MAKE SURE THIS IS A LEGITIMATE TIME */

    for (;;)
    {
          while ((count < maxsize) && *format && (*format != '%'))
	  {
	      count++;
	      *out++ = *format++;
	  }

	  if (count >= maxsize) return 0;
	  if (*format == '\0')  { *out = 0; return (count); }

	  switch (*++format)
	  {
               case '%' : strcpy(buf, "%");                             break;
	       case 'Z' : strcpy(buf, "Central");                       break;

	       case 'A' : strcpy(buf, fday[time->tm_wday]);             break;
	       case 'a' : strcpy(buf, fday[time->tm_wday]); buf[3] = 0; break;
	       case 'B' : strcpy(buf, fmon[time->tm_mon]);              break;
	       case 'b' : strcpy(buf, fmon[time->tm_mon]);  buf[3] = 0; break;
	       case 'c' : strcpy(buf, asctime(time));                   break; 

	       case 'I' : sprintf(buf, "%02d", time->tm_hour % 12);     break;
	       case 'H' : sprintf(buf, "%02d", time->tm_hour);          break;
	       case 'M' : sprintf(buf, "%02d", time->tm_min);           break;
	       case 'S' : sprintf(buf, "%02d", time->tm_sec);           break;
	       case 'j' : sprintf(buf, "%03d", time->tm_yday);          break;
	       case 'd' : sprintf(buf, "%02d", time->tm_mday);          break;
	       case 'w' : sprintf(buf, "%1d",  time->tm_wday);          break;
	       case 'm' : sprintf(buf, "%02d", time->tm_mon + 1);       break;
	       case 'y' : sprintf(buf, "%02d", time->tm_year);          break;
	       case 'Y' : sprintf(buf, "%4d", 1900 + time->tm_year);    break;

	       case 'p' : strcpy(buf, time->tm_hour >= 12 ? "PM":"AM"); break;

	       case 'W' :
	       case 'U' : sprintf(buf, "%2d", time->tm_yday / 7);       break;

	       case 'x' : sprintf(buf, "%3s %d, %d", fmon[time->tm_mon], 
				time->tm_mday, time->tm_year + 1900);   break;
	       case 'X' : sprintf(buf, "%02d:%02d:%02d", time->tm_hour, 
					   time->tm_min, time->tm_sec); break;
	  }

          /*-------------------------------------------------------------*/
          /* IF THIS STRING WILL FIT IN BUFFER, APPEND TO BUFFER         */
          /*-------------------------------------------------------------*/
	  if ((count += strlen(buf)) > maxsize) return 0;
	  strcpy(out, buf);
	  out += strlen(buf);
	  format++;
    }
}

strlen.c/       624131620   0     0     0       482       `
/****************************************************************************/
/*  strlen v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

unsigned int strlen(string)
     char *string;
{
     register char *rstr = string - 1;
     register int   n    = 0;

     while (*++rstr) n++;
     return (n);
}

strncat.c/      624131622   0     0     0       742       `
/****************************************************************************/
/*  strncat v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

char *strncat(to, from, n)
     char *to;
     char *from;
     int n;
{
     register char *r1 = to - 1;
     register char *r2 = from - 1;
     register int   rn = n;

     while (*++r1);                                /* FIND END OF STRING   */
     for (r1--; (--rn >= 0) && (*++r1 = *++r2););  /* APPEND SECOND STRING */
     r1[1] = 0;                                    /* ADD TERMINATION      */
     return (to);
}

strncmp.c/      624131622   0     0     0       696       `
/****************************************************************************/
/*  strncmp v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

int   strncmp(string1, string2, n)
     char *string1;
     char *string2;
     int  n;
{
     register char *r1 = string1 - 1;
     register char *r2 = string2 - 1;
     register int   rn = n;
     register char  cp;

     if (rn <= 0) return(0);                   /* SPECIAL CASE n <= 0 */

     while ((--rn >= 0) && ((cp = *++r1) == *++r2) && cp);
     return (*r1 - *r2);
}
strncpy.c/      624131622   0     0     0       640       `
/****************************************************************************/
/*  strncpy V2.00                                                           */
/*  Copyright (c) 1988, 1989 Texas Instruments Inc.                         */
/****************************************************************************/

char *strncpy(to, from, n)
     register char *to;
     register char *from;
     register int n;
{
     register char *result = to;

     while ((--n >= 0) && (*to++ = *from++));    /* COPY STRING         */
     from = 0;
     while (--n >= 0) *to++ = (char)from;        /* TERMINATION PADDING */
     return (result);
}
strpbrk.c/      624131622   0     0     0       711       `
/****************************************************************************/
/*  strpbrk v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

char *strpbrk(string, chs)
     char *string;
     char *chs;
{
     register char *str = string - 1;
     register char ch;

     while (ch = *++str)  /* FOR EACH CHARACTER IN STRING */
     {
        register char *check = chs - 1;
	register char  tch;

        while(tch = *++check)    /* FOR EACH CHARACTER IN LOOKUP STRING */
           if (ch == tch) return str;
     }

     return 0;
}

strrchr.c/      624131622   0     0     0       634       `
/****************************************************************************/
/*  strrchr v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

char *strrchr(string, ch)
     char *string;
     char  ch;
{
     register char *str = string - 1;
     register char  rch = ch;
     register char  tch;
     register char *result = (char *)0;

     for (;;)
        if ((tch = *++str) == rch) result = str;
        else if (tch == 0) break;

     return(result);
}
strspn.c/       624131622   0     0     0       762       `
/****************************************************************************/
/*  strspn  v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

int strspn(string, chs)
     register char *string;
     char *chs;
{
     int count = 0;

     for (;;)         /* FOR EACH CHARACTER IN STRING */
     {
	register char  ch    = *string++;
        register char *check = chs;
	register char  tch   = *check++;

        while (tch)      /* FOR EACH CHARACTER IN LOOKUP STRING */
	{
	   if (ch == tch) break;
	   tch = *check++;
	}

        if (!ch || ch != tch) return(count);
	count++;
     }
}
strstr.c/       624131622   0     0     0       730       `
/****************************************************************************/
/*  strstr v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

char *strstr(string1, string2)
     register char *string1;
     char *string2;
{
     register char cp1;
     register char cp2;
     char *pos = string1;

     while (*string1)         /* FOR EACH STRING IN SOURCE STRING */
     {
         register char *cmp = string2;

         while (((cp1 = *string1++) == (cp2 = *cmp++)) && cp1);
	 if (cp2 == 0) return (pos);
	 string1 = ++pos;
     }
     return (0);
}

strtod.c/       624131622   0     0     0       2780      `
/****************************************************************************/
/*  strtod v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "ctype.h"

static double powerof10[]  = { 1.e1, 1.e2, 1.e4, 1.e8, 1.e16, 1.e32 };
static double digits[]     = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

double strtod(st, endptr)
  char  *st;
  char  **endptr;
{
    double        result = 0;
    register char cp;
    register char *fst   = st;
    register int  exp    = 0;               /* EXPONENT              */
    register int  count;                    /* EXPONENT CALCULATION  */
    int           value  = 0;               /* SUCCESSFUL PARSE      */
    int           sign;

    while (_isspace(*fst)) ++fst;  /* SKIP WHITE SPACE */
    if ((sign = ((cp = *fst) == '-')) || (cp == '+')) { ++fst; value = 1; }

    /************************************************************************/
    /* READ IN FRACTIONAL PART OF NUMBER, UNTIL AN 'E' IS REACHED.          */
    /* COUNT DIGITS AFTER DECIMAL POINT.                                    */
    /************************************************************************/
    for (; _isdigit(cp = *fst); ++fst) 
    {
       result = result * 10 + digits[cp - '0']; 
       value  = 1;
    }

    if (cp == '.')
       while (_isdigit(cp = *++fst)) 
       {
          result = result * 10 + digits[cp - '0']; 
          value  = 1;
	  --exp;
       }

    if (sign) result = -result;  /* IF NEGATIVE NUMBER, REVERSE SIGN */

    /*****************************************************************/
    /* READ IN EXPLICIT EXPONENT AND CALCULATE REAL EXPONENT.        */
    /*****************************************************************/
    if (value && _toupper(*fst) == 'E')
    {
       if ((sign = ((cp = *++fst) == '-')) || (cp == '+')) cp = *++fst;

       for (count = 0; _isdigit(cp); cp = *++fst)
	  { count *= 10; count += cp - '0'; }

       if (sign) exp -= count;
	    else exp += count;
    }

    if (sign = (exp < 0)) exp *= -1;
    exp &= 0x3F;                                    /* MAX EXPONENT IS +-38 */

    /************************************************************************/
    /* ADJUST NUMBER BY POWERS OF TEN SPECIFIED BY FORMAT AND EXPONENT.     */
    /************************************************************************/
    count = 0;
    if (sign) for (; exp; count++, exp >>= 1)
	      {  if (exp & 1) result /= powerof10[count]; }

    else      for (; exp; count++, exp >>= 1)
	      {  if (exp & 1) result *= powerof10[count]; }

    if (endptr) *endptr = value ? fst : st;
    return result;
}
strtok.c/       624131622   0     0     0       698       `
/****************************************************************************/
/*  strtok v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "stddef.h"
#include "string.h"

char *strtok(str1, str2)
     char *str1;
     char *str2;
{
     static char *last_end;
     char        *start; 

     if (str1) last_end = str1;

     last_end += strspn(last_end, str2);
     if (*last_end == 0) return (NULL);

     start = last_end;
     last_end += strcspn(last_end, str2);
     *last_end++ = 0; 
     return start;
}

strtol.c/       624131622   0     0     0       1967      `
/****************************************************************************/
/*  strtol v2.10                                                            */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "limits.h"
#include "ctype.h"
#include "errno.h"

long strtol(st, endptr, base)
  char   *st;
  char  **endptr;
  unsigned int base; 
{
    register long result = 0;
    register char cp;
    register char *fst   = st;
    int  digits = 0;
    int  sign;

    while (_isspace(*fst)) ++fst;  /* SKIP WHITE SPACE */

    if (sign = ((cp = *fst) == '-')) cp = *++fst;
    else if (cp == '+') cp = *++fst;

    if (base > 36) base = 0;

    /*********************************************************************/
    /* DETERMINE BASE IF ZERO BASE ASKED FOR.                            */
    /*********************************************************************/
    switch (base)
    {
	case  0 : if (cp != '0') base = 10;
	          else if (((cp = *++fst) == 'X') || (cp == 'x')) 
		  { 
	              base = 16;  
		      cp = *++fst;    
		  }
		  else base = 8;
                  break;

        case 16 : if ((cp == '0') && ((fst[1] == 'x') || (fst[1] == 'X')))
		      cp = *(fst += 2);
    }

    for (;; cp = *++fst)
    {
	register long addval;

	if (!((_isdigit(cp) && (addval = cp - '0')      < base) ||
	      (_isupper(cp) && (addval = cp - 'A' + 10) < base) ||
	      (_islower(cp) && (addval = cp - 'a' + 10) < base)))  break;

        if (result == (addval = (result * base + addval))/base) result = addval;
	else 
	{   
	    errno = ERANGE;
	    if (endptr) *endptr = st;       
	    return (sign ? LONG_MIN : LONG_MAX); 
	}

	digits++;
    }

    if (endptr) *endptr = digits ? fst : st;
    if (sign)
    {
	if (result > LONG_MAX) { errno = ERANGE; return (LONG_MIN); }
        return -result;
    }
    return result;
}


strtoul.c/      624131622   0     0     0       1981      `
/****************************************************************************/
/*  strtoul v2.10                                                           */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/
#include "limits.h"
#include "ctype.h"
#include "errno.h"

unsigned long strtoul(st, endptr, base)
  char        *st;
  char       **endptr;
  unsigned int base; 
{
    register unsigned long result = 0;
    register char cp;
    register char *fst = st;
    int sign;
    int digits = 0;

    while (_isspace(*fst)) ++fst;  /* SKIP WHITE SPACE */
    if (base > 36) base = 0;  

    if (sign = ((cp = *fst) == '-')) cp = *++fst;
    else if (cp == '+') cp = *++fst;

    /*********************************************************************/
    /* DETERMINE BASE IF ZERO BASE ASKED FOR.                            */
    /*********************************************************************/
    switch (base)
    {
	case  0 : if (cp != '0') base = 10;
	          else if (((cp = *++fst) == 'X') || (cp == 'x')) 
		  { 
	              base = 16;  
		      cp = *++fst;    
		  }
		  else base = 8;
                  break;

        case 16 : if ((cp == '0') && ((fst[1] == 'x') || (fst[1] == 'X')))
		      cp = *(fst += 2);
    }

    for (;; cp = *++fst)
    {
	register unsigned long addval;

	if (!((_isdigit(cp) && (addval = cp - '0')      < base) ||
	      (_isupper(cp) && (addval = cp - 'A' + 10) < base) ||
	      (_islower(cp) && (addval = cp - 'a' + 10) < base)))  break;

        if (result == (addval = (result * base + addval))/base) result = addval;
	else 
	{   
	    errno = ERANGE;
	    if (endptr) *endptr = st;        
	    return (ULONG_MAX); 
	}

	digits++;
    }

    if (endptr) *endptr = digits ? fst : st;
    if (sign)
    {
	if (result > INT_MAX) { errno = ERANGE; return (ULONG_MAX); }
	return (-result);
    }
    return result;
}


time.c/         624131622   0     0     0       738       `
/****************************************************************************/
/*  time v2.10                                                              */
/*  Copyright (c) 1989 Texas Instruments Inc.                               */
/****************************************************************************/

/****************************************************************************/
/* OBVIOUSLY, THIS IS SIMPLY A STUB, WHICH BY DEFINITION RETURNS -1         */
/* IF THE SYSTEM TIME IS UNAVAILABLE.                                       */ 
/****************************************************************************/
#include "time.h" 

time_t time(timer)
   time_t *timer;
{
    if (timer) *timer = -1;
    return -1;
}
