Applications and language tools
OaSis includes a kernel-mode text editor, a built-in x86 assembler, and the occ subset C compiler. These tools run inside the VGA shell and write output through kernel services.
Text editor
Source: src/kernel/apps/editor.c
The editor stores up to 4 KiB of text and supports navigation, editing, saving, and scrolling.
| Key | Action |
|---|---|
Ctrl+X |
Exit after saving changes. |
Ctrl+S |
Save through the VFS. |
| Arrow keys | Move the cursor. |
Home and End |
Move to the start or end of a line. |
Backspace and Delete |
Remove characters. |
Enter |
Insert a newline. |
Tab |
Insert four spaces. |
The editor renders multiple lines from the scroll position. A status bar shows the filename, line, and column.
Built-in assembler
Source: src/kernel/apps/asm.c
The assembler accepts a subset of 32-bit x86 instructions, labels, data directives, external symbols, and the times directive. It emits machine code into the CODE_VIRT execution area.
Assembly flow
asm_assemble(code, &exec_addr)
1. Copy the source into the input buffer.
2. Process each line.
- A line ending in ':' defines a label.
- An instruction is parsed and encoded.
3. Apply forward-reference patches.
4. Allocate pages at CODE_VIRT (0x40000000).
5. Copy the generated bytes into CODE_VIRT.
6. Return the execution address.
Labels and patches
Labels store names and byte offsets. Patches store the byte position, instruction origin, target label, and relocation type.
static struct {
char name[32];
int position;
} labels[MAX_LABELS];
static struct {
int position;
int origin;
char target[32];
int type;
} patches[MAX_PATCHES];
Supported instruction groups
mov,add,sub,cmp,xor,and,orjmp,je,jne,jg,jl,jge,jlecall,push,pop,inc,decimul,idiv,cdq,div,neg,test,movzx- Conditional
setccandcmovccinstructions int,nop,hlt,sti,cli,pusha, andpopadbandtimes
Occ compiler
The occ compiler is a small subset C compiler built from src/kernel/lib/lexer.c, parser.c, and codegen.c.
It supports integers, characters, functions, parameters, arrays, expressions, if, while, for, printf, and allocation helpers. It emits x86 assembly that the built-in assembler can execute.
Compiler pipeline
C source
-> lexer: source characters become tokens
-> parser: tokens become an AST
-> code generator: AST becomes x86 assembly
-> assembler: assembly becomes executable bytes
The compiler is intentionally limited. It is a teaching tool, not a complete C implementation. See the shell guide for occ, lex, parse, nasm, and user commands.