Use float64 instead of int64

master
Jonas Franz 5 years ago
parent 725e443e56
commit 0eeea6f007
Signed by: JonasFranzDEV
GPG Key ID: 7293A220B7C38080
  1. 13
      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
}

Loading…
Cancel
Save