geas icon indicating copy to clipboard operation
geas copied to clipboard

Numeric labels as PC assertionss

Open fjl opened this issue 2 months ago • 0 comments

The geas disassembler should be usable not just for inspecting bytecode, but also for editing bytecode. One challenge with this are jumps. The disassembler output for jumps looks like thi:

     ...
     push 0x23
     jump
     ...
     jumpdest
     ...

There is no way to infer where the jump actually goes. To help with this, the disassembler can print PC numbers (geas -d -pc):

           ...
000a:      push 0x23
000c:      jump
           ...
0023:      jumpdest
           ...

This makes jumpdest offsets visible, but it also means the disassembler output is no longer a valid assembler input. But there is no reason it couldn't be. We just have to make numeric labels valid in the input language, and turn them into a kind of assertion. When the assembler encounters a numeric label, it should check the computed PC at that point matches the label.

fjl avatar Nov 02 '25 12:11 fjl