x87

Which bits in the x87 tag word does FFREE ST(i) modify?

蹲街弑〆低调 提交于 2019-12-01 23:03:47
This example was written in NASM: section .bss var28: resb 28 section .text _main: ; Initialize finit fldpi ; Read Tag Word fstenv [var28] mov ax, [var28 + 8] ; move the Tag Word to ax At this point ax = 0011 1111 1111 1111, which means ST7 = 00 (valid), and the rest is 11 (empty). The rest of the code: ; FFREE ST(i) ffree ST7 ; Sets tag for ST(i) to empty. ; Read Tag Word fstenv [var28] mov ax, [var28 + 8] ; move the Tag Word to ax At this point ax = 0011 1111 1111 1111 too. My question is, shouldn't be ax = 11 11 1111 1111 1111? At this point ax = 0011 1111 1111 1111, which means ST7 = 00

Are there unsigned equivalents of the x87 FILD and SSE CVTSI2SD instructions?

我只是一个虾纸丫 提交于 2019-12-01 18:19:45
I want to implement the equivalent of C's uint -to- double cast in the GHC Haskell compiler. We already implement int -to- double using FILD or CVTSI2SD . Is there unsigned versions of these operations or am I supposed to zero out the highest bit of the uint before the conversion (thus losing range)? You can exploit some of the properties of the IEEE double format and interpret the unsigned value as part of the mantissa, while adding some carefully crafted exponent. Bits 63 62-52 51-0 S Exp Mantissa 0 1075 20 bits 0, followed by your unsigned int The 1075 comes from the IEEE exponent bias

Finding the “discrete” difference between close floating point numbers

孤街醉人 提交于 2019-11-30 23:02:23
Suppose I have two floating point numbers, x and y , with their values being very close. There's a discrete number of floating point numbers representable on a computer, so we can enumerate them in increasing order: f_1, f_2, f_3, ... . I wish to find the distance of x and y in this list (i.e. are they 1, 2, 3, ... or n discrete steps apart?) Is it possible to do this by only using arithmetic operations ( +-*/ ), and not looking at the binary representation? I'm primarily interested in how this works on x86. Is the following approximation correct, assuming that y > x and that x and y are only

Finding the “discrete” difference between close floating point numbers

孤人 提交于 2019-11-30 18:17:20
问题 Suppose I have two floating point numbers, x and y , with their values being very close. There's a discrete number of floating point numbers representable on a computer, so we can enumerate them in increasing order: f_1, f_2, f_3, ... . I wish to find the distance of x and y in this list (i.e. are they 1, 2, 3, ... or n discrete steps apart?) Is it possible to do this by only using arithmetic operations ( +-*/ ), and not looking at the binary representation? I'm primarily interested in how

Memory corruption in System.Move due to changed 8087CW mode (png + stretchblt)

让人想犯罪 __ 提交于 2019-11-30 12:58:23
问题 I have strange a memory corruption problem. After many hours debugging and trying I think I found something. For example: I do a simple string assignment: sTest := 'SET LOCK_TIMEOUT '; However, the result sometimes becomes: sTest = 'SET LOCK'#0'TIMEOUT ' So, the _ gets replaced by an 0 byte. I have seen this happening once (reproducing is tricky, dependent on timing) in the System.Move function, when it uses the FPU stack (fild, fistp) for fast memory copy (in case of 9 till 32 bytes to move)

Memory corruption in System.Move due to changed 8087CW mode (png + stretchblt)

早过忘川 提交于 2019-11-30 04:39:42
I have strange a memory corruption problem. After many hours debugging and trying I think I found something. For example: I do a simple string assignment: sTest := 'SET LOCK_TIMEOUT '; However, the result sometimes becomes: sTest = 'SET LOCK'#0'TIMEOUT ' So, the _ gets replaced by an 0 byte. I have seen this happening once (reproducing is tricky, dependent on timing) in the System.Move function, when it uses the FPU stack (fild, fistp) for fast memory copy (in case of 9 till 32 bytes to move): ... @@SmallMove: {9..32 Byte Move} fild qword ptr [eax+ecx] {Load Last 8} fild qword ptr [eax] {Load

How do I specify immediate floating point numbers with inline assembly?

半世苍凉 提交于 2019-11-28 11:11:28
When I try to compile this code: #include <stdio.h> main(int argc, char *argv[]) { double y = 0; __asm__ ("fldl $150;" "fsqrt;" "fstl %0;" : : "g" (y) ); printf("%f\n", y); return 0; } I get this error: sqrt.c: Assembler messages: sqrt.c:6: Error: suffix or operands invalid for `fld' Why doesn't this work? Why can't I push the number "150" onto the stack for floating point operations? I do not know of an assembly language which supports literal floating point constants for immediate use. The usual means is to declare initialized storage containing the floating point constant and referencing it

Usefulness of signaling NaN?

喜欢而已 提交于 2019-11-27 18:28:14
I've recently read up quite a bit on IEEE 754 and the x87 architecture. I was thinking of using NaN as a "missing value" in some numeric calculation code I'm working on, and I was hoping that using signaling NaN would allow me to catch a floating point exception in the cases where I don't want to proceed with "missing values." Conversely, I would use quiet NaN to allow the "missing value" to propagate through a computation. However, signaling NaNs don't work as I thought they would based on the (very limited) documentation that exists on them. Here is a summary of what I know (all of this

How do I specify immediate floating point numbers with inline assembly?

偶尔善良 提交于 2019-11-27 06:09:36
问题 When I try to compile this code: #include <stdio.h> main(int argc, char *argv[]) { double y = 0; __asm__ ("fldl $150;" "fsqrt;" "fstl %0;" : : "g" (y) ); printf("%f\n", y); return 0; } I get this error: sqrt.c: Assembler messages: sqrt.c:6: Error: suffix or operands invalid for `fld' Why doesn't this work? Why can't I push the number "150" onto the stack for floating point operations? 回答1: I do not know of an assembly language which supports literal floating point constants for immediate use.

Is SSE floating-point arithmetic reproducible?

此生再无相见时 提交于 2019-11-27 04:33:23
The x87 FPU is notable for using an internal 80-bit precision mode, which often leads to unexpected and unreproducible results across compilers and machines. In my search for reproducible floating-point math on .NET, I discovered that both major implementations of .NET (Microsoft's and Mono) emit SSE instructions rather than x87 in 64-bit mode. SSE(2) uses strictly 32-bit registers for 32-bit floats, and strictly 64-bit registers for 64-bit floats. Denormals can optionally be flushed to zero by setting the appropriate control word . It would therefore appear that SSE does not suffer from the