diff --git a/hal/module.go b/hal/module.go index fd01476..e483900 100644 --- a/hal/module.go +++ b/hal/module.go @@ -5,17 +5,22 @@ import "fmt" type Program []*ProgrammedInstruction type Module struct { - Accumulator int64 + Accumulator float64 ProgramStorage Program - Register []int64 + Register []float64 } func (h *Module) ProgramCounter() int64 { - return h.Register[0] + return int64(h.Register[0]) +} + +func (h *Module) increaseProgramCounter() { + h.Register[0]++ } func (h *Module) Step() error { instruction := h.ProgramStorage[h.ProgramCounter()] + h.increaseProgramCounter() if instruction == nil { return fmt.Errorf("instruction not found for program counter = %d", h.ProgramCounter()) } @@ -28,6 +33,6 @@ func NewHALModule(program Program, registerSize uint64) (*Module, error) { } return &Module{ ProgramStorage: program, - Register: make([]int64, registerSize), + Register: make([]float64, registerSize), }, nil }