package
0.0.0-20230405025934-acc62890dc3b
Repository: https://github.com/coolcoder613eb/go.vm.git
Documentation: pkg.go.dev
# Functions
LoadProgTrap loads a program into memory
Input: Memory address in register 0.
NewCPU returns a new CPU object.
NewRegister is the constructor for a register.
NewStack creates a new stack object.
ReadStringTrap reads a string from the console
Input: None
Output:
Sets register 0 with the user-provided string.
RemoveNewLineTrap removes any trailing newline from the string in #0
Input:
The string operate upon in #0.
StrLenTrap returns the length of a string.
TrapNOP is the default trap-function for any trap IDs that haven't explicitly been setup.
# Variables
TRAPS is an array of our trap-functions.
# Structs
CPU is our virtual machine state.
Flags holds the CPU flags - of which we only have one.
IntegerObject is an object holding an integer-value.
Register holds the contents of a single register, as an object.
Stack holds return-addresses when the `call` operation is being completed.
StringObject is an object holding a string-value.
# Interfaces
Object is the interface for something we store in a register.
# Type aliases
TrapFunction is the signature for a function that is available as a trap.