bradford-hamilton-apple-1/internal/vm/mem.go
Bradford Lamson-Scribner cdca8f735d internal/vm: add the first few opcode handlers
Still a little iffy on the code design, although this seems like it
could be a desirable pattern. This way I would have to write an opcode
handler for all the cases and register it to the “op”. That way step
calls are super simple from Appleone’s point of view -> get the operation
and that operation has everything needed to execute on the vm.
2020-05-30 11:03:58 -06:00

18 lines
358 B
Go

package vm
// block represents a 64kiB memory block
type block [64 * 1024]byte
func newBlock() [64 * 1024]byte {
return [64 * 1024]byte{}
}
// load loads a program into memory at the provided address space
func (b block) load(addr uint16, data []uint8) {
end := int(addr) + len(data)
for i := int(addr); i < end; i++ {
b[int(addr)+i] = data[i]
}
}