From: Peter Johnson Date: Sun, 16 Sep 2007 20:41:16 +0000 (-0000) Subject: Add support for IEEE-754r "half precision" (16-bit) float format. X-Git-Tag: v0.6.2~6^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f6c405d98e96d06fb16677c5d0c9ed2c992bcb6;p=yasm Add support for IEEE-754r "half precision" (16-bit) float format. This format is used by SSE5. Update minor tests; more extensive tests will be added soon. svn path=/trunk/yasm/; revision=1954 --- diff --git a/libyasm/floatnum.c b/libyasm/floatnum.c index 951e17ca..a7cfcb7e 100644 --- a/libyasm/floatnum.c +++ b/libyasm/floatnum.c @@ -631,7 +631,17 @@ floatnum_get_common(const yasm_floatnum *flt, /*@out@*/ unsigned char *ptr, return retval; } -/* IEEE-754 (Intel) "single precision" format: +/* IEEE-754r "half precision" format: + * 16 bits: + * 15 9 Bit 0 + * | | | + * seee eemm mmmm mmmm + * + * e = bias 15 exponent + * s = sign bit + * m = mantissa bits, bit 10 is an implied one bit. + * + * IEEE-754 (Intel) "single precision" format: * 32 bits: * Bit 31 Bit 22 Bit 0 * | | | @@ -672,6 +682,9 @@ yasm_floatnum_get_sized(const yasm_floatnum *flt, unsigned char *ptr, yasm_internal_error(N_("unsupported floatnum functionality")); } switch (destsize) { + case 2: + retval = floatnum_get_common(flt, ptr, 2, 10, 1, 5); + break; case 4: retval = floatnum_get_common(flt, ptr, 4, 23, 1, 8); break; @@ -702,6 +715,7 @@ int yasm_floatnum_check_size(/*@unused@*/ const yasm_floatnum *flt, size_t size) { switch (size) { + case 16: case 32: case 64: case 80: diff --git a/modules/objfmts/bin/tests/float-err.asm b/modules/objfmts/bin/tests/float-err.asm index 56a766c2..7c608ba0 100644 --- a/modules/objfmts/bin/tests/float-err.asm +++ b/modules/objfmts/bin/tests/float-err.asm @@ -1,6 +1,6 @@ ; Tests illegal float handling db 1.2 -dw 3.14 +dw 3.14e500 dd 5.12e100000 dq 3.141592653589793e-158105 dt 5653894745.318293470142875104710284019245e-1999 diff --git a/modules/objfmts/bin/tests/float-err.errwarn b/modules/objfmts/bin/tests/float-err.errwarn index 3efe445d..33fcebec 100644 --- a/modules/objfmts/bin/tests/float-err.errwarn +++ b/modules/objfmts/bin/tests/float-err.errwarn @@ -1,8 +1,8 @@ -:2: invalid floating point constant size --:3: invalid floating point constant size +-:3: warning: overflow in floating point expression -:4: warning: overflow in floating point expression -:5: warning: underflow in floating point expression -:8: invalid floating point constant size --:9: invalid floating point constant size +-:9: warning: overflow in floating point expression -:11: warning: overflow in floating point expression -:12: warning: underflow in floating point expression diff --git a/modules/objfmts/bin/tests/float.asm b/modules/objfmts/bin/tests/float.asm index a2823f35..32d2777b 100644 --- a/modules/objfmts/bin/tests/float.asm +++ b/modules/objfmts/bin/tests/float.asm @@ -1,8 +1,10 @@ ; Tests float handling +dw 3.14 dd 5.12 dq 3.141592653589793 dt 5653894745.318293470142875104710284019245e335 +dw -62000.0 dd -47102940.467103581 dq -45102571092751092341095.5827509174509178450917845019 dt -1.e-1000 diff --git a/modules/objfmts/bin/tests/float.hex b/modules/objfmts/bin/tests/float.hex index 066fa76e..33b0d978 100644 --- a/modules/objfmts/bin/tests/float.hex +++ b/modules/objfmts/bin/tests/float.hex @@ -1,3 +1,5 @@ +48 +42 0a d7 a3 @@ -20,6 +22,8 @@ f1 97 78 44 +92 +fb f7 ae 33