Skip to content

7. Memory (Internals)

AsynchronousAI edited this page Sep 1, 2025 · 1 revision
Screenshot 2025-09-01 at 1 51 49 PM

Here is a visualization on the memory model.

Static Data

On the left you can see Strings & Static data automatically added by compiler. This includes the strings (added with .asciz, .string), or static arrays (added with .word, .half, .byte). These are all allocated first thing to the start of the main memory buffer on init().

sp

sp is the memory pointer, and is used to allocate values on runtime. It is assigned in the center because the compiler assumes it can allocate from both sides.

Updating memory size

local module = ...

module.memory = buffer.create(4096) -- override the 2kb memory with 4kb

module.init() -- load all strings, static data, etc and center the 'sp' register.
module.main() -- start

Clone this wiki locally