From: kon@cs.titech.ac.jp (Narihito Kon)
Subject: Re: Sharp PC-E500
Organization: Department of Computer Science, Tokyo Institute of Technology
Date: Sat, 26 Sep 1992 06:26:35 GMT

Hello.

In article <1992Sep25.162423.723@ae.chalmers.se> lindgren@ae.chalmers.se (ULF A LINDGREN) writes:
>I would like to know if there is a C-compiler for the Sharp PC-E500.

	From my little acquaintance, there is no C-compiler for Sharp
PC-E500. I heard that there is a C-compiler ( which was made out of
japan ) for a Sharp electric organizer, and both PC-E500 and the
electric organizer use same CPU. But I don't know if the C-compiler
is also available for PC-E500 or not.

	Some month ago, I also thought about C-compiler. So I made
C-"like"-compiler for PC-E500. Below are the example of source program
for the compiler. 

Ex.1 Change downcase character to upcase one.
----------------------------------------------------------------------
1000 const EOF -1;
1020 char name[16];
1030 int fd,c,length;
1050 func char fgetc2(char fd):
1060 char high,low;
1070 int c;
1080 {
1090 	if ( length == 0) {
1100 		high = fgetc(fd);
1110 		if ( high == $ff ) {
1120 			fclose(fd);
1130 			puts("");
1140 			exit;
1150 		};
1160 		low  = fgetc(fd); /* print line number */
1170 		printf("^M%d:",(pnt high) * 256 + low);
1180 		length = fgetc(fd);
1190 	};
1200 	c = fgetc(fd);
1210 	length -= 1;
1220 	return c;
1230 }
1240 { /* Main */
1250 	printf("Filename(default ^"S1:TEXT.BAS^"):");
1260 	scanf("%s",&name);
1270 	puts("");
1280 	if ( strlen(&name) == 0 ) {
1290 		strcpy(&name,"S1:TEXT.BAS");
1300 	};
1310 	if ( ( fd = fopen( &name , 3 ) ) == EOF ) {
1320 		printf("Can^'t open ^"%s^"^M^J" , &name );
1330 		exit;
1340 	};
1350 	fd = char fd;
1360 	if ( char fgetc(fd) != $ff ) {
1370 		puts("Not a TEXT-FORMAT file");
1380 		fclose(fd);
1390 		exit;
1400 	};
1410 	fseek(fd , 19 , 0);
1420 	length = 0;
1430 	while ( 1 ) {
1440 		c = fgetc2(fd);
1450 		while ( ( c == '^"' ) | ( c == '^'') ) {
1460 			do { /* skip strings in "" and '' */
1470 				c = fgetc2(fd);
1480 				if ( c == '^^' ) {
1490 					fgetc2(fd);
1500 					c = fgetc2(fd);
1510 				};
1520 			} until ( ( c == '^"' ) | ( c == '^'' ) );
1530 			c = fgetc2(fd);
1540 		};
1550 		if ( ( c >= 'A' ) & ( c <= 'Z' ) ) {
1560 			c += $20;
1570 			fseek(fd , -1 , 1);
1580 			fputc(fd,c);
1590 		};
1600 	};
1610 }
----------------------------------------------------------------------------

Ex.2 Tiny telephone number database. this program makes a file named
"TEL.DAT" on current drive.
----------------------------------------------------------------------------
1000 const l_name 32;
1010 const l_adrs 80;
1020 const l_tel  16;
1030 const l_data l_name + l_adrs + l_tel;
1050 char name[l_name];
1060 char adrs[l_adrs];
1070 char tel[l_tel];
1080 int fd;
1090 char c;
1110 func char d_write:
1120 {
1130 	do {
1140 		putc('^L');
1150 		printf("Name:");
1160 		gets(&name);
1170 		puts("");
1180 		printf("Adrs:");
1190 		gets(&adrs);
1200 		puts("");
1210 		printf("Tel :");
1220 		gets(&tel);
1230 		puts("");
1240 		puts("OK? (^'y^' or else)");
1250 	} until ( upcase (getc) == 'Y' );
1260 	fseek( fd , 0 , 2 );
1270 	if ( fwrite( fd , &name , l_data ) != l_data ) {
1280 		puts("Data write error.");
1290 	};
1300 }
1320 func char d_list:
1330 char c;
1340 pnt number;
1350 {
1360 	fseek( fd , 0 , 0 );
1370 	do {
1380 		if ( fread( fd , &name , l_data ) != l_data ) {
1390 			puts("Data read error");
1400 		} else {
1410 			puts(&name);
1420 			puts(&adrs);
1430 			puts(&tel);
1440 		};
1450 		puts("[Q]uit [J]ump [B]ack or else(Show next)");
1460 		c = upcase( getc );
1470 		if ( c == 'J' ) {
1480 			printf("Number:");
1490 			scanf("%d",&number);
1500 			puts("");
1510 			number -= 1;
1520 			number *= l_data;
1530 			if ( fseek( fd , number , 0 ) != number ) {
1540 				puts("Not exist such a data");
1550 			};
1560 		};
1570 		if ( c == 'B' ) {
1580 			fseek( fd , - ( l_data * 2 ) , 1 );
1590 		};
1600 	} until ( c == 'Q' );
1610 }
1630 { /* Main */
1640 	if ( (fd = fopen("TEL.DAT",3)) == -1 ) {
1650 		if ( (fd = fcreat("TEL.DAT",0)) == -1 ) {
1660 			puts("Can^'t make database.");
1670 			exit;
1680 		};
1690 	};
1700 	while (1) {
1710 		puts("^L*** MENU ***");
1720 		puts("[L]ist [W]rite [Q]uit");
1730 		c = upcase( getc );
1740 		if ( c == 'Q' ) {
1750 			fclose(fd);
1760 			exit;
1770 		};
1780 		if ( c == 'W' ) {
1790 			d_write;
1800 		};
1810 		if ( c == 'L' ) {
1820 			d_list;
1830 		};
1840 	};
1850 }
----------------------------------------------------------------------------

	If you want to know more about the compiler, please E-mail to
me. I'm ready to send the compiler. But all of documents are written
in japanese.

	I hope this will help you.

--
Narihito Kon
Dept. of Computer Science, Tokyo Institute of Tech., Japan
E-Mail : kon@cs.titech.ac.jp
HAM    : JK1OSG @ JR1YTD
Narihito Kon
Dept. of Computer Science, Tokyo Institute of Tech., Japan
E-Mail : kon@cs.titech.ac.jp
HAM    : JK1OSG @ JR1YTD
Newsgroups: comp.sys.handhelds