-----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