I am building a completely custom 32-bit Virtual Machine, a bare-metal Operating System, and a custom C Compiler (a heavily modified port of chibicc).
- The VM is a pure Stack Machine (no general-purpose registers, just R1-R4 for math/sys, FP, SP, PC).
- There is NO standard library (
libc). No<stdio.h>,<stdlib.h>, or<string.h>. - Everything is handled via direct pointer memory-mapping or inline assembly bridging to hardware syscalls.
- Word Size: 32-bit integers, 8-bit chars.
- CPU: Uncapped speed (runs as fast as host).
- VRAM (0x100000 / 1048576): 320x200 pixel screen, 8-bit color palette. Mapped as
char *vram. - Keyboard MMIO (0x200000 / 2097152): Array of 256 key states. Mapped as
char *keys.keys[256]= Escape Keykeys[257]= Enter Key
- CPU 'RC' Register (8388376): Mapped as
int *RC. Used to pull typewriter characters generated by the Syscall Input interrupt. - System Font (10000): 8x8 font bitmap loaded into RAM here.
RS = 2: Clear ScreenRS = 6: Keyboard Input (returns ASCII typed char intoRCregister)RS = 7: Render Frame (VSync)RS = 8: Hardware Disk Write (RX= Sector,RY= RAM Ptr,RC= Sector Count)RS = 9: Hardware Disk Read (RX= Sector,RY= RAM Ptr,RC= Sector Count)
The Hard Drive contains a 512-byte Directory Table at Sector 9. It holds a maximum of 16 files. Each entry is 32 bytes:
struct DirectoryEntry {
char name[24]; // Filename (null-terminated)
int start_sector; // Physical sector on drive.img
int size_in_bytes; // File size
};
5. C Compiler Status (chibicc Custom Port)
All Intel x86 generation has been ripped out and replaced with my VM's custom stack assembly (e.g., PSH, LOD, STI, LDB, STB, RUN).
Supports cdecl calling convention (Caller pushes arguments, callee maps FP + offset, caller drops arguments).
Pointers and Arrays work perfectly.
char correctly evaluates to 1-byte (LDB/STB), int to 4-bytes (LDI/STI).
Stack depth tracking is fully balanced.
AI Directive:
Do NOT use standard C libraries. Only write C code that compiles natively for my custom hardware map. Acknowledge this context and ask me for the current Kilo source code or the next step I want to take.