Jump to content
IGNORED

GCC for the TI


insomnia

Recommended Posts

Should GCC for TI be called GCC for TMS9900? or does it have specific dependencies on the TI99 computer roms and hardware?

What is to produce a functional binary for the TI99 that can be loaded into an emulator or real hardware?

I guess one needs a .crt file and maybe some specific compiler options and "packaging" tools.
Where can I get the .crt file(s) and compiler options and tools to produce a rom/tape/disk images?

Link to comment
Share on other sites

gcc is known to create code that can run on the Tomy Tutor (TMS9995) and I've used it to create a Hello World on the Myarc Geneve 9640 MDOS ( also TMS9995 )

 

There is no crt.o exactly... As the operating system on the 4A doesn't really have a TTY/keyboard abstraction that anyone uses... (<--- gross generalization for purposes of this context) If targeting a cartridge image you need an entry point function that sets the workspace pointer, then the gcc stack pointer (R10, or aliased as 'sp'), copies data from your linked image into the global variables (BSS) and then branches into your actual function/code... doesn't have to be called main.

 

This library here, https://github.com/tursilion/libti99, is a good place to start. There is a TESTLIB program built by the Makefile, and some crt_ea5.asm ( or .c ) can't remember. It uses another tool called ea5split that you can find in this thread, that will convert an .elf file into a sequence of Editor Assembler Option 5 loadable program image files. It is important when linking your modules into the .elf binary that the crt entry point function is first, or at least an assembly command that 'BR' branches to it, as ea5split assumes the beginning of your code is the program start address.

 

There are other beginning to end examples that vary in complexity:

 

There were a couple example .zips in post #1... I think a simple 8k rom cartridge example, and an ea5 example.

 

https://github.com/jedimatt42/tipi/tree/master/clients/tipicfg - uses libti99's conio routines, produces a simple ea5 program using ea5split, with a simple linker file

 

https://github.com/jedimatt42/fcmd - a very complex example that produces a cartridge image, and does bank switching. It uses objcopy and unix commands like 'dd' and 'cat' to craft the ROM image.

 

https://github.com/peberlein/turmoil - Here is a nice game example from PeteE on this forum. This build process can produce a cartridge image or ea5 from the same code...

 

You'll see these all have their own crt source file.

 

I've noticed that under some circumstances the compiler will generate calls to memcpy (such as 'char mutable_filename[16] = "DSK1.DEFAULT" , there is a memcpy in libti99, but I also think there are some utility functions like that in the includes with the compiler... I've never used the includes with the compiler...

 

-M@

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

I am trying to use gcc for ti to compile my game Cross Chase.
Cross Chase can be compiled with standard GCC and other GCC derivatives but it fails with GCC for TI with a linker error:
ld: cannot find -lgcc

 

Cross Chase source code is spread over many files at different locations with lots of nested includes.

I have not been able to use any of the template examples (hello or hello2 examples here) for my game.

With all other GCC variants I simply use gcc with all the .c files and gcc takes care of linking the object files.

GCC for TI fails but if I pass the "-c", it does create the .o fails.

I am hoping to be able to link the produced .o files.

Is the error about "-lgcc" expected?


Link to comment
Share on other sites

-lgcc requires you to have a library named libgcc.* that is on your library path at link time.

 

I have never succeeded in building libgcc.

 

If you remove the -lgcc from your build statement the linker should complain about missing symbols. If it doesn't, then you didn't need libgcc anyway. If it does report missing symbols, you just need to write a library that implements what is missing.

 

-M@

  • Like 2
Link to comment
Share on other sites

Someone needs to make libgcc build for the TI before that can happen - I've not been able to do it either.

 

You don't explicitly call the linker (tms9900-ld) anywhere? You can try adding "-nostdlib" to your build line to make it not pull in the standard libraries.

 

The odds are you'll then get a bunch of unresolved references, which unless you succeeded at building any of the GCC libs, you'll have to provide. :)

Link to comment
Share on other sites

I am now close to getting Cross Chase compiled with GCC for TI:
"
ti99_tiny_no_graphics:
$(TI99_CC) $(TI99_OPTS) \
-I$(SOURCE_PATH) \
-D__GCC_BUFFERED__ \
...
$(TINY_FILES) \
$(CROSS_LIB_PATH)/rand/rand.c \
$(TOOLS_PATH)/ti99/cart_header.o \
$(TOOLS_PATH)/ti99/crt0.o
"
produces the following errors:
"
../tools/ti99/crt0.o: In function `_start2':
(.text+0x18): undefined reference to `__DATA_START'
../tools/ti99/crt0.o: In function `_start2':
(.text+0x1c): undefined reference to `__DATA_END'
../tools/ti99/crt0.o: In function `_start2':
(.text+0x22): undefined reference to `__VAL_START'
../tools/ti99/crt0.o: In function `L5':
(.text+0x28): undefined reference to `__DATA_END'
../tools/ti99/crt0.o: In function `L4':
(.text+0x2e): undefined reference to `__BSS_START'
../tools/ti99/crt0.o: In function `L4':
(.text+0x32): undefined reference to `__BSS_END'
../tools/ti99/crt0.o: In function `L10':
(.text+0x3c): undefined reference to `__BSS_END'
collect2: ld returned 1 exit status
make: *** [Makefile:4976: ti99_tiny_no_graphics] Error 1
"

Link to comment
Share on other sites

Looks like your crt0 is trying to do set up the C runtime, but can't find the labels. Where did you get this crt0? In mine, which is admittedly quite old, the only startup label is _init_data (which has a table after it).

 

If the toolchain has changed someone who's up to date may need to step in :)

Link to comment
Share on other sites

