You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

C support in KOS

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0
b/[Inactive] KnightOS (TI-73/83+/84+/CSE) publicado por u/Max Leiter December 27, 2015, 11:53:26 PM
I had a better topic but accidentally reloaded the page and lost it  :(

Recently, I've been working on C bindings/the C library (libc) for KnightOS. Once I've finished the C bindings for corelib I plan to create some bindings for fx3dlib and configlib (both by @matrefeytontias).

I'm really hoping this will interest more people in KOS, mostly because a lot more people are familiar with C than z80 asm.

The compiler used is KCC, a fork of SDCC. There's a C library, libc, which has some POSIX-compliant functions where there's overlap between KOS and POSIX systems. There's also bindings for corelib, a userspace library, so hopefully some KOS C programs will start to show up.

To show off libc, here's a demo that SirCmpwn made: pong


And here's a demo I made demonstrating corelib: corelibcdemo (I'm very original when it comes to naming things)



So I guess if anyones curious about C support/has questions/errors/whatever, you can post here, ask me on IRC, or ask in #knightos on freenode

Inicia sesión o crea una cuenta para dejar un comentario
u/Ivoah December 28, 2015, 03:41:16 AM
Looks nice! It's been great seeing all of the pull requests and stuff from you on IRC and in my email :) Keep up the good work :thumbsup:
u/ben_g December 29, 2015, 12:30:42 PM
I looked at some source files, and:
Quote from: source fragment
double tan(double x) {
    return sin(x) / cos(x);
}
Does that mean we can use floating points on KOS in C? O.O
u/Max Leiter December 29, 2015, 05:28:57 PM
Quote from: ben_g on December 29, 2015, 12:30:42 PM
I looked at some source files, and:
Quote from: source fragment
double tan(double x) {
    return sin(x) / cos(x);
}
Does that mean we can use floating points on KOS in C? O.O
Well, kind of. I don't really understand it, but libc doesn't provide BCD (binary-coded decimal) floats. This means that 0.1 + 0.2 = 0.300000000001, but that probably won't affect you too badly.


EDIT:
Just PR'd my filestream bindings into libc, so now you can (kind of!) modify/create/etc files!
Last Edit: December 29, 2015, 05:57:00 PM by Max Leiter
u/Dream of Omnimaga December 30, 2015, 06:24:43 AM
That is awesome. Is it useable yet? Because that would definitively be news material. A lot of people like C and the fact that KnightOS has an emulator (and I assume that other emus can be used with a KOS ROM) will probably help.
u/Max Leiter December 30, 2015, 06:43:49 AM
Quote from: DJ Omnimaga on December 30, 2015, 06:24:43 AM
That is awesome. Is it useable yet? Because that would definitively be news material. A lot of people like C and the fact that KnightOS has an emulator (and I assume that other emus can be used with a KOS ROM) will probably help.

Yeah, its definitely usable (see: demos), but there's a few small things that get annoying (C89, mainly). z80e, the emulator, can load TI-OS (with a few bugs) afaik, and I've been using it for KOS for the past few months. The one big downside imo is no keyboard/skin, but that's not really a huge deal.
u/Dream of Omnimaga December 30, 2015, 06:55:22 AM
Can you enlighten me about what C89 is? Because Google returns mostly results about ANSI C and irrelevant stuff. As for the lack of a keyboard/skin, it's ok for now, as long as the keyboard layout is identical to WabbitEmu/PindurTI, since those emulators have been used for almost a decade.
u/Lionel Debroux December 30, 2015, 07:14:27 AM
C89 is the 1989 version of ANSI/ISO C, indeed.
u/SirCmpwn December 30, 2015, 03:30:16 PM
FWIW you can ask kcc to use C99 mode, but it's not entirely implemented.
u/Max Leiter December 31, 2015, 03:52:08 AM
Having seen the many issues @ben_g has experienced using libc (none his fault, they're just things that seem like nobrainers to me because I wrote most of them), I've gone through and commented *most* C functions in libc and corelib.

Here's the corelib header file, fully documented :) : https://github.com/MaxLeiter/corelib/blob/master/corelib.h

I've decided to finally write up the KnightOS C tutorials that will be on the website. Here's a screenshot of the first one (haven't pushed it yet, plan to write the others first).
https://sr.ht/VvMS.png

Also, @ben_g threw together a pretty nice (WIP) calculator program in C
u/Dream of Omnimaga December 31, 2015, 09:04:09 AM
Oh, nifty. It would be cool to see more math applications for KOS in the future, especially now that C is supported. :)
u/Max Leiter January 01, 2016, 12:01:04 AM
Finished up the C tutorial for using corelib (userspace library), drawing the corelib window, and userinput :)

https://sr.ht/HzJX.png
u/Dream of Omnimaga January 26, 2016, 07:46:39 AM
Darn, that's an elaborate tutorial. Nice. And I'm glad it will be on KOS website or established site/forum, rather than a small personal site, so it will remain online as long as KnightOS domain name is up.
u/Max Leiter January 26, 2016, 07:51:26 AM
Quote from: DJ Omnimaga on January 26, 2016, 07:46:39 AM
Darn, that's an elaborate tutorial. Nice. And I'm glad it will be on KOS website or established site/forum, rather than a small personal site, so it will remain online as long as KnightOS domain name is up.

Yep! Once I bother making a PR/finishing the tutorials, theyll be available here: http://www.knightos.org/documentation/
u/Dream of Omnimaga January 26, 2016, 07:55:01 AM
Thanks for the link. That reminds me, since CW no longer has a tutorials-specific board, we definitively need to make a list somewhere with links to external tutorials. It would be easier to find stuff. But that's offf-topic :P
Start a Discussion

b/[Inactive] KnightOS (TI-73/83+/84+/CSE)

A third-party operating system intended to be compatible with every Z80 TI calculator that can be upgraded from the TI-73 to the TI-84 Plus series. It is still under development.

6
Topics
Explore Board
Website statistics


MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
Powered by EzPortal