Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: Blagus on November 19, 2011, 01:52:07 pm

Title: Small-C - confused
Post by: Blagus on November 19, 2011, 01:52:07 pm
Can someone help me with Small-C compiler for TI-83 Plus?
I downloaded 8xccb5 compiler and I don't understand a thing there, and there are no tutorials about Small-C on TI-83.
Since I'm already learning C on PC (in school), I'd like to do the same, at least for small fun, on my calc, before moving on to ASM.
So can anyone help me with making at least "Hello World" program? When I try to compile code, it gives me hello.bin, hello.lst and hello.opt
Hello.opt contains ASM code, which is then compiled in hello.bin, so I'm guessing it should be ready, but what to do with that hello.bin? I can't send it to calc.

Thanks
Title: Re: Small-C - confused
Post by: Scipi on November 19, 2011, 02:02:55 pm
Wait, woah, woah. You're saying there's C for the calc? Can you supply a link, I definitely want to check this out. XD

It might be the formatting for a file that's readable by the calc.
Title: Re: Small-C - confused
Post by: Blagus on November 19, 2011, 02:15:12 pm
Right here: http://www.ticalc.org/archives/files/fileinfo/91/9187.html

Update on progress: I found utility that converts bin to 8xp, but when I execute Asm(prgmHELLO it gives me ERR:INVALID
so I guess I made some mistake in code, but I don't know what.
That's why I'm asking for help here.
Title: Re: Small-C - confused
Post by: Scipi on November 19, 2011, 02:16:05 pm
Can you post your code? If it's the same syntax as C then I could probably help. :D
Title: Re: Small-C - confused
Post by: Blagus on November 19, 2011, 02:28:10 pm
Sure, here it is:
Keep in mind that include files were a wild guess since there's no std*.h files.
hello.z80:
Code: [Select]
#include "ti.h"
#include "ti83.h"
main()
{
printf("Hello World!nl");
printf("HELLO WORLD!");
printf("1234567890");
}
int main() was causing compile error.
Title: Re: Small-C - confused
Post by: ralphdspam on November 19, 2011, 02:29:55 pm
Right here: http://www.ticalc.org/archives/files/fileinfo/91/9187.html

Update on progress: I found utility that converts bin to 8xp, but when I execute Asm(prgmHELLO it gives me ERR:INVALID
so I guess I made some mistake in code, but I don't know what.
That's why I'm asking for help here.

It looks like it only works for the TI-83 (not plus).  Sadly, those two are not compatible.
Title: Re: Small-C - confused
Post by: Scipi on November 19, 2011, 02:32:06 pm
Instead of printf(str), use puts(str)

From the readme:

Quote
Function:     puts(str)
Parameters:   char *str - string to display to screen.
Returns:      Nothing
Include File: TI.H
Description:  Displays the string 'str' at current cursor location and moves
              cursor to the end of the string
Title: Re: Small-C - confused
Post by: Blagus on November 19, 2011, 02:47:43 pm
@ralph: I'm afraid you're right. I've minimized the code and still error.
Then I found the actual TI-83 Plus compiler, but it's made primarily for MacOS with badly compiled Windows executables.
I took ti83p.h from there and put it in 8x... compiler and still ERR:INVALID.

Still, it would be really nice if it could be modified somehow for TI-83 Plus.
Title: Re: Small-C - confused
Post by: Scipi on November 19, 2011, 02:57:22 pm
I wonder if there's a converter to change 83 ASM to 83+ ASM.

Also, did you change printf to puts?
Title: Re: Small-C - confused
Post by: Blagus on November 19, 2011, 03:02:06 pm
Yes, I changed to puts and with minimizing code, I came to stage with no errors and successful assembly, and only error being fail to convert bin to "83p" since there's no app for that in the folder. So I do it manually (convert to 8xp).

And here's the TI-83+ C compiler, but for Mac: http://www.ticalc.org/archives/files/fileinfo/381/38118.html

Edit: I found Windows version! But I'm having some annoying problems with setting up path as readme says to do.
Title: Re: Small-C - confused
Post by: Scipi on November 19, 2011, 03:35:21 pm
Can you supply a link to that one? I have a post around here that explains the path.

I'll try to find it.
Title: Re: Small-C - confused
Post by: FinaleTI on November 19, 2011, 03:43:53 pm
I think it's here. The readme says stuff about the PATH and the author is the same.
http://www.ticalc.org/archives/files/fileinfo/380/38061.html (http://www.ticalc.org/archives/files/fileinfo/380/38061.html)
Title: Re: Small-C - confused
Post by: Blagus on November 19, 2011, 03:46:23 pm
Yes, I did it finally, and I get to this stage:
Code: [Select]
c:\tisdcc>tisdcc ti83p_asm hello.c
tisdcc
tisdcc: sdcc -mz80 --no-std-crt0 --code-loc 0x9DA3 --data-loc 0x9872 -L c:\tisdcc\lib -I c:\tisdcc\include -DTI83P -Wlc:\tisdcc\startup\ti83p_asm.o ti83p.lib hello.c
?ASlink-Error-<cannot open> : "c:\tisdcc\startup\ti83p_asm.rel"
Error in sdcc

hello.c:
Code: [Select]
#include "ti83p.h"
main()
{
PutS("Hello World!");
return 0;
}
Title: Re: Small-C - confused
Post by: Scipi on November 19, 2011, 03:49:11 pm
I think you need. TI.H If included. Or it might be a different instruction perhaps?
Title: Re: Small-C - confused
Post by: Blagus on November 19, 2011, 04:09:10 pm
No, there's no TI.H at all in 83+ version of compiler.
But this one is different than 83 version I started with, and gives me different asm code.
Either C to ASM part is too buggy or I'm doing something wrong. This time I get no errors, but no other output either. Only sdcc command line.
Guess I'm too tired to set it up now... I'll try tomorrow, but maybe someone else wants to have fun with setting up too :)
Title: Re: Small-C - confused
Post by: Scipi on November 19, 2011, 04:59:28 pm
It looks to me that ti83p_asm.rel does not exist. I'm getting the exact same error on the included test program.

Edit: I emailed the author. I hope I get a reply :)
Title: Re: Small-C - confused
Post by: AHelper on November 20, 2011, 02:36:40 am
Just the throw this out there as I already use C  and know a lot about it....

