User Tools

Site Tools


sd:tinyc_for_the_sd-8516

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
sd:tinyc_for_the_sd-8516 [2026/05/30 02:58] โ€“ appledogsd:tinyc_for_the_sd-8516 [2026/06/05 16:53] (current) โ€“ appledog
Line 40: Line 40:
 === Compile to disk === Compile to disk
 The other solution I am mulling is to rewrite the emitter. There's no reason it has to output to the exact location it will run at. It could output the bytes to a file instead. The other solution I am mulling is to rewrite the emitter. There's no reason it has to output to the exact location it will run at. It could output the bytes to a file instead.
 +
 +== What's Missing?
 +* Preprocessor: no #include, #define, #ifdef, macros, conditional compilation. Every program is monolithic.
 +Structs and unions: cannot define composite types. No member access (., ->).
 +* Typedef: no type aliases.
 +* Multi-dimensional arrays and array declarations: int arr[10] doesn't exist; arrays only as pointers.
 +* Initializers: int g = 5; parses but doesn't run. No aggregate initializers {1, 2, 3}.
 +* String literals as data: strings work only as immediate operands, not as initialized arrays.
 +* Function pointers: no syntax, no calling convention.
 +* Variable arguments: no ..., no va_list.
 +* enum: no constant enumeration.
 +* static, extern, register, volatile, const: storage class and qualifier keywords missing.
 +* Multiple return types: only int (well, 24-bit). No void, char, short, long, float, double returns.
 +* void type: parsed in (void) parameter list only; can't declare void variables, return void, or use void 
 +
 +=== Operator gaps
 +* Bitwise ops are critical for systems programming. Without them, no masking, no flag manipulation.
 +* Logical && and || with short-circuit semantics matter for correctness, not just convenience.
 +* ++/-- are syntactic sugar but their absence is glaring.
 +* % (modulo) for any non-trivial arithmetic.
 +* Compound assignment is just sugar but expected.
 +
 +=== Library
 +* No standard library at all. No printf, malloc, strcmp, memcpy, strlen. Programs must be self-contained or call only the six builtins.
 +* No file I/O from compiled programs (peek/poke don't qualify).
 +* No dynamic memory.
 +
 +=== Compiler quality
 +* No optimization passes. Every operation goes through BLA via the stack.
 +* No type checking. Assigning char * to int is silent.
 +* No warnings about unused variables, missing returns, narrowing conversions.
 +* Error messages are minimal ("undefined variable" without line number context).
 +* No symbol scoping beyond function-local โ€” all locals share one flat namespace within a function.
 +
 +=== Language semantics
 +* Pointer arithmetic doesn't scale by element size: int *p; p + 1 adds 1 byte, not 3.
 +* sizeof would be needed to write portable code; absent.
 +* Char arithmetic doesn't promote to int per C rules.
 +* No automatic conversions, casts, or type coercion.
 +
 +== Roadmap
 +This is not a roadmap.
 +
 +=== Easy
 +* Bitwise operators.
 +* ++/-- and compound assignment.
 +* % operator; opcode already exists in the CPU, just needs parser.
 +* Pre-processor. Separate pass before lexing; probably harder than it sounds.
 +
 +=== Medium
 +* &&/|| with short-circuit. Needs branch generation.
 +* Local arrays. int arr[10] allocates 30 bytes on stack, needs frame offset adjustment and array-as-pointer-decay.
 +
 +=== Hard/Time-consuming/Don't know
 +* Initialized globals. This is, unfortunately, non-trivial :( It requires either an init phase before main or compile-time init.
 +* Standard library subset -- strlen, strcmp, memcpy, printf (formatted output is a project of its own).
 +* Type checking. Proper type expression evaluation, conversion rules.
 +* Structs. Type representation grows from 1 byte to multi-byte type descriptor.
sd/tinyc_for_the_sd-8516.1780109898.txt.gz ยท Last modified: by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki