From: deech
Subject: SBCL Disassemble Function
Date: 
Message-ID: <11329d12-1696-4cd6-8afc-71c576fc948a@i12g2000prf.googlegroups.com>
How do I read the output from the SBCL disassemble function. I can't
find the specs online or in the SBCL manual.

For example a defining a simple function (defun testx ()) at the SLIME
prompt results in the following disassemble output:
;0B3EE626:       BA0B001001       MOV EDX, 17825803          ; no-arg-
parsing entry
point
;       2B:       8D65F8           LEA ESP,
[EBP-8]
;       2E:       F8
CLC
;       2F:       8B6DFC           MOV EBP,
[EBP-4]
;       32:       C20400           RET
4
;       35:       90
NOP
;       36:       90
NOP
;       37:       90
NOP
;       38:       CC0A             BREAK 10                   ; error
trap
;       3A:       02               BYTE
#X02
;       3B:       18               BYTE #X18                  ;
INVALID-ARG-COUNT-
ERROR
;       3C:       4D               BYTE #X4D                  ;
ECX

How do I figure out what this means?

Thanks..
Deech

From: Edi Weitz
Subject: Re: SBCL Disassemble Function
Date: 
Message-ID: <ud4sxf3uj.fsf@agharta.de>
On Sun, 23 Dec 2007 14:09:30 -0800 (PST), deech <············@gmail.com> wrote:

> How do I read the output from the SBCL disassemble function. I can't
> find the specs online or in the SBCL manual.

DISASSEMBLE is not an SBCL function, it is part of the ANSI Common
Lisp standard:

  http://www.lispworks.com/documentation/HyperSpec/Body/f_disass.htm

The output is obviously implementation-dependent (as the spec says)
and will usually be Assembler code for your specific platform if
you're using a Lisp which compiles to machine code.  It won't make
much sense to you unless you understand the Assembler code for your
CPU and some of the internals of the Lisp you're using.

For SBCL you might want to start here:

  http://sbcl.sourceforge.net/sbcl-internals/
  http://sbcl-internals.cliki.net/index

Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Alex Mizrahi
Subject: Re: SBCL Disassemble Function
Date: 
Message-ID: <476f886d$0$90275$14726298@news.sunsite.dk>
 d> How do I read the output from the SBCL disassemble function. I can't
 d> find the specs online or in the SBCL manual.

first of all, you should know x86 assembly language before starting reading 
disassemblies, do you know it?

consider this example:

(defun add (a b) (declare (optimize speed (safety 0)) (double-float a b)) (+ 
a b))

; 0AF4AF06:       D8C1             FADDD FR1                  ; 
no-arg-parsing entry point
;       08:       9B               WAIT
;       09:       64               FS-SEGMENT-PREFIX
;       0A:       800D4C00000004   OR BYTE PTR [#x4C], 4
;       11:       BA10000000       MOV EDX, 16
;       16:       64               FS-SEGMENT-PREFIX
;       17:       031524000000     ADD EDX, [#x24]
;       1D:       64               FS-SEGMENT-PREFIX
;       1E:       3B1528000000     CMP EDX, [#x28]
;       24:       7607             JBE L0
;       26:       E8117911FD       CALL #x806283C             ; 
alloc_overflow_edx
;       2B:       EB0A             JMP L1
;       2D: L0:   64               FS-SEGMENT-PREFIX
;       2E:       891524000000     MOV [#x24], EDX
;       34:       83EA10           SUB EDX, 16
;       37: L1:   C70216030000     MOV DWORD PTR [EDX], 790
;       3D:       8D5207           LEA EDX, [EDX+7]
;       40:       DD5201           FSTD [EDX+1]
;       43:       64               FS-SEGMENT-PREFIX
;       44:       80354C00000004   XOR BYTE PTR [#x4C], 4
;       4B:       7402             JEQ L2
;       4D:       CC09             BREAK 9                    ; pending 
interrupt trap
;       4F: L2:   8D65F8           LEA ESP, [EBP-8]
;       52:       F8               CLC
;       53:       8B6DFC           MOV EBP, [EBP-4]
;       56:       C20400           RET 4

as you see, operation itself is just first line: FADDD FR1 and later FSTD 
[EDX+1].
the rest of this code implements boxing the result into an object so dynamic 
typing would work, probably you should just ignore this unless you're going 
to improve SBCL's compiler -- just keep in mind that boxing takes a lot of 
time.
From: Juho Snellman
Subject: Re: SBCL Disassemble Function
Date: 
Message-ID: <87prwqpln5.fsf@vasara.proghammer.com>
deech <············@gmail.com> writes:
> How do I read the output from the SBCL disassemble function. I can't
> find the specs online or in the SBCL manual.

Have a look at the SBCL-specific :TRACE-FILE T option to COMPILE-FILE.
If you compile foo.lisp, it will then dump a bunch of information into
foo.trace, including one that shows which intermediate instruction was
responsible for generating each machine instruction. This should help
in figuring out the big picture.

-- 
Juho Snellman