Page 1 of 1

XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 09 Jun 2020, 15:52
by miyuki_takara
Hello folks,
Today we would like to announce a new project, XPicoC, which turns your TI-Nspire CX into a powerful programming machine in pure C programming language WITHOUT NDLESS! :D

XPicoC is programmed completely in the Lua scripting language and does not depend on any native code, so it can be run on all TI-Nspire OSes from OS 3.2 to the newest OS 5.1, and only slight changes are needed to make it compatible with OS 3.0 and OS 3.1.
We have implemented all the essential features of ISO C, including pointer arithmetic.

Please read the Project GitHub Page for more details about this project.
Project GitHub Page: https://github.com/ExAcler/XPicoC

Usage:
Play with it by directly typing in C statements.
To execute from a C source file:
Create a Notes application and type in or paste your C source code into the application.
Press Ctrl+A followed by Ctrl+C.
Switch back to XPicoC and press Ctrl+V (Or press Menu and select Run > Run code from clipboard)

Screenshots:

Simple Hello World:

Image

Pointer arithmetic:

Image

Quicksort:

Image

Current version of XPicoC is still being tested and may be error prone. A preview version of XPicoC is available to download now:
archives_voir.php?id=2624026

If you are interested you can clone the project and deploy it yourself to get the latest updates.

Re: XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 09 Jun 2020, 17:11
by jean-baptiste boric
Looks cool! Have you made benchmarks against native execution? Also which (if any) platforms APIs do you intend to implement?

Re: XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 09 Jun 2020, 17:21
by miyuki_takara
It is way slower than native C execution. This is due to double interpretation: Lua itself interpreted by Native C, and XPicoC is again interpreted by Lua. A sample C code containing only for loops may take 100 times more time than native C to execute. My intention was to make an at least "usable" C interpreter that fully conforms to Texas Instrument's "legality" policy on TI-Nspire programming. Execution efficiency is not the first thing I should consider at this stage.

Re: XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 09 Jun 2020, 17:26
by miyuki_takara
I am planning to implement gc-related functions in the near future and add a "Graphics Console" page in addition to the current "Command Prompt" page.
Implementing other platform-dependent function should be a breeze.

Re: XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 10 Jun 2020, 13:43
by Bisam
Are you planning to support execution of code read from a file ?

Re: XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 10 Jun 2020, 14:39
by miyuki_takara
TI-Lua does not support reading from a file inside the TI-Nspire filesystem; but it is possible to simulate it inside a TI-Nspire document. If we receive sufficient positive feedback on this project, we may consider implementing a code editor like Jen's Script Editor that is capable of storing C source files, and you will be able to run from these files.
stdio functions are still under development; you will be able to read the contents from a "file" that is indeed stored in a platform variable.

Re: XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 10 Jun 2020, 16:39
by Bisam
Sounds great !

Re: XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 10 Jun 2020, 17:22
by Adriweb
Nspire Lua can "read from files", but those files have to be .tns inside MyLib.

What I did in FormulaPro a long time ago in order to dynamically load external databases relied on that. A LibPub basic function exposed in a tns file in MyLib, that Lua can call (then execute).
See here: https://github.com/adriweb/EEPro-for-Ns ... tabase.lua

Re: XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 18 Aug 2020, 15:21
by Zocipal
Great project, really interesting !

Re: XPicoC - C interpreter ported to TI-Lua!

Unread postPosted: 20 Aug 2020, 02:55
by BackStage
good job thank you :)