Does changing the definition of your segment pointers from "int" to "unsigned int" not help? I'm not sure if the signedness of these symbols would make it so that aren't found, but the values will overflow the range of an int, giving that we have a 16 bit address space. So try extern "unsigned int __VAL_START;" instead of "extern int __VAL_START;", etc...

 

Other than that, I see nothing wrong with your code. You are in fact explicitly invoking the linker though, that's what your ti99_cross_chase.elf target does in your Makefile.

Link to comment
Share on other sites

@themole, I will try to use a cleaner Makefile target...
The current ti99_tiny_no_graphics target if used with the -c option, will produce the .o files.
I guess I just need to invoke the linker on those files + use the linkfile, crt and cart files.

I can try to invoke the compiler on each file but it fails because it does not find some files. I probably need to include some header files with some include option.

Link to comment
Share on other sites

(scratch) Sorry, I'm a step behind.

 

At this point everyone is guessing. Can you just post your makefile (at minimum, but a full project, even just a hello world, would let others help to solve the full issue)?

Edited by Tursi
Link to comment
Share on other sites

@tursi, I have already posted my Makefile here, which is a trivial one with just all the source files in one single target line and the -nostdlib flag.

It builds all the .o files as expected. It fails with the linking. I most probably need to run the linker command separately with the good linkfile.
I was hoping I could do it with a single command line as I do with standard gcc.

Link to comment
Share on other sites

You should move your .c and .h files into the build system (Makefile, link file, crt*) of one of the examples in post #1.

 

Just my opinion. You'd be done already.

 

We can't answer your question because we don't practice the usage pattern you are advocating. Even the linker when run separate cannot produce a 4A binary. Additional steps will be required.

 

There are a million arguments to the gcc tool, some of them control defaults that it otherwise passes on to the ld tool. Since I always use the ld tool directly, as do all the examples I have seen, I think you are a pioneer in this space and will have to concede or educate us on your alternative approach.

 

-M@

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Took me a while to find out where to look. Not the obvious place to find the TI99 GCC forum!

 

I've been giving it a spin with the Fuzix code and have a small set of fail cases (compiler crashes, aborts, internal errors, other flaws) when I try and build the Fuzix C library. If you can let me know how you'd like them. I've also fixed a small error in tms9900_output_ascii. If you have a string ending in '\' then the compiler doesn't quote the '\' and confuses the assembler completely. I chnged it to quote \ or nonprintables.

 

There's also another fairly fundamental problem I'm not sure how to tackle other than by telling the compiler to tack _ on all the variable names - if you do this

 

static int sp;

 

and then try and use it - boy does it get upset 8). It works for other non '_' using targets because they use an asm syntax that explicitly marks registers.

 

Alan

 

  • Like 3
Link to comment
Share on other sites

18 hours ago, EtchedPixels said:

Took me a while to find out where to look. Not the obvious place to find the TI99 GCC forum!

 

I've been giving it a spin with the Fuzix code and have a small set of fail cases (compiler crashes, aborts, internal errors, other flaws) when I try and build the Fuzix C library. If you can let me know how you'd like them. I've also fixed a small error in tms9900_output_ascii. If you have a string ending in '\' then the compiler doesn't quote the '\' and confuses the assembler completely. I chnged it to quote \ or nonprintables.

 

There's also another fairly fundamental problem I'm not sure how to tackle other than by telling the compiler to tack _ on all the variable names - if you do this

 

static int sp;

 

and then try and use it - boy does it get upset 8). It works for other non '_' using targets because they use an asm syntax that explicitly marks registers.

 

Alan

 

Oh, cool! I'd really love to see Fuzix on the TI!

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...

Hi all,

 

i was not able to install on osx. 

The installer can’t download the files, what is strange because they exist.

 

I downloaded myself and disable it in the installer script.

 

Then the installer make huge stuff, also make the destination path and put a lot inside.

 

But the tms9900-gcc is missing for example.

 

The installer stop with an error, see the picture.

 

Any idee? or could someone post a ready to use osx build?

 

The docker version is running, but this i don’t like, i want it native.

 

Thanks

D44BB875-1715-4F5A-B38B-EF72BC3AEBCD.jpeg

Link to comment
Share on other sites

Hello, Michael,

 

I'd love to help you. However, I don't feel like reading through the previous 20 pages of messages. Only waste of time. So I can only guess.  Which would certainly not help you.
I suspect that a header file could be included twice. But I am not there in the detail. I would have to follow all the steps you have taken.

 

From my point of view it is no miracle for the failures with your attempt to set up the tool chain, and/or to produce the source code. I wouldn't even be motivated to start working through the gibberish, although it's an interesting project.

 

As constructive criticism to insomnia I can contribute the following:
On the first page all versions of the patches are available for download, that's quite good. But unfortunately I can't see what an interested user should do. (Without reading more than 20 pages of comments.) What, an installer? What is that supposed to do? Is it a kind of build script? It's certainly independent of the platform, isn't it? Do these patches build on each other? So should you apply each patch one by one, or is it enough to just use the last one? What is the base of the patches? What are the requirements to build your own gcc? (Regarding the tool chain with version numbers.)

It seems to me like in the 90's when you sent patches by mail. Terrible! If this procedure had proved itself, patches would still be exchanged today. But the world continues to turn and the opportunities are evolving. Nowadays one should use more modern technologies, which GIT really makes available to everyone. Just create a fork from the master of the gcc repository and maintain a branch with your TMS9900 extensions. (Or include the gcc sources as a git module for your extensions in the repository, like I do with XDT99 on my XDT-Wrapper project.) Occasionally rebase your branch onto the latest master of the gcc. Furthermore, you should provide some build scripts, like for commonly used make or cmake, etc.
This increases the acceptance by a multiple: Clone, build - done! It can be sooo simple...
Everything else is crap!

 

No harm meant!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...