• Please review our updated Terms and Rules here

Building gcc1.27 for Uniflex on Tektronix 4404

Elektraglide

Experienced Member
Joined
Mar 24, 2023
Messages
53
Location
UK
Well that was fairly brutal. but I have managed to get gcc1.27 built and running on the Tektronix 4404. The native C compiler is kinda terrible, so building gcc - even though back then gcc is fastitiously K&R syntax for bootstrapping, was a lesson in misery.

Even if it got through the native cpp (which often died because of the long statements), lots of:

517: && !reg_mentioned_p (((((p)->fld[3].rtx))->fld[0].rtx),
** FATAL ERROR: Expression too complex - internal table overflow.

** FATAL ERROR: Internal table overflow - "switch" item count.

etc. So I tried premasticating all the source files on my Mac. ie resolve all the includes into single large files and then just compile on the Tek4404. No dice, still explodes. I had a go at strength reducing large expressions etc but if you've ever looked at the C that gets generated from a machine description, its not made for human eyes, so was very error prone.

Finally bit the bullet and used m68k gcc cross compiler on the Mac to generate .o files and then wrote a utility to convert the ELF32 .o files into Uniflex relocatable files (.r files). Given there isn't any docs on the Uniflex file format, just getting something simple like this working perfectly took quite a while. Its here if you're interested:

tek4404 github repo

After much head scratching when printfs turn into infinite loops, turns out Uniflex clobbers a2 and d2 on function calls. So added:
-fcall-used-d2 -fcall-used-a2

Rebuilt everything but turns out the native assembler which I am relying on has various odd quirk. eg it knows of quick variants of instructions (movq etc) but you cannot use them in your code, you have to let Mr. Assembler decide to do that..whatev!

So lots of editing a tm-4404.h to get assembler output that was acceptable.

And finally! Got a hello world program running through cpp, into cc1, and into asm and into the link-loader. Woot!!
I've made a fork of gcc1.27 for anyone interested in the madness: gcc1.27 fork for Tek4404

Screenshot of the gcc running on Tektronix 4404..

fullcompile.png
 
Back
Top