Created
October 2, 2011 19:14
-
-
Save rjungemann/1257796 to your computer and use it in GitHub Desktop.
TinyVM example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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