In the last paper we showed how vbdec could be automated by a local AI agent.
One of the demos was using it to build a pcode opcode reference from the disassembler tables of the tool itself. That database was then enhanced by having AI automate IDA to analyze the actual vb runtime opcode handlers. We then added this info to the database and also used it to check my disasm.
This weekend I took the next step and had the AI do an automated compile/disassemble loop to document how to generate as many opcodes as we could and analyze the outputs further. Knowing exactly when each opcode is emitted is actually pretty interesting.
One other bit of trivia claude discovered. So there is a BoS (beginning of statement) and LargeBoS opcodes. BoS is used for on error resume next, so the runtime knows what the next statement should be if it encounters an error. It takes the next byte as the relative jump offset.
So what happens if your function has the next statement more than 255 bytes away? Thats where LargeBoS comes into play, and now the next byte is an index into an offset table that trails the function body.
So when do you get an instruction longer than 255 bytes?! Well come instructions are variable length and contain a list of arguments that all get processed at once like freeing strings.