mirror of
https://github.com/bradford-hamilton/apple-1.git
synced 2024-06-10 17:29:26 +00:00
cdca8f735d
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.
18 lines
358 B
Go
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]
|
|
}
|
|
}
|