User Tools

Site Tools


sd:tinyc_for_the_sd-8516

Differences

This shows you the differences between two versions of the page.


Previous revision
sd:tinyc_for_the_sd-8516 [2026/04/17 14:24] (current) appledog
Line 1: Line 1:
 += TinyC for the SD-8516
  
 +== Introduction
 +TinyC refers to V1 (tinyc.asm) and V2 (tinyc.c), which is the same as V1 but written in C. V1 is intended to compile V2, and then we have self-hosting C. Thus, this TinyC should be more like the "B" language in it's feature set, and in the idea that it is intended to compile a version of itself written in C. From there, we can iterate on the C compiler and make it better.
 +
 +V1 Current Feature Set:
 +* Expressions with precedence
 +* Local variables
 +* if/else/else if
 +* Comparison operators
 +* while
 +* break/continue
 +* Multiple functions + function calls
 +* Function arguments
 +* Pointers (read, write, address-of)
 +* Array indexing
 +* char* (8-bit access)
 +* String literals
 +* Hex literals
 +* Character literals
 +* Comments (<nowiki>//</nowiki>)
 +* Global variables
 +* Builtins (putchar, getchar, halt, yield)
 +
 +This is enough that I was able to start writing functions in C like abs, min, max, strlen, strcmp, atoi/itoa, and so on.
 +
 +== Function Library
 +* [[List of TinyC built-in functions]]
 +
 +== History
 +A self-hosting C compiler had been my goal for quite some time. But I didn't know how to write one. I hacked out a BASIC first, then followed some guides and source code to get a Forth running. But C eluded me for several months. Eventually I was able to leverage what I had learned doing BASIC to get a parser that could compile int main(void) { return 0; } and emitted LDA #0 and RET. The debugger was simply printing the return value. The rest of the story is found in the [[TinyC Developer Diary]]. Mainly so I don't forget what I learned, as this project has gotten quite big.

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki