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

Function getNextExecutableInstructionLoc

asm/assembler.go:167–191  ·  view source on GitHub ↗
(currentOffset uint16, currentInstrIndex int, instructions []Instruction)

Source from the content-addressed store, hash-verified

165}
166
167func getNextExecutableInstructionLoc(currentOffset uint16, currentInstrIndex int, instructions []Instruction) uint16 {
168 // if at the end then just return the location outside the loop
169 if currentInstrIndex == (len(instructions) - 1) {
170 return uint16(currentOffset + uint16(instructions[currentInstrIndex].Size()))
171 }
172
173 nextInstructionPos := 0
174
175 for i := currentInstrIndex; i < len(instructions); i++ {
176 instruction := instructions[i]
177 if _, ok := instruction.(DEFLABEL); ok {
178 continue
179 } else if _, ok := instruction.(DEFSYMBOL); ok {
180 continue
181 } else {
182 if currentInstrIndex == i {
183 nextInstructionPos += instruction.Size()
184 } else {
185 break
186 }
187 }
188
189 }
190 return uint16(currentOffset) + uint16(nextInstructionPos)
191}

Callers 2

ProcessMethod · 0.85
ToStringMethod · 0.85

Calls 1

SizeMethod · 0.65

Tested by

no test coverage detected