With a list of opcodes for a virtual machine, is it possible to assign a number to every possible program of size n that can be run on that machine? Say you have some virtual machine with &lt; 100 numbered opcodes that fully specify its behaviour. Is there an easy way to order and enumerate all possible programs of less than n instructions, the result being that a particular number refers to a particular program? Preferably with natural numbers and short programs at the begining.
As this list would be combinatorially large, it would be helpful to assign these numbers without running the programs or loading them into memory.
There is no need to assign a number. The program already is a number.
If you have $m$ opcodes and your program has $n$ instructions, then it can be interpreted as an $n$-&quot;digit&quot; number written in base $m$.