Subject: C compiler?

From: Owen Brand <[email-masked]>
Date: Wed, 27 Jan 2010 09:38:05 -0500

What would actually be involved in putting together a C compiler for  
our system?  We have talked previously about just such an endeavor,  
something to take programs written in C and convert it to TMS9900  
assembly language.... Tursi has been an advocate of a group project  
dealing with this subject, and after looking at many vintage computer  
software catalogues, I am really beginning to see his point.... So I  
talked to a friend of mine who has a career in utility design in 2 or  
3 different languages (for PC) and he seems to think that just such an  
application is certainly achievable.  He doesn't really understand the  
"why" of it, but he says it can be done.... As a matter of fact, he  
suggested a website to check out, I have it written down in my car,  
I'll go check it out and post it in a bit.
    Anyway, my point is---if it can be done, if this technology is  
available and could potentially be very useful.... What would it  
take?  Should we outsource the project and pay someone to do it.... Or  
is it possible with all the wizards on here that we could do it  
ourselves?  Just curious

Owen Brand
**Oprysoft**
Opry99er.com

---

From: "Michael Zapf" <[email-masked]>
Date: Wed, 27 Jan 2010 16:43:14 -0000

--- In [email-masked], Owen Brand <owenbrand@...> wrote:
> our system?  

You mean, getting to something like a real ANSI-C compiler, not just what we get from c99 or TIC? Would be nice, sure. 

What I would find interesting: A compiler which also creates a virtual memory management, especially for systems with banked memory like the Geneve. That is, you could write something like

char* ptr = malloc(100000);
for (int i=0; i < 100000; i++) ptr[i]=0;

and the machine code produced by the compiler does all the necessary stuff to switch banks if necessary. The programmer does not get in contact with the specifics of this memory management. If this were feasible somehow, we could compile many, many programs written for other architectures.

(I guess among all the "difficults" there is also an "impossible", but let's just dream...)

Michael

---

From: Owen Brand <[email-masked]>
Date: Wed, 27 Jan 2010 11:53:59 -0500

Nothing is impossible when there is enough motivated people working on  
it.    :). If anyone is interested, there is a link on the page I  
posted a link to to contact the developer directly.  He developed this  
cross-development software in Linux.... I bet some of you Linux  
masters could decipher his code and learn from it... I wrote him, but  
I'm not sure if it went through.... Some robot wrote me back and asked  
me to confirm my something or other by typing in a very specific  
command.... Almost like the old compuserve lists.... Remember those?

Owen Brand
**Oprysoft**
Opry99er.com

On Jan 27, 2010, at 11:43 AM, "Michael Zapf" <[email-masked]>  
wrote:

> You mean, getting to something like a real ANSI-C compiler, not just  
> what we get from c99 or TIC? Would be nice, sure.
>
> What I would find interesting: A compiler which also creates a  
> virtual memory management, especially for systems with banked memory  
> like the Geneve. That is, you could write something like
>
> and the machine code produced by the compiler does all the necessary  
> stuff to switch banks if necessary. The programmer does not get in  
> contact with the specifics of this memory management. If this were  
> feasible somehow, we could compile many, many programs written for  
> other architectures.
>

---

From: Gregory McGill <[email-masked]>
Date: Wed, 27 Jan 2010 08:55:24 -0800

- Someone who's done it before, that is either into or newly into the 4/a.
or
- One of our resident 9900 addicts, desiring to try and take the time.

There's many many examples out there of the art.  Me personally, I barely
know enough 9900 assy to write hello world.. Happy to test tho!

Greg

---

From: "Tursi" <[email-masked]>
Date: Wed, 27 Jan 2010 09:00:11 -0800

> dealing with this subject

Not precisely. I have started the work and invited anyone interested to 
help. A few stepped up and tried but so far didn't have any luck. My WIP 
code for GCC is here: http://www.harmlesslion.com/cgi-bin/onesoft.cgi?109
and my forum thread: 
http://www.harmlesslion.com/hl4m/viewtopic.php?f=1&t=324

The port so far compiles my first test program but has many problems and 
would not compile my second test. At the time I had an idea why and needed 
to back up a bit and redo some parts. After this much time I'd probably need 
to relearn it.

I'll get back to it eventually.. eventually I need to port my Coleco work 
back so I'll need a C compiler. ;)

---

From: Owen Brand <[email-masked]>
Date: Wed, 27 Jan 2010 12:07:41 -0500

Well-- I know a little Objective C, but that won't be any good for us,  
I don't imagine....  What language are you using, Tursi?

Owen Brand
**Oprysoft**
Opry99er.com

---

From: tursi <[email-masked]>
Date: Wed, 27 Jan 2010 09:48:00 -0800 (PST)

> Well-- I know a little Objective C, but that won't be any good for us, I 
> don't imagine....  What language are you using, Tursi?

GCC (and most C compilers) is written in C.

