Re: i386 kernel not included?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 23 Oct 2002 14:38:05 -0500, Thomas Dodd wrote:

> >>example
> >>i686                      athlon
> >>movl -24(%edp), %edx      andl -24(%edp), %eax
> >>andl %edx, %eax
> >>
> >>
> >>movl %eax, %edx           imull $100, %eax, %edx
> >>movl %edx, %eax
> > 
> > 
> > Eh? First EDX=EAX, then EAX=EDX? =:-}
> 
> not a clue, but I compile th code
> gcc -march=i386 -mcpu=i686 -S file.c
> 
> and diff'ed againg the output from changing i686 to athlon
> in that same line.
> 
> I don't follow x86 assemble good, but it looked odd to me too.
> Does the rest even do the same thing?

Yes. Both pieces multiply EAX with 100 and store it in EDX. I'm not
so used to GCC's notation, where the '$' prefix is used for decimal
numbers. For the i686, a special integer multiplication algorithm is
used which saves cycles compared with mul/imul. I think it is a
common form of optimization.

i686 (assume the input value is X=eax):

  movl %eax, %edx         ; edx = eax
;  movl %edx, %eax         ; eax = edx
  sall $2, %eax           ; eax = 4*X
  addl %edx, %eax         ; eax = 4*X+X = 5*X
  leal 0(,%eax,4), %edx   ; edx = 4*(5*X)+0 = 20*X
  addl %edx, %eax         ; eax = 5*X + 20*X = 25*X
  leal 0(,%eax,4), %edx   ; edx = 4*(25*X)+0 = 100*X = 100*eax

athlon:

  imull $100, %eax, %edx  ; edx = 100*eax

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE9txMi0iMVcrivHFQRAlE8AJ0a2/ZlfZsYk95cWG7rfrjSSk5L9gCdFjKo
unaLcWIThOvCvWFG93NzYGA=
=61Tt
-----END PGP SIGNATURE-----



-- 
Psyche-list mailing list
Psyche-list@redhat.com
https://listman.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux