// GoSyntax returns the Go assembler syntax for the instruction. // The syntax was originally defined by Plan 9. // The pc is the program counter of the instruction, used for expanding // PC-relative addresses into absolute ones. // The symname function queries the symbol table for the program // being disassembled. Given a target address it returns the name and base // address of the symbol containing the target, if any; otherwise it returns "", 0. // The reader r should read from the text segment using text addresses // as offsets; it is used to display pc-relative loads as constant loads. func GoSyntax(inst Inst, pc uint64, symname func(uint64) (string, uint64), text io.ReaderAt) string { … } var plan9Shift … func plan9Arg(inst *Inst, pc uint64, symname func(uint64) (string, uint64), arg Arg) string { … } // convert memory operand from GNU syntax to Plan 9 syntax, for example, // [r5] -> (R5) // [r6, #4080] -> 0xff0(R6) // [r2, r0, ror #1] -> (R2)(R0@>1) // inst [r2, -r0, ror #1] -> INST.U (R2)(R0@>1) // input: // // a memory operand // // return values: // // corresponding memory operand in Plan 9 syntax // .W/.P/.U suffix func memOpTrans(mem Mem) (string, string) { … } type goFPInfo … var fpInst … // convert FP instructions from GNU syntax to Plan 9 syntax, for example, // vadd.f32 s0, s3, s4 -> ADDF F0, S3, F2 // vsub.f64 d0, d2, d4 -> SUBD F0, F2, F4 // vldr s2, [r11] -> MOVF (R11), F1 // inputs: instruction name and arguments in GNU syntax // return values: corresponding instruction name and arguments in Plan 9 syntax func fpTrans(inst *Inst, op string, args []string) (string, []string) { … }