Skip to content

Instantly share code, notes, and snippets.

@rjungemann
Created October 2, 2011 19:14
Show Gist options
  • Select an option

  • Save rjungemann/1257796 to your computer and use it in GitHub Desktop.

Select an option

Save rjungemann/1257796 to your computer and use it in GitHub Desktop.
TinyVM example
// R08 stores a pointer to top of the heap
// a function with two parameters (lists of pointers)
// R09 stores the flag
// R10 stores a pointer to the current node in the heap
// R11 stores:
// * a pointer to the list of parameters
// * the return value
f:
[popf R09]
[pop R11]
// ...
// smash current node in heap pointed to by R10
// deallocate list at R11
// store the return value in R11
[push R11]
// ...
// push a pointer to the list of parameters
[pushf]
[call f]
// pop the return value
// the heap is a tree where each node contains:
// * pointer to parent
// * pointer to list of children
// * pointer to hash (pointer to string, pointer to value) of variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment