From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c12j2-0004Aj-R2 for qemu-devel@nongnu.org; Sun, 30 Oct 2016 22:53:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c12j1-0005zz-Hx for qemu-devel@nongnu.org; Sun, 30 Oct 2016 22:53:28 -0400 Date: Mon, 31 Oct 2016 13:50:37 +1100 From: David Gibson Message-ID: <20161031025037.GI18226@umbus.fritz.box> References: <1477487938-23921-1-git-send-email-joserz@linux.vnet.ibm.com> <1477487938-23921-5-git-send-email-joserz@linux.vnet.ibm.com> <20161027014734.GD19918@umbus.fritz.box> <20161027200820.GE19890@pacoca> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="STPqjqpCrtky8aYs" Content-Disposition: inline In-Reply-To: <20161027200820.GE19890@pacoca> Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH] 4/4] target-ppc: Implement bcdctz. instruction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: joserz@linux.vnet.ibm.com Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, bharata@linux.vnet.ibm.com --STPqjqpCrtky8aYs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 27, 2016 at 06:08:20PM -0200, joserz@linux.vnet.ibm.com wrote: > On Thu, Oct 27, 2016 at 12:47:34PM +1100, David Gibson wrote: > > On Wed, Oct 26, 2016 at 11:18:58AM -0200, Jose Ricardo Ziviani wrote: > > > bcdctz. converts from BCD to Zoned numeric format. Zoned format uses > > > a byte to represent a digit where the most significant nibble is 0x3 > > > or 0xf, depending on the preferred signal. > > >=20 > > > Signed-off-by: Jose Ricardo Ziviani > > > --- > > > target-ppc/helper.h | 1 + > > > target-ppc/int_helper.c | 54 +++++++++++++++++++++++++++= ++++++++++ > > > target-ppc/translate/vmx-impl.inc.c | 7 +++-- > > > 3 files changed, 60 insertions(+), 2 deletions(-) > > >=20 > > > diff --git a/target-ppc/helper.h b/target-ppc/helper.h > > > index f460635..3b928b8 100644 > > > --- a/target-ppc/helper.h > > > +++ b/target-ppc/helper.h > > > @@ -372,6 +372,7 @@ DEF_HELPER_4(bcdsub, i32, avr, avr, avr, i32) > > > DEF_HELPER_3(bcdcfn, i32, avr, avr, i32) > > > DEF_HELPER_2(bcdctn, i32, avr, avr) > > > DEF_HELPER_3(bcdcfz, i32, avr, avr, i32) > > > +DEF_HELPER_3(bcdctz, i32, avr, avr, i32) > > > =20 > > > DEF_HELPER_2(xsadddp, void, env, i32) > > > DEF_HELPER_2(xssubdp, void, env, i32) > > > diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c > > > index 8cbbdfc..e0a84bb 100644 > > > --- a/target-ppc/int_helper.c > > > +++ b/target-ppc/int_helper.c > > > @@ -2768,6 +2768,60 @@ uint32_t helper_bcdcfz(ppc_avr_t *r, ppc_avr_t= *b, uint32_t ps) > > > *r =3D ret; > > > return cr; > > > } > > > + > > > +uint32_t helper_bcdctz(ppc_avr_t *r, ppc_avr_t *b, uint32_t ps) > > > +{ > > > + int i; > > > + int j; > > > + int cr =3D 0; > > > + int invalid =3D 0; > > > + uint8_t digit =3D 0; > > > + int sgnb =3D bcd_get_sgn(b); > > > + int zone_lead =3D (ps) ? 0xF0 : 0x30; > > > + ppc_avr_t ret =3D { .u64 =3D { 0, 0 } }; > > > + > > > + int eq_flag =3D (b->u64[HI_IDX] =3D=3D 0) && ((b->u64[LO_IDX] >>= 4) =3D=3D 0); > > > + int ox_flag =3D (b->u64[HI_IDX] !=3D 0); > >=20 > > This doesn't look right. The zoned format can accomodate 16 digits. > > The low word of the packed format can accomodate 15 digits + sign. So > > it should be possible to convert a packed for with a value in the low > > nibble of the upper word. >=20 > David, it seems that zoned format can accommodate 15 digits + sign > at most. Suppose I have this 16 bytes zoned number: > f9f9f9f9f9f9f9f9f9f9f9f9f9f9f9xx. Converting it to packed bcd will > give 999999999999999x. Do you agree? can I keep that ox_flag logic? Uh.. no. AFAICT from the description of the instruction the last byte of a zoned number contains *both* a sign nibble *and* the least significant digit of the number. So zoned format can represent 16 digits + sign. But IIRC you changed this in v2, so maybe you realised that already. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --STPqjqpCrtky8aYs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJYFrF7AAoJEGw4ysog2bOS/GEQAOH6B8PpExIVDtcMmGJYfcLh 3M2czN0nuRElZtDY4WibS+W6/rKEta0IZ7AUg/LpORaldxbHRISne9TY4VI4lzqF lL64mwyZYhHThMoKvfGKko8/6xfCYeE4glWiA+ANMtdPry/RJiaEQBEEHwWHjnmP MJB+tbcNpSnBJPExPPr2UNxVqANHeZN1kTEdb+7eA8LXJQUHKQUnXPy9lyZeeDCe mR4y3H9lpQqLcxZKKzn/qQSmv6KTCabyHWNDgIQUcyyALORN6bVNuj5CaYD566Ke pe91J0NmJdN3Rq1+ATN/oLsrc2RDowBswm1DQ5nifJsHf0++ZtgIMB5PwtwbDh3m agJErpDhhlUqMauURwO3bTb0EGzT1FtLB8W5uf/Z/Kbj81dE10pWtT20GcimDmb5 jJOKI89eM0zZXG0TovyEsENVN2hGWOfgFw1SJcsZilAzu2w1DDOlj6Novw8GrPN9 PHetjHgFgzG7nFE1Qc6rYxprSZAr3qFV/eTRM9RUpy6tSq6D6iJP1Yp9Pf6Jmpv7 7eAGl0U1Bv5wMoFI63le3imiDfVHyAIUjGN+Dx2+5VVQ4JofP9STStq51e/nY8jY WED/tahdgKWxZwAPkOEX3F9GnKVAILOlRVwKNjdsrtVLWe0CqlkrT1Uw7bsvmm7z UhZoomcq0tuBQ23WsZ3a =hfeo -----END PGP SIGNATURE----- --STPqjqpCrtky8aYs--