[Discuss] Disassembled code

dmg dmg at uvic.ca
Tue Jun 26 13:31:21 PDT 2007


For those who can still read assembly.

Here is the disassembled code, with the addresses replaced with
symbolic names. The two sequences of instructions are identical,
except for the fstpl and fldl (to and from temp).

I can only think that these instructions reset the FPU registers, but
I can't find their description on the web any more :(

dmg


----------------------------------------------------------------------


rip.o:     file format elf32-i386

Disassembly of section .text:

00000000 <main>:
main():
/tmp/rip.c:5
#include <stdio.h>
#include <math.h>
x        0xffffffd0(%ebp)
xscale   0xffffffd8(%ebp)
y        0xffffffe0(%ebp)       
temp     0xffffffe8(%ebp)
greater  0xfffffff4(%ebp)
int main(void) 
{
   0:	8d 4c 24 04          	lea    0x4(%esp),%ecx
   4:	83 e4 f0             	and    $0xfffffff0,%esp
   7:	ff 71 fc             	pushl  0xfffffffc(%ecx)
   a:	55                   	push   %ebp
   b:	89 e5                	mov    %esp,%ebp
   d:	51                   	push   %ecx
   e:	83 ec 54             	sub    $0x54,%esp
/tmp/rip.c:6
   double x=1.e-200, xscale=1.e+250;
  11:	dd 05 40 00 00 00    	fldl   0x40
  17:	dd 5d d0             	fstpl  x
  1a:	dd 05 48 00 00 00    	fldl   0x48
  20:	dd 5d d8             	fstpl  xscale
/tmp/rip.c:10
   double y;
   double temp;
   int greater;
   printf("%15.5e %15.5e %15.5e \n", x, xscale, x/xscale);
  23:	dd 45 d0             	fldl   x
  26:	dc 75 d8             	fdivl  xscale
  29:	dd 5c 24 14          	fstpl  0x14(%esp)
  2d:	dd 45 d8             	fldl   xscale
  30:	dd 5c 24 0c          	fstpl  0xc(%esp)
  34:	dd 45 d0             	fldl   x
  37:	dd 5c 24 04          	fstpl  0x4(%esp)
  3b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  42:	e8 fc ff ff ff       	call   43 <main+0x43>
/tmp/rip.c:12

   greater = x/xscale > 0.e0;
  47:	dd 45 d0             	fldl   x
  4a:	dc 75 d8             	fdivl  xscale
  4d:	d9 ee                	fldz   
  4f:	d9 c9                	fxch   %st(1)
  51:	da e9                	fucompp 
  53:	df e0                	fnstsw %ax
  55:	9e                   	sahf   
  56:	0f 97 c0             	seta   %al
  59:	0f b6 c0             	movzbl %al,%eax
  5c:	89 45 f4             	mov    %eax,greater
/tmp/rip.c:13
   printf("1>%5i  \n", greater);
  5f:	8b 45 f4             	mov    greater,%eax
  62:	89 44 24 04          	mov    %eax,0x4(%esp)
  66:	c7 04 24 17 00 00 00 	movl   $0x17,(%esp)
  6d:	e8 fc ff ff ff       	call   6e <main+0x6e>
/tmp/rip.c:14
   temp = x/xscale;
  72:	dd 45 d0             	fldl   x
  75:	dc 75 d8             	fdivl  xscale
  78:	dd 5d e8             	fstpl  temp
/tmp/rip.c:15
   greater = temp > 0.e0;
  7b:	dd 45 e8             	fldl   temp
  7e:	d9 ee                	fldz   
  80:	d9 c9                	fxch   %st(1)
  82:	da e9                	fucompp 
  84:	df e0                	fnstsw %ax
  86:	9e                   	sahf   
  87:	0f 97 c0             	seta   %al
  8a:	0f b6 c0             	movzbl %al,%eax
  8d:	89 45 f4             	mov    %eax,greater
/tmp/rip.c:16
   printf("2>%5i  \n", greater);
  90:	8b 45 f4             	mov    greater,%eax
  93:	89 44 24 04          	mov    %eax,0x4(%esp)
  97:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  9e:	e8 fc ff ff ff       	call   9f <main+0x9f>
/tmp/rip.c:19


   greater = x/xscale > 1.e-305;
  a3:	dd 45 d0             	fldl   x
  a6:	dc 75 d8             	fdivl  xscale
  a9:	dd 05 50 00 00 00    	fldl   0x50
  af:	d9 c9                	fxch   %st(1)
  b1:	da e9                	fucompp 
  b3:	df e0                	fnstsw %ax
  b5:	9e                   	sahf   
  b6:	0f 97 c0             	seta   %al
  b9:	0f b6 c0             	movzbl %al,%eax
  bc:	89 45 f4             	mov    %eax,greater
/tmp/rip.c:20
   printf("%5i  \n", greater);
  bf:	8b 45 f4             	mov    greater,%eax
  c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  c6:	c7 04 24 29 00 00 00 	movl   $0x29,(%esp)
  cd:	e8 fc ff ff ff       	call   ce <main+0xce>
/tmp/rip.c:21
   y = log(x/xscale);
  d2:	dd 45 d0             	fldl   x
  d5:	dc 75 d8             	fdivl  xscale
  d8:	dd 1c 24             	fstpl  (%esp)
  db:	e8 fc ff ff ff       	call   dc <main+0xdc>
  e0:	dd 5d e0             	fstpl  y
/tmp/rip.c:22
   printf("%15.5e \n", y);
  e3:	dd 45 e0             	fldl   y
  e6:	dd 5c 24 04          	fstpl  0x4(%esp)
  ea:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  f1:	e8 fc ff ff ff       	call   f2 <main+0xf2>
/tmp/rip.c:24

   return(0);
  f6:	b8 00 00 00 00       	mov    $0x0,%eax
/tmp/rip.c:25
}
  fb:	83 c4 54             	add    $0x54,%esp
  fe:	59                   	pop    %ecx
  ff:	5d                   	pop    %ebp
 100:	8d 61 fc             	lea    0xfffffffc(%ecx),%esp
 103:	c3                   	ret    



--
Daniel M. German                  "Any sufficiently advanced
                                   technology is indistinguishable
   Arthur C. Clarke ->             from magic."
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .

 


More information about the Discuss mailing list