There are a few C compilers to use.  You must likely have to make your own glue functions to interface with TIOS.  That means that you need to convert that compiler's register/stack usage into b_call's. 

z88dk already has functions ready to use, but is huge.  If you want to make super-tiny programs in C for the ti83p right away, shell or no shell, then z88dk is there.

small-c has many differences from normal C and some things may be done differently.  I didn't like the C style in it, so I have no experience.

SDCC is what I use for the optimizing abilities, ansi c89/c99 compliance, and its own libc.  You will need to make glue functions for this, too, but the output code size is smaller than z88dk and allows high-level printf with floats to low level hardware access. 

The output files for the compilers is usually similar.  .ihx/.bin is the binary output.  If you want to make programs with C in TIOS, then have fun depending on the compiler.

(Because I am magnatized to C on z80 threads, I simply will note)  GlaßOS is a nice example of SDCC being used to write a replacement OS for the ti84pse, already with programs dealing with filesystem access, minimal CAS usage, greyscale and USB support.  The reason to note this is if you want to do a lot of C coding on a calc, then note that TIOS doesn't have a libc on it.  Each compiler has its own functions and will put them in every program you build.  GlaßOS has this library in it already plus more in order to make C programs much smaller.  That's my pointer about size outputs, but it isn't impossible to use C on a calc.

<edit> That missing file is the calc's crt0, as it seems.  That's just an asm file that contains the program's header and code layout that is compiled into a .rel and linked to your code output.  Since each compiler is different, you will need to modify the ti83 version to work with the ti83p.