|
|
@ -105,10 +105,6 @@ var InstructionIn = &Instruction{ |
|
|
|
var InstructionLoad = &Instruction{ |
|
|
|
var InstructionLoad = &Instruction{ |
|
|
|
Name: "LOAD", |
|
|
|
Name: "LOAD", |
|
|
|
ExecuteWithOperand: func(module *Module, operand float64) error { |
|
|
|
ExecuteWithOperand: func(module *Module, operand float64) error { |
|
|
|
index := int(operand) |
|
|
|
|
|
|
|
if len(module.register) <= index { |
|
|
|
|
|
|
|
return fmt.Errorf("index %d exceeds register size of %d", index, len(module.IO)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
module.accumulator = module.mmu.Read(Address(operand)) |
|
|
|
module.accumulator = module.mmu.Read(Address(operand)) |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
@ -125,10 +121,6 @@ var InstructionLoadNum = &Instruction{ |
|
|
|
var InstructionStore = &Instruction{ |
|
|
|
var InstructionStore = &Instruction{ |
|
|
|
Name: "STORE", |
|
|
|
Name: "STORE", |
|
|
|
ExecuteWithOperand: func(module *Module, operand float64) error { |
|
|
|
ExecuteWithOperand: func(module *Module, operand float64) error { |
|
|
|
index := int(operand) |
|
|
|
|
|
|
|
if len(module.register) <= index { |
|
|
|
|
|
|
|
return fmt.Errorf("index %d exceeds register size of %d", index, len(module.IO)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
module.mmu.Write(Address(operand), module.accumulator) |
|
|
|
module.mmu.Write(Address(operand), module.accumulator) |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
}, |
|
|
|
}, |
|
|
@ -204,11 +196,6 @@ func newMathInstruction(name string, operation func(accumulator, register float6 |
|
|
|
return &Instruction{ |
|
|
|
return &Instruction{ |
|
|
|
Name: name, |
|
|
|
Name: name, |
|
|
|
ExecuteWithOperand: func(module *Module, operand float64) error { |
|
|
|
ExecuteWithOperand: func(module *Module, operand float64) error { |
|
|
|
index := int(operand) |
|
|
|
|
|
|
|
if len(module.register) <= index { |
|
|
|
|
|
|
|
return fmt.Errorf("index %d does not exist in register", index) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
param := module.mmu.Read(Address(index)) |
|
|
|
param := module.mmu.Read(Address(index)) |
|
|
|
module.accumulator = operation(module.accumulator, param) |
|
|
|
module.accumulator = operation(module.accumulator, param) |
|
|
|
return nil |
|
|
|
return nil |
|
|
|