x87

Objdump swapping fsubrp to fsubp on compiled assembly?

二次信任 提交于 2019-12-13 13:41:43
问题 I am porting Quake 2's inline Win32 assembly to GAS. I started out by taking the inline assembly and then placing it into it's own ASM file. Fixed any issues, then started porting to GAS. I do know that the src/dst is reversed in AT&T vs Intel syntax (including floating point registers for some math operations) and a few other small gotchas, but when I got this compiling fine I noticed that the code was not working as intended. I looked over it carefully for hours with a compare utility and

SSE FPU parallel

混江龙づ霸主 提交于 2019-12-12 20:25:13
问题 I was wondering if it would be possible to use SSE in parallel with x87. So consider the following pseudo code, 1: sse_insn 2: x87_insn Would the pipeline execute 1 and 2 in parallel assuming they can be executed in parallel? 回答1: In all modern (and older) processors, the x87 and SSE instructions use the same execution units, so it's UNLIKELY that you will benefit much from this sort of code. There may be very special cases where you can trick the processor into running for example a x87

fstcw assembly operand type mismatch

浪子不回头ぞ 提交于 2019-12-11 20:07:29
问题 I'm trying to round an input double using a specified rounding mode in in-line assembly in C. To do so, I need to grab the FPU control word using "fstcw" and then change the bits in the word. Unfortunately I'm encountering an error on the very first line: double roundD(double n, RoundingMode roundingMode) { asm("fstcw %%ax \n" ::: "ax"); //clobbers return n; } The assembler error I receive is: "Error: operand type mismatch for 'fstcw'." I'm under the impression this code snippet should store

Should fxam work for single precision floating point values?

扶醉桌前 提交于 2019-12-11 13:57:50
问题 This question arose from Why is isnormal() saying a value is normal when it isn't? A C compiler generates the following code which is supposed to detect if the 32-bit float passed in is Normal or not: flds 24(%esp) fxam; fstsw %ax; andw $17664, %ax cmpw $1024, %ax sete %al (full code can be viewed here). Is this code correct? The program appears to behave incorrectly, saying a number is Normal when it isn't. We think that perhaps the number is being checked for double-precision normality here

call function with float in assembly x86 x87

♀尐吖头ヾ 提交于 2019-12-11 12:12:52
问题 I'm new to assembly programming and, as a part of a bigger program I have need to pass floating point values to another C-function. I have a call from my test program to my assembly function, that only pushes the parameters on the right stack, and calls a second C function. My C test function: extern void ext_func(char *result, double d); // C function extern double tester(char *str, float d); double a = tester(str, 3.14) printf("%s\n", str); // Resulting in '0.000000' // doing some fancy

use of FFREE and FDECSTP

狂风中的少年 提交于 2019-12-11 05:56:59
问题 I cannot understand this things: what is the use of such commands (FFREE, FDECSTP)? Can it ve used to pop value out of the fpu stack, or this is for some another purpose? I dont get it :/ Could someone explain that, tnx 回答1: Yes, using FFREE , FINCSTP and FDECSTP you can manage the FPU stack manually. Note that FPU stack grows down similar to the CPU stack, so to remove (pop) something you mark the register as free and increment the stack pointer. You won't see these instructions in typical

floating point instruction anomaly — FLDZ malfunctioning?

你说的曾经没有我的故事 提交于 2019-12-10 19:05:04
问题 I am trying to debug the problem I posted earlier here: C++ and pin tool -- very weird DOUBLE variable issue with IF statement. I tracked down the moment when the weird behavior occurred using gdb. What I found is shown in the figure below that shows the gdb screenshot displaying the disassembled code and floating pointer register values. (larger image here) Left-hand side image shows the screenshot before the highlighted FLDZ instruction is executed and the right-hand side image is after the

Using FPU with C inline assembly

老子叫甜甜 提交于 2019-12-07 13:38:34
问题 I wrote a vector structure like this: struct vector { float x1, x2, x3, x4; }; Then I created a function which does some operations with inline assembly using the vector: struct vector *adding(const struct vector v1[], const struct vector v2[], int size) { struct vector vec[size]; int i; for(i = 0; i < size; i++) { asm( "FLDL %4 \n" //v1.x1 "FADDL %8 \n" //v2.x1 "FSTL %0 \n" "FLDL %5 \n" //v1.x2 "FADDL %9 \n" //v2.x2 "FSTL %1 \n" "FLDL %6 \n" //v1.x3 "FADDL %10 \n" //v2.x3 "FSTL %2 \n" "FLDL

Add a constant value to a xmm register in x86

穿精又带淫゛_ 提交于 2019-12-07 12:02:51
问题 How would I add 1 or 2 to the register xmm0 (double)? I can do it like this, but sure there must be an easier way: movsd xmm0, [ecx] xor eax, eax inc eax cvtsi2sd xmm1, eax addsd xmm0, xmm1 movsd [ecx], xmm0 Also would it be possible to do this with the floating point x87 instructions? This doesn't work for me: fld dword ptr [ecx] fld1 faddp fstp dword ptr [ecx] 回答1: You can keep a constant in memory or in another register: _1 dq 1.0 and addsd xmm1,[_1] or movsd xmm0,[_1] addsd xmm1,xmm0 If

Adding floating point/double numbers in assembly

好久不见. 提交于 2019-12-07 01:57:13
问题 I am trying to experiment with inline assembly, and I am trying to add decimal numbers (no, NOT integers) in inline assembly. Issue is, when I call the following function: inline double ADD(double num1, double num2) { double res; _asm{ push eax; push the former state of eax onto stack mov eax, num1; add eax, num2; mov res, eax; pop eax; restore the former state of eax now that we are done } return res;} The compiler complains of improper operand size at the inline assembly (ALL lines of