fpu

Assembly: JA and JB work incorrectly

若如初见. 提交于 2021-01-29 02:45:27
问题 Since my main OS is linux and have project on visual studio, I decided to use online compilers to achieve it. I found this which was suggested by many. So here is my code: #include <iostream> using namespace std; int main(void) { float a = 1; float b = 20.2; float res = 0; float res1 = 0; _asm { FLD a FCOM b JA midi JMP modi midi: FST res JMP OUT modi: FST res1 JMP OUT } OUT: cout << "res = " << res << endl; cout << "res1 = " << res1 << endl; return 0; } My goal is simple, if a is greater

Print FPU registers in lldb

旧城冷巷雨未停 提交于 2021-01-28 02:06:38
问题 How do you print FPU registers using lldb? In gdb, you would do something like p $st0 , however doing the same in lldb results in the error: error: use of undeclared identifier '$st0' . register read st0 doesn't work either and gives the error error: Invalid register name 'st0'. . 回答1: By using register read --all as suggested by paulsm4 , I found that the name of the registers are actually stmm0 to stmm7 and not st0 to st7 . So doing register read stmm0 --format b will get you the binary

How to move ST(0) to EAX?

自作多情 提交于 2020-07-18 06:38:52
问题 Hullo, I am learning x86 FPU assembly, and I have got a simple question I cannot find answer for: How to move value from ST(0) ( top of the FPU stack ) to EAX ? also: is this code correct: ; multiply (dot) two vectors of 3 floats passed by pointers as arg 1 arg 2 ; passings are ok I think, but not sure if multiplies-adds are ok push ebp mov ebp, esp mov eax, dword [ebp+8H] mov edx, dword [ebp+0CH] fld qword [eax] fmul qword [edx] fld qword [eax+4H] fmul qword [edx+4H] fld qword [eax+8H] fmul

How to write a several values on the screen using C printf function?

梦想与她 提交于 2020-05-24 05:34:12
问题 I have a program that counts root of quadratic equation. And I have a problem with printing the results on the screen, because I can print only one value. This is my code below, could you please tell me what should I do to pass two result to expression "x1 = ... ". [bits 32] call getaddr format db "x1 = %lf, x2 = %lf", 0xA, 0 offset equ $ - format a dq 1.0 ; b dq -11.0 c dq 28.0 minusfour dq -4.0 getaddr: finit mov eax, [esp] lea eax, [eax+offset] ; eax = a mov edx, [esp] lea edx, [edx+offset

How are floating point operations emulated in software? [closed]

故事扮演 提交于 2020-01-20 07:04:26
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . How does software perform floating point arithmetic when the CPU has no (or buggy) floating point unit? Examples would be the PIC, AVR, and 8051 microcontrollers architectures. 回答1: "Emulated" is the wrong term in the context of PIC, AVR and 8051. Floating-point emulation refers

What algorithms do FPUs use to compute transcendental functions?

帅比萌擦擦* 提交于 2020-01-13 09:01:07
问题 What methods would a modern FPU use to compute transcendental functions? For example, Intel CPUs provide instructions such as FSIN , FCOS , FYL2X , etc. I am curious as to what algorithms would be used to actually implement these in hardware. My naïve guess would be Taylor series perhaps combined with some lookup tables, but that's nothing more than a wild guess. Please enlighten me. P.S. This question is more general than just Intel hardware. 回答1: One place to start could be "New Algorithms

How to clear stack in masm32 coprocessor (FPU)?

风格不统一 提交于 2020-01-06 19:55:22
问题 Doing some operations in masm32 FPU . But I'm not able to clear the stack of FPU e.g. ST(0)-ST(7) afterwards. Is there any instruction for stack clearing. Can you suggest anything? P.S. Suppose to clear stack for further calculation. 回答1: You can use FINIT which initializes the FPU and tags the data registers ST(0)-ST(7) as empty (it does not clear their contents though) 来源: https://stackoverflow.com/questions/34840658/how-to-clear-stack-in-masm32-coprocessor-fpu

Floating point calculations in a processor with no FPU

别说谁变了你拦得住时间么 提交于 2020-01-03 15:17:28
问题 Is it possible to perform floating point operations in an embedded processor that does not have a Floating Point Unit? 回答1: Yes, you just have to do it in software. Your compiler may provide support, or you may need to roll your own. There are freely-available implementations, too. 回答2: Yes, e.g. early Linux kernels did emulate i387 floating point instructions in the kernel. It was rather slow, but allowed you to use the same binary on computers with and without a floating point unit. 来源:

FLD floating-point instruction

╄→гoц情女王★ 提交于 2019-12-31 05:44:19
问题 According to http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH14/CH14-4.html#HEADING4-5 14.4.4.1 The FLD Instruction fld mem_32 fld mem_64[bx] My objective is store a constant 10 into my fPU stack. Why I cant do this? __asm { move bx, 0x0004; fld dword ptr[bx] or fld bx; //------- fld 0x004; //Since it is 32 bits? fild 0x004; } 回答1: At least three things can go wrong here. One is the syntax of the assembler. The second is instruction set architecture. The third is the memory model (16 bit vs 32