[Openmcl-devel] help me read disassemble output
gb at clozure.com
Mon May 19 21:51:19 PDT 2014
The syntax used by the disassembler is essentially the same as the syntax used
by the assembler ... that isn't documented either, but it's fairly simple.
An instruction is represented by a list whose CAR is (usually) an instruction
mnemonic and whose CDR is a list of 0 or more operands. Labels generated
by the disassembler are atoms of the form "Ln", where n is the label's address
in bytes relative to the start of the function.
The disassembler usually uses canonical symbolic names for registers; for
x8664, these names are defined in "ccl:compiler;X86;X8664;x8664-arch.lisp"
and IIRC are discussed in chapter 17 of the CCL manual.
CCL's disassembler indeed is based on AT&T syntax; some instructions have
slightly different names than in Intel/Microsoft syntax, and the destination
operand (if any) follows source operand(s).
A register operand is written as %reg in at&t syntax and as (% reg) in CCL.
A constant operand is written as $val in at&t sybtax and as ($ val) in CCL.
A memory operand is written as seg:disp(base,index,scale) in at&t syntax and
as (@ (% seg) disp (% base) (% index) scale) in CCL. (Many of the fields
in a memory operand can be omitted.)
Lisp objects referenced as constants by a function are stored in the
function (after the function's machine code). The register whose symbolic
name is FN usually points to the first byte of the function's code; references
past the end of the function's code that use FN as a base register disassemble
as (@ 'constant (% fn))
There are some cases where the address of a label is used in an expression
and the disassembler recogizes this; those expressions are represented as (^ lab),
(Sometimes, the label address is pc-relative; sometimes, it's relative to the
start of the function.
There may be a little more to disassembler syntax that I'm forgetting; if so,
it's even more obscure than what's described above.
On Mon, 19 May 2014, Leo Liu wrote:
> Sorry if this is obvious.
> I can sort of guess but I would like to have a better understanding of
> the disassemble output. From what I have learnt by Google the assembly
> syntax resembles AT&T's. Any resources (links, docs etc.) that you know
> of that can help? Thanks.
> (machine-type) => "X86-64"
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel