Archives
 
 
 
  Special
 
 
 
  About Us
 
 
 

Newsletter
Free E-mail Newsletter from BYTE.com

 
    
           
Visit the home page Browse the four-year online archive Download platform-neutral CPU/FPU benchmarks Find information for advertisers, authors, vendors, subscribers Request free information on products written about or advertised in BYTE Submit a press release, or scan recent announcements Talk with BYTE's staff and readers about products and technologies

ArticlesANSI C Anywhere


June 1995 / News & Views / ANSI C Anywhere
Rick Grehan

Some time ago, a fellow BYTE editor loaned me his notes and documents from a conference on how to retarget GCC, the GNU C++ compiler. After spending days poring over the materials, I emerged none the wiser, and simply more jealous of anyone who'd succeeded in building his or her own GCC compiler. Apparently, I didn't have the mental stamina required to accomplish this task.

Then I found out about the Retargetable Software Tools from Archelon (Waterloo, Ontario, Canada, (800) 387-5670). I'll say right up front that Archelon's tools build C compilers, not C++ compilers. Furthermore, the software is not cheap: The starting price is $3495. But you get a set of tools to construct a C compiler, an assembler, a linker, and a librarian for whatever target processor you wish (provided, of course, that the processor is powerful enough). The re's also a preprocessor for the compiler's front end and a peephole optimizer for its back end.

Furthermore, the C compiler is ANSI compatible. Archelon's president, R. Preston Gurd, informed me that the company has verified the output with the Plum-Hall suite.

I spent most of my time with the kit working with the C compiler portion. That meant wading through the CIF (compiler information file). The CIF tells the compiler everything it needs to know about the architecture of the target machine, including available registers, which ones can be used for indexing, which one can be used for the stack pointer, whether there's a frame-pointer register, the format of assembly instructions, and addressing modes.

Using these tools, you end up working in two directions at once. On one end is the target processor's architecture. On the other end are the rudimentary operators that the compiler understands. Your job is to connect the two.

For example, one of the compiler's fundamental operators is SUB; it s format is "$dest = $left - $right," which means that the SUB operator subtracts the right operand from the left operand and puts the result in a destination operand. Your job is to teach the compiler the assembly instructions it must emit to perform a SUB operation. Of course, a SUB operation can have characters, integers, long integers, or floating-point values as operands; you have to take all cases into account.

I won't kid you; this stuff is not for the squeamish. I recommend that you work through the demonstration files, trying a little reverse-engineering until you get the feel of how the commands in the CIF work. Then bring up your compiler piecemeal--don't try to do the whole thing at once. You can have it output dummy instructions for the operators you're not sure of in the beginning and then complete it all later.

My biggest complaint is that the documentation could stand more work. I appreciated all the Backus-Naur diagrams--they helped me figure out the proper syntax for a command--but m ore examples, such as a tutorial for an 8088 C compiler, would make the process smoother.

Still, if you find yourself working with a variety of processors or custom microcontrollers and you'd like to start building a library of ANSI C compilers for yourself, Archelon's Retargetable Software Tools deserves a look. I worked with the DOS version; versions also exist for Unix System V release 4.2, HP-UX, SunOS, and Solaris 2.x.


Up to the News & Views section contentsGo to previous article: An Early Survey of Windows 95 PlansGo to next article: Windows 95 Sees Better FutureSearchSend a comment on this articleSubscribe to BYTE or BYTE on CD-ROM  
Flexible C++
Matthew Wilson
My approach to software engineering is far more pragmatic than it is theoretical--and no language better exemplifies this than C++.

more...

BYTE Digest

BYTE Digest editors every month analyze and evaluate the best articles from Information Week, EE Times, Dr. Dobb's Journal, Network Computing, Sys Admin, and dozens of other CMP publications—bringing you critical news and information about wireless communication, computer security, software development, embedded systems, and more!

Find out more

BYTE.com Store

BYTE CD-ROM
NOW, on one CD-ROM, you can instantly access more than 8 years of BYTE.
 
The Best of BYTE Volume 1: Programming Languages
The Best of BYTE
Volume 1: Programming Languages
In this issue of Best of BYTE, we bring together some of the leading programming language designers and implementors...

Copyright © 2005 CMP Media LLC, Privacy Policy, Your California Privacy rights, Terms of Service
Site comments: webmaster@byte.com
SDMG Web Sites: BYTE.com, C/C++ Users Journal, Dr. Dobb's Journal, MSDN Magazine, New Architect, SD Expo, SD Magazine, Sys Admin, The Perl Journal, UnixReview.com, Windows Developer Network