MCPcopy Create free account
hub / github.com/djhworld/simple-computer / Run

Method Run

computer/computer.go:93–118  ·  view source on GitHub ↗
(tickInterval <-chan time.Time, printStateConfig PrintStateConfig)

Source from the content-addressed store, hash-verified

91}
92
93func (c *SimpleComputer) Run(tickInterval <-chan time.Time, printStateConfig PrintStateConfig) {
94 log.Println("Starting computer....")
95 c.putValueInRAM(0xFEFE, 0x0040) //JMP back to code region start if IAR reaches the end
96 c.putValueInRAM(0xFEFF, CODE_REGION_START)
97
98 // start at offet of user code
99 c.cpu.SetIAR(CODE_REGION_START)
100 go c.screenControl.Run()
101
102 steps := 0
103 for {
104 <-tickInterval
105 c.cpu.Step()
106
107 if printStateConfig.PrintState {
108 if steps%printStateConfig.PrintStateEvery == 0 {
109 fmt.Println("COMPUTER\n-----------------------------------------------------------")
110 fmt.Printf("Cycle count = %d, step count = %d, printing state every %d steps\n\n", steps/6, steps, printStateConfig.PrintStateEvery)
111 fmt.Println("CPU\n----------------------------------------")
112 fmt.Println(c.cpu.String())
113 fmt.Println()
114 }
115 }
116 steps++
117 }
118}

Callers

nothing calls this directly

Calls 4

putValueInRAMMethod · 0.95
SetIARMethod · 0.80
StepMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected