I am currently attempting to output assembly using the script below:
for instr in currentProgram.getListing().getInstructions(True):
print("\" " + str(instr) + "\\n\\t" + "\"")
It produces output like below:
" ADD RBX,0x1\n\t"
" CMP RBP,RBX\n\t"
" JNZ 0x001012b0\n\t"
" ADD RSP,0x8\n\t"
This works great for every instruction except anything that modifies the execution flow, such as jumps or calls. I'd ideally like the output to be:
" ADD RBX,0x1\n\t"
" CMP RBP,RBX\n\t"
" JNZ -0x10\n\t"
" ADD RSP,0x8\n\t"
Because in this example, the JNZ instruction jumps to an address a distance of 0x10 before this instruction. I can see this in the instruction bytes of 75 ea (75 being a jnz, and ea being -0x10), but I don't know how to get this value from the ghidra scripting api. Can you help me get this value for the output I'm expecting?