Files
subcoding/gen/instruction.go

16 lines
287 B
Go
Raw Normal View History

2021-11-20 17:59:22 -10:00
package gen
import "github.com/firestuff/subcoding/vm"
2021-11-20 18:27:06 -10:00
func randInstruction(prog *vm.Program) *vm.Instruction {
2021-11-20 17:59:22 -10:00
instr := &vm.Instruction{
OpCode: randOpCode(),
}
for i, t := range vm.OperandsByOpCode[instr.OpCode] {
2021-11-20 18:27:06 -10:00
instr.Operands[i] = randOperand(prog, t)
2021-11-20 17:59:22 -10:00
}
return instr
}