- compiler works for basic maths expressions and functions

- basic pointers and reading values from pointers works
- writing to pointers not yet implemented (looks painful so a problem
  for tomorrow)
- updated print library. the compiler has this hardcoded in all programs
  for now
This commit is contained in:
2026-02-03 02:11:30 +00:00
parent 5573c5a609
commit 3afeafc9d4
17 changed files with 2009 additions and 807 deletions
+37
View File
@@ -0,0 +1,37 @@
dw global_arena_start: 0x30000
dw global_arena_current: 0x30000
dw global_arena_end: 0x40000
arena_alloc:
// Just like bump allocator
push bpr
mov spr, bpr
ldw bpr, rg0, 8 // size argument
ldw global_arena_current, rg1
add rg1, rg0, rg2 // new_current = current + size
ldw global_arena_end, rg3
cmp rg2, rg3
jgt out_of_memory
stw rg2, global_arena_current
mov rg1, acc // return old current
stw acc, bpr, 8
mov bpr, spr
pop bpr
return
arena_reset:
// Reset to start
push bpr
mov spr, bpr
ldw global_arena_start, rg0
stw rg0, global_arena_current
mov bpr, spr
pop bpr
return