AMD 250 Computer Hardware User Manual


 
182 Integer Optimizations Chapter 8
25112 Rev. 3.06 September 2005
Software Optimization Guide for AMD64 Processors
shr eax, 30 ; converting it into
lea ebx, [eax+edx*4+1] ; 17.15 fixed-point format
mov ecx, ebx ; such that 1.0 = 2^15.
mov eax, 0xD1B71759 ; 2^15 / 1e4 * 2^30
mul esi ; Divide y2 by 1e4,
shr eax, 30 ; converting it into
lea esi, [eax+edx*4+1] ; 17.15 fixed-point format
mov edx, esi ; such that 1.0 = 2^15.
shr ecx, 15 ; 1st digit
and ebx, 0x00007fff ; Fraction part
OR ecx, '0' ; Convert 1st digit to ASCII.
mov [edi+0], cl ; Store 1st digit in memory.
lea ecx, [ebx+ebx*4] ; 5 * fraction, new digit ECX[31-14]
lea ebx, [ebx+ebx*4] ; 5 * fraction, new fraction EBX[13-0]
shr edx, 15 ; 6th digit
and esi, 0x00007fff ; Fraction part
or edx, '0' ; Convert 6th digit to ASCII.
mov [edi+5], dl ; Store 6th digit in memory.
lea edx, [esi+esi*4] ; 5 * fraction, new digit EDX[31-14]
lea esi, [esi+esi*4] ; 5 * fraction, new fraction ESI[13-0]
shr ecx, 14 ; 2nd digit
and ebx, 0x00003fff ; Fraction part
or ecx, '0' ; Convert 2nd digit to ASCII.
mov [edi+1], cl ; Store 2nd digit in memory.
lea ecx, [ebx+ebx*4] ; 5 *f raction, new digit ECX[31-13]
lea ebx, [ebx+ebx*4] ; 5 * fraction, new fraction EBX[12-0]
shr edx, 14 ; 7th digit
and esi, 0x00003fff ; Fraction part
or edx, '0' ; Convert 7th digit to ASCII.
mov [edi+6], dl ; Store 7th digit in memory.
lea edx, [esi+esi*4] ; 5 * fraction, new digit EDX[31-13]
lea esi, [esi+esi*4] ; 5 * fraction, new fraction ESI[12-0]
shr ecx, 13 ; 3rd digit
and ebx, 0x00001fff ; Fraction part
or ecx, '0' ; Convert 3rd digit to ASCII.
mov [edi+2], cl ; Store 3rd digit in memory.
lea ecx, [ebx+ebx*4] ; 5 * fraction, new digit ECX[31-12]
lea ebx, [ebx+ebx*4] ; 5 * fraction, new fraction EBX[11-0]
shr edx, 13 ; 8th digit
and esi, 0x00001fff ; Fraction part
or edx, '0' ; Convert 8th digit to ASCII.
mov [edi+7], dl ; Store 8th digit in memory.
lea edx, [esi+esi*4] ; 5 * fraction, new digit EDX[31-12]
lea esi, [esi+esi*4] ; 5 * fraction, new fraction ESI[11-0]
shr ecx, 12 ; 4th digit
and ebx, 0x00000fff ; Fraction part
or ecx, '0' ; Convert 4th digit to ASCII.
mov [edi+3], cl ; Store 4th digit in memory.
lea ecx, [ebx+ebx*4] ; 5 * fraction, new digit ECX[31-11]
shr edx, 12 ; 9th digit
and esi, 0x00000fff ; Fraction part