Added a function to load in a block of memory

This commit is contained in:
Sasha Koshka 2022-08-28 17:50:53 -04:00
parent 3b8f87212f
commit eb3f581b00
1 changed files with 7 additions and 1 deletions

View File

@ -53,7 +53,7 @@ func (machine *Machine) Reset () {
func (machine *Machine) Execute (offset int) {
machine.counter = offset
for {
for machine.counter < len(machine.Program) {
switch machine.instruction() {
case 0x0:
// PUSH
@ -244,5 +244,11 @@ func (machine *Machine) Unregister (id int) {
delete(machine.functions, id)
}
// LoadMemory loads the contents of block into the machine's memory.
func (machine *Machine) LoadMemory (block []int) {
machine.block = make([]int, len(block))
copy(machine.block, block)
}
// Milk milks the stack machine
func (machine *Machine) Milk () {}