Jump to content
IGNORED

Need some C Help.


dhe

Recommended Posts

 
Need some c help, I'm more of a using c to replace basic, versus using c to replace assembly kind of guy.
 
The original line of code is:
   void ShowMaze(const char *maze, int width, int height)
     Which compiles perfectly with gcc - on linux for linux.
 
I'm trying to use TIC 1.67 on the geneve. It seems TIC doesn't groove on defs in the function name line. So I pulled it out old school and put it before the {}
 
I re-wrote things to look like:

  

image.png.eba8e850cc6d9a570e77f04320ec74d4.png

 

 

 

That results in:

image.png.2f666dba94431dac48ea4287cdd13ce5.png
 
 
 
Removing * in front of maze gets:
image.png.86e047b6e62d24143cb1d4fb1e296f23.png
 
 
c99's favorite error seems to be lval, tic seems to like punctuation.
 
I did find:

char* is a mutable pointer to a mutable character/string.

 

const char* is a mutable pointer to an immutable character/string. You cannot change the contents of the location(s) this pointer points to. Also, compilers are required to give error messages when you try to do so. For the same reason, conversion from const char * to char* is deprecated.

 

char* const is an immutable pointer (it cannot point to any other location) but the contents of location at which it points are mutable.

 

const char* const is an immutable pointer to an immutable character/string.

 
Yea.. That makes my head want to explode....
 
So can anyone tell me what construct would stand in for the program goal above, but still work with an old tired K&R C like compiler?

 

 
 
 
 
 
Link to comment
Share on other sites

46 minutes ago, FarmerPotato said:

Have you tried without const? Maybe TIC doesn’t have const?

I seem to recall that const came along in ANSI 1.0 or even later.

I think I first saw const in C++ in 1990

Without const, you just have to respect the char * and not write to it. 

 

The second edition of K&R (1988) says const and volatile were parts of the ANSI C Standard, which was completed in late 1988, but already implemented in most C compilers of the day.

 

...lee

  • Like 1
Link to comment
Share on other sites

The chicken dinner goes to FPo!

 

>Have you tried without const? Maybe TIC doesn’t have const?

That did the trick.
 
> Without const, you just have to respect the char * and not write to it. 
And also, the practical answer!
 
Fred got me thinking, so I went back through the documentation and found it:
image.png.892869ca522e30903eae82cfdff03bf2.png
 
Clint Pulley's C compiler was based on small c.
 
Al's compiler (which Clint Helped with) was based on:
"TIC was derived from a 68000 based C compiler developed by Matthew
   Brandt. "
 
Source supposedly compile-able with gcc can be found:
 
From the readme in tic.zip:
 

This is the source code for Al Beard's "Big C" compiler. Al wrote:

"I have attached the last build I did for the TIC C compiler, it was about 20 years ago.  Unfortunately I lost the source code for the companion TASM assembler.  Much of the work for the TIC C compiler was based on the public domain 68000 C compiler that was in circulation at the time (even though it was a bit buggy).    Paul Charlton at the time sent me some code he was working on from the same source baseline that was helpful, as well as Clint Pulley's testing it for me."

 

To compile, do
   gcc -o tic -m32 *.c
in the source directory.

 

See the file 'manual.txt' for usage instructions.

 

The code compiles without warnings on a basic gcc compilation, but adding -Wall, or compiling with clang shows many warnings. Most seem to be innocent (simply reflecting that C got more and more strict about types over the last 30 years), some may indicate old bugs. Compiling as a 32 bit binary seems the safe choice, as the code appears to assume int's and pointers being the same size, which isn't true on x64 systems.

 

The compiler outputs assembler source, intended for the TASM assembler. The Dave Pitts assembler and linker seem to work fine.
http://www.cozx.com/~dpitts/ti990.html

 

The runtime support file must be linked as the first object file and is written for use on Stuart's breadboard 9995 system.
http://www.avjd51.dsl.pipex.com/tms9995_breadboard/tms9995_breadboard.htm

 

For use on other systems this crt0.S can be used as a guide. The key things to change are the WP and stack location in the start routine, and the 'OUTC' and 'GETC' routines to out/input a single character to/from the console. When deciding on the initial value of the stack pointer, please remember that the stack grows 'up' in memory, which is unusual for a C implementation.

If you use this code, don't forget to post a big thank you to Al in a vintage computing forum of your own choice.

"

 
 
 
 
  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

I did pull over TIC source from WHTECH / programming / tic / tic.zip

 

I was able to compile and run with gcc 9.4 - it's what I have on my linux box.

 

image.png.e14a756abe259c1a8c7a80c2d31ac45d.png

 

Even without -Wall or -Wextra - gcc let me know about some concerns it had! ?

  • Like 2
Link to comment
Share on other sites

16 hours ago, dhe said:

I did pull over TIC source from WHTECH / programming / tic / tic.zip

 

I was able to compile and run with gcc 9.4 - it's what I have on my linux box.

 

image.png.e14a756abe259c1a8c7a80c2d31ac45d.png

 

Even without -Wall or -Wextra - gcc let me know about some concerns it had! ?

So for us ill-informed-about-C people:

You can compile TIC programs on Linux now?

Does that output an 9900 Assembly program that you then assemble and link with other TI-99 tools?

 

Link to comment
Share on other sites

7 hours ago, TheBF said:

You can compile TIC programs on Linux now?

Compiling programs under linux is problematic, because of lack of libraries.

 

I did move the files to the Geneve, with appropriate renaming and tried to compile with TIC.

 

TIC ran out of memory. Guess it's either the C compiler we have, or we wait for someone more knowledgeable then myself to adapt GCC with libraries for the Geneve. =(

  • Thanks 1
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...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...