Fix register handling

master
kolaente 4 years ago
parent f29bcbb2ae
commit 2a606aaaf8
Signed by: kolaente
GPG Key ID: F40E70337AB24C9B
  1. 7
      hal/instructions.go

@ -109,7 +109,7 @@ var InstructionLoad = &Instruction{
if len(module.register) <= index {
return fmt.Errorf("index %d exceeds register size of %d", index, len(module.IO))
}
module.accumulator = module.register[index]
module.accumulator = module.mmu.Read(Address(operand))
return nil
},
}
@ -129,7 +129,7 @@ var InstructionStore = &Instruction{
if len(module.register) <= index {
return fmt.Errorf("index %d exceeds register size of %d", index, len(module.IO))
}
module.register[index] = module.accumulator
module.mmu.Write(Address(operand), module.accumulator)
return nil
},
}
@ -209,7 +209,8 @@ func newMathInstruction(name string, operation func(accumulator, register float6
return fmt.Errorf("index %d does not exist in register", index)
}
module.accumulator = operation(module.accumulator, module.register[index])
param := module.mmu.Read(Address(index))
module.accumulator = operation(module.accumulator, param)
return nil
},
}

Loading…
Cancel
Save