Added a function to load in a block of memory
This commit is contained in:
parent
3b8f87212f
commit
eb3f581b00
@ -53,7 +53,7 @@ func (machine *Machine) Reset () {
|
|||||||
func (machine *Machine) Execute (offset int) {
|
func (machine *Machine) Execute (offset int) {
|
||||||
machine.counter = offset
|
machine.counter = offset
|
||||||
|
|
||||||
for {
|
for machine.counter < len(machine.Program) {
|
||||||
switch machine.instruction() {
|
switch machine.instruction() {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
// PUSH
|
// PUSH
|
||||||
@ -244,5 +244,11 @@ func (machine *Machine) Unregister (id int) {
|
|||||||
delete(machine.functions, id)
|
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
|
// Milk milks the stack machine
|
||||||
func (machine *Machine) Milk () {}
|
func (machine *Machine) Milk () {}
|
||||||
|
Loading…
Reference in New Issue
Block a user