Most retargetable compilers are actually very complex. After having looked 
at roughly a dozen of them and spent time here and there for years, I'm 
increasingly of the belief that starting from scratch is easier. ;)

---

From: ti99_forever <[email-masked]>
Date: Wed, 27 Jan 2010 10:01:55 -0800 (PST)

I looked at lcc about 5 times before scratching my head and walking away...

--- On Wed, 1/27/10, tursi <[email-masked]> wrote:

> From: tursi <[email-masked]>
> Subject: Re: [TI994A] C compiler?
> To: "[email-masked]" <[email-masked]>
> Date: Wednesday, January 27, 2010, 12:48 PM
> ------------------------------------
> 
> Yahoo! Groups Links
> 
> 
>     [email-masked]
> 
> 
>

---

From: "killroy732000" <[email-masked]>
Date: Wed, 27 Jan 2010 20:36:19 -0000

How about SDCC (small Device C Compiler) as a starting point ?
Would that not be better suited than a full blown gcc cross-crompiler
considering the memory constraints of the TI-99/4A =

This compiler already produces object code for different targets,
among them Z80 (guess Tursi already worked with SDCC when programming
colecovision).

Here are some linkss
homepage: http://sdcc.sourceforge.net/
manual: http://sdcc.sourceforge.net/doc/sdccman.html/

I'm not a C programmer, but I did take a look at the compiler dokumentation/sources. 
If I understand correctly the frontend generates machine 
independent intermediate code that is optimized before it gets
converted to Z80 assembly by the backend.

So the big task to do would be to write a backend that takes the 
intermediate code and converts it to 9900 code.

Here is a good reference for implementing a new target (and a lot of it also goes when starting from scratch I would say)
http://sourceforge.net/mailarchive/message.php?msg_id=1132766600.14511.42.camel%40localhost.localdomain

Still a huge task if you ask me. 

On the other hand, why not checkout how suitable Dave Pitts' TI-990   GCC compiler is. Or continue Tursi's version of gcc.

Cheers
Filip

--- In [email-masked], tursi <yahoogroup@...> wrote:
> > don't imagine.... Â What language are you using, Tursi?
>

---

From: Gregory McGill <[email-masked]>
Date: Wed, 27 Jan 2010 16:44:07 -0800

Dont we already have small c?  TiC is missing functions that are required to
compile tcp stack.. etc..

G

On Wed, Jan 27, 2010 at 12:36 PM, killroy732000 <[email-masked]>wrote:

> Here is a good reference for implementing a new target (and a lot of it
> also goes when starting from scratch I would say)
>
> On the other hand, why not checkout how suitable Dave Pitts' TI-990 GCC
> compiler is. Or continue Tursi's version of gcc.
>
> Cheers
> Filip
>
>
> --- In [email-masked] <TI994A%40yahoogroups.com>, tursi
> <yahoogroup@...> wrote:
> >
> I

---

From: tursi <[email-masked]>
Date: Wed, 27 Jan 2010 17:15:31 -0800 (PST)

> Dont we already have small c?  TiC is missing functions that are 
> required to compile tcp stack.. etc..

SDCC is a full ANSI C compiler, targetted for small devices. (Rather than 
being Small C ;) ). It's mostly in the ways that it handles memory that it 
differs from larger compilers like GCC.

The code it produces, at least for Z80, doesn't look very good, but this 
is a curse shared by most retargettable compilers.

---

From: mark wills <[email-masked]>
Date: Wed, 27 Jan 2010 20:36:26 -0800 (PST)

There's possibly two ways:

1) Take C99 by clint pulley and extend/modify to produce 'standard' C
2) Take something like GCC and build a TMS9900 extension

Option 1 would be of limited appeal, certainly to me, because compiling C on the TI is a pain... Edit/Save/Compile/Repeat until no compile errors/then assemble/load/run

It's like pulling teeth.

Option 2 (cross compiler) is best option. Tursi started work on this already, but, you know, real life and all...

*BUT* Would we gain *THAT* much from having a C compiler? Personally, I can write in assembly (on the TI) quicker than I could in C! Aside from porting other applications to the TI, would it be of much benefit?

It would be tricky for a C compiler to produce efficient on the 9900, as it doesn't have a stack...

Mark

>
>From: Owen Brand <[email-masked]>
>To: [email-masked]
>Sent: Wed, 27 January, 2010 15:38:05
>Subject: [TI994A] C compiler?
>
> >
>
>
>
>
>  >
>>      
>

---

From: mark wills <[email-masked]>
Date: Wed, 27 Jan 2010 20:55:41 -0800 (PST)

Meh... There's always Forth ;-)

It produces very efficient code, because every instruction is just a call to an address ;-)

I'm interested in C compilers, but I wouldn't have the FIRST CLUE about how to write one...

It looks very difficult to me...

>Sent: Thu, 28 January, 2010 2:15:31
>Subject: Re: [TI994A] Re: C compiler?
>
> >
>
>
>
>
>  >
>>      
>