lodsb ;al = *si++
mov ah,al ;eg if al=3eh (=mvi a,dd), then ax=0x3e3e
jmp ax ;eg goto 0x3e3e. Preloader puts the emulation
; code for mvi a,dd followed by another copy
; of the inner interpreter at cs:0x3e3e.
This approach uses 64K to sparsely store the emulation code for each of the 256 opcodes at 0x0000,0x0101,0x0202 ... etc. which seemed a pretty outrageous waste of memory at the time. But it was worth it because none of the 3 inner interpreter instructions modified the flags, which meant I could use the native 8086 flags to directly emulate the 8080 flags, a huge speed win. Remember that the 8086 had LAHF and SAHF instructions to help solve this very problem, yet my approach avoiding the whole flags issue was still twice as quick as commercial equivalents.Okay admittedly this is all irrelevant dinosaur nostalgia from the perspective of modern technology, but it reinforces the point that there's no substitute for human creativity when it comes to real hardcore optimization tricks.