Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!wuarchive!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-pcd!hpcvra!frankw From: frankw@hpcvra.CV.HP.COM (Frank Wales) Newsgroups: comp.sys.handhelds Subject: Re: What If - someone wrote a HP-48SX C compiler? Message-ID: <21580037@hpcvra.CV.HP.COM> Date: 21 Mar 90 00:48:15 GMT References: <8697@rosevax.Rosemount.COM> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 51 [Note: I'm not an HP employee, and don't speak for them, but I do have experience pertinent to this topic.] In some article The Amazing Daniel Winker (daniel@rosevax.Rosemount.COM) asks about writing an HP-48 C compiler. Well, I don't want to sound to discouraging, but I think writing a C compiler for the 48 would be an interesting project, in the sense of the Chinese curse "may you live in interesting times." There are certain fundamental difficulties: -- the 48 has no file system, so any implementation of open(), close(), read(), write(), etc. would need heavy rework, never mind stdio; -- no processes, so no fork(), exec(), etc.; -- signal(), setjmp(), and many other commonly used system calls would need work to behave reasonably -- some might be impossible to make work; -- 99% of the 48's maths functionality has no parallel in C; -- fundamental types would be non-standard by most common C implementations -- the 48 CPU has 64-bit registers and 20-bit nibble-based memory addressing, for example, which pushes the usual portability limits; -- the 48 operating system is written in a language (RPL) which is like a sort-of polymorphic, sort-of object-oriented, stack-based blend of Forth, LISP and other stuff, and has few things in common with C, certainly at the User level (no pointers, no memory allocation, no reasonable analogues to goto, break or continue). The last of these is probably the biggest obstacle to a reasonable implementation of C. You can either beat the hell out of C to make it fit the 48, or ignore the OS and take over the hardware. The former would involve so many compromises and changes to C that whatever came out the other end would be seriously unlike any other C you ever saw. The latter would be nigh on impossible without the internals documentation, and I would doubt you could get your hands on that. It would also defeat much of the obvious object of writing C on the 48, which is to access its maths capabilities while writing in a popular language. It would be a genuinely interesting and educational exercise to attempt to write something which could take C code (ignoring the standard libraries and providing compatible alternatives which accessed the 48's resources) and output something which implemented that program on the 48, either by producing RPL code or assembler code. However, if your final goal is to bring existing C code to the 48, or to turn the machine into a C one instead of an RPL one, I feel that you would ultimately be frustrated by the obstacles which the design of the HP-48 presents. -- Frank Wales, Guest of HP Corvallis, [frank@zen.co.uk||frankw@hpcvdq.cv.hp.com] Zengrange Ltd., Greenfield Road., LEEDS, England, LS9 8DB. (+1)-503-750-3086