From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/653 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: correctly rounded sqrt Date: Thu, 15 Mar 2012 01:07:48 -0400 Message-ID: <20120315050748.GC184@brightrain.aerifal.cx> References: <20120314165604.GF5728@port70.net> <20120314190123.GH5728@port70.net> <20120315014647.GI5728@port70.net> <20120315032304.GJ5728@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Yylu36WmvOXNoKYn" X-Trace: dough.gmane.org 1331788072 5481 80.91.229.3 (15 Mar 2012 05:07:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 15 Mar 2012 05:07:52 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-654-gllmg-musl=m.gmane.org@lists.openwall.com Thu Mar 15 06:07:51 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1S82ue-0004LE-PO for gllmg-musl@plane.gmane.org; Thu, 15 Mar 2012 06:07:44 +0100 Original-Received: (qmail 30525 invoked by uid 550); 15 Mar 2012 05:07:44 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 30517 invoked from network); 15 Mar 2012 05:07:44 -0000 Content-Disposition: inline In-Reply-To: <20120315032304.GJ5728@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:653 Archived-At: --Yylu36WmvOXNoKYn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Mar 15, 2012 at 04:23:04AM +0100, Szabolcs Nagy wrote: > but now that we figured out the fpu status register based > solution this does not matter.. Here's the asm version based on fpu status word. I'm not sure if it's safe for non-default rounding modes but otherwise it should be correct. Rich --Yylu36WmvOXNoKYn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sqrt.s" .global sqrt .type sqrt,@function sqrt: fldl 4(%esp) fsqrt fstsw %ax sub $12,%esp fld %st(0) fstpt (%esp) mov (%esp),%ecx and $0x7ff,%ecx cmp $0x400,%ecx jnz 1f and $0x200,%eax sub $0x100,%eax sub %eax,(%esp) fstp %st(0) fldt (%esp) 1: add $12,%esp fstpl 4(%esp) fldl 4(%esp) ret --Yylu36WmvOXNoKYn--