home *** CD-ROM | disk | FTP | other *** search
- /* (c) Copyright Franklin Software, Inc. 1989
- * 888 Saratoga Avenue, Suite #2
- * San Jose, Ca. 95129
- * ph/fax: (408) 296-8051/8061
- *
- * FileName: d2.c
- * Purpose: to demonstrate C functions and code generation
- * Input: none - self contained
- * Function: does a symbolic conversion of a data stream from CODE space
- * Output: returns :
- * DONE = 0
- * Error = ~0
- *
- * History: 890923 - swb - initial code
- *
- * Scope: Read an ASCII input stream from CODE space. Start by writing
- * '*'s out to XDATA space. Blank that space, and write out
- * a short Franklin message--scrambled with numbers. Sort
- * non-numeric characters (except dashes) and write directly
- * to XDATA space, and write the numeric values and dashes to
- * internal 8051 DATA space. Repeat till the cows come home.
- */
- #pragma code symbols debug objectextend
- #include <absacc.h>
-
- /*
- * Define our various data spaces. Note that access to these spaces can be
- * made with direct writes--no procedure calls are required!
- */
- code char arrayC[] = {
- "No4ha0u Co8rp-ora8ti6on6. Em-ula1tor8s f2or Mi0croControllers!"};
- data char arrayD[12];
- xdata char arrayX[ sizeof(arrayC) ];
-
- /*
- * This FUNCtion will copy whats pointed to by <src> into whats pointed to
- * by <dest>. Copying will continue until a NULL value is encountered.
- * Return a count of items processed.
- *
- * NOTE: Be certain that the <src> array is bounded by a terminating NULL!
- */
- char copy_char( char *dest, char *src ) {
- unsigned char cnt;
- while( *dest++ = *src++ )
- cnt++;
- return cnt;
- } /* end of FUNCtion copy_char() */
-
-
- /*
- * This PROCedure will set what's pointed to by post-incremented <dest> to
- * ZERO, <count> times. Nothing is returned.
- */
- void clr_char( char *dest, unsigned char count ) {
- while( count-- )
- *dest++ = ' ';
- }
-
-
- /*
- * This is the actual working routine called by main to do the demo at hand.
- * No parameters are required, and nothing is returned.
- */
- void moving_demo() {
- unsigned char c, n = 0;
- char *p1, *p2;
-
- /* fill the external data array with asterisks, just for drill */
- for( p1 = arrayX, c = sizeof( arrayC ); c-- ; )
- *p1++ = '*';
-
- /* fill the internal data space with some '#' signs, just to be different! */
- for( p2 = arrayD, c = sizeof( arrayD ); c-- ; )
- *p2++ = '#';
-
- c = copy_char( arrayX, arrayC ); /* copy code to Xdata */
-
- clr_char( arrayX, c ); /* flush the array */
-
- p1 = arrayC; /* set the pointer */
- p2 = arrayD;
-
- while( c = *p1++ ) {
- if ( ( c > '9' || c < '0' ) && c != '-' )
- XBYTE[ n++ ] = c;
- else
- *p2++ = c;
- }; /* end of while *p1 ... */
- } /* end of PROCedure moving_demo() */
-
-
- /*
- * The MAIN routine. This is just a placeholder, and gives us a way to
- * cleanly make this a forever test.
- */
- void main( char argc, char *argv[] ) {
-
- while( 1 ) moving_demo();
-
- } /* end of PROCedure main() */
-
- /* (c) Copyright Franklin Software, Inc. 1989 */
-
-