Standard Library Functions for C02 Programs At the beginning of the program use the directives #include The following functions are defined: c = abs(b); Returns the absolute value of the two's-complement byte b. In two's-complement arithmetic, the unsigned values 0 - 127 are considered positive, while the unsigned values 128 - 255 are considered negative. c = atoc(s); Returns the numeric value of the string in array s. Does not skip leading white-space characters and stops when first non-digit character is encountered. Overflows are ignored, so numbers greater than 255 will be returned modulo 256. ctoa(c, &s); Stores the ASCII representation of unsigned byte c as a null-terminated string in array s. The array must be dimensioned to at least 4 bytes. c = max(b, d); Returns the greater of the two unsigned bytes b and d. c = min(b, d); Returns the lesser of the two unsigned bytes b and d. c = mult(d, r); Returns the product of byte d times byte r. Overflows are ignored, so results greater than 255 will be returned modulo 256. c = div(n, d); Returns the quotient of byte n divided by byte d. Remainders are discarded and division by 0 returns ??. c = rand(); Returns pseudo-random number. Sequence repeats after 255 repeated calls. The generator must be seeded using the rands() function before the first call to rand(). rands(n); Seeds the pseudo-random number generator. If n is 0, the generator is seeded with a system seed value. This should be used for normal operation. If n is not 0. then it is used as the seed. This can be used for program testing or when a predictable pattern is needed. Note: The system seed is generated by a counter or timer. On systems that don't use a timer, the counter is cycled by the keyboard routines, so the getkey() or getchr() function must called at least once before a rands(0) call. Note: This library expects the following function to be defined setsrc(&s); Set source string pointer and initialize index along with the zero page variables srclo,srchi: Source string pointer as well as the transient variables temp0 Temporary storage temp1 temp2 and the static variables random Psuedo-random number generator seed Value rdseed System generated initial seed (counter or timer)