assembly

Is there any way to get correct rounding with the i387 fsqrt instruction?

佐手、 提交于 2021-01-27 02:34:32
问题 Is there any way to get correct rounding with the i387 fsqrt instruction?... ... aside from changing the precision mode in the x87 control word - I know that's possible, but it's not a reasonable solution because it has nasty reentrancy-type issues where the precision mode will be wrong if the sqrt operation is interrupted. The issue I'm dealing with is as follows: the x87 fsqrt opcode performs a correctly-rounded (per IEEE 754) square root operation in the precision of the fpu registers,

How to get the gcc compiler to not optimize a standard library function call like printf?

非 Y 不嫁゛ 提交于 2021-01-26 19:28:44
问题 Out of curiosity, I was wondering if there is any way that gcc does not optimize any function calls? In the generated assembly code, the printf function is replaced by putchar. This happens even with the default -O0 minimal optimization flag. #include <stdio.h> int main(void) { printf("a"); return 0; } (Godbolt showing GCC9 doing it, clang8 keeping it unchanged.) 回答1: Use -fno-builtin to disable all replacement and inlining of standard C functions with equivalents. Or use -fno-builtin

How to get the gcc compiler to not optimize a standard library function call like printf?

血红的双手。 提交于 2021-01-26 19:27:25
问题 Out of curiosity, I was wondering if there is any way that gcc does not optimize any function calls? In the generated assembly code, the printf function is replaced by putchar. This happens even with the default -O0 minimal optimization flag. #include <stdio.h> int main(void) { printf("a"); return 0; } (Godbolt showing GCC9 doing it, clang8 keeping it unchanged.) 回答1: Use -fno-builtin to disable all replacement and inlining of standard C functions with equivalents. Or use -fno-builtin

Step into standard library call with godbolt

ε祈祈猫儿з 提交于 2021-01-26 07:40:35
问题 I want to know how various compilers implement std::random_device , so I popped it into godbolt. Unfortunately, the only thing it says is std::random_device::operator()(): push rbp mov rbp, rsp sub rsp, 16 mov QWORD PTR [rbp-8], rdi mov rax, QWORD PTR [rbp-8] mov rdi, rax call std::random_device::_M_getval() leave ret which is not very helpful. How can I step into the _M_getval() call and examine the assembly there? 回答1: You can't "step into" functions; Godbolt isn't a debugger, it's a

OS, Kernel, Applications, and Assembly [closed]

安稳与你 提交于 2021-01-26 02:10:32
问题 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 5 years ago . Improve this question I'm trying to piece together how these four things work together: 1)Assembly is the language which talks directly to hardware, there is no other language between Assembly and voltages on pins. 2)The Kernel of an OS is a set of Assembly functions that the OS

OS, Kernel, Applications, and Assembly [closed]

谁都会走 提交于 2021-01-26 02:09:43
问题 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 5 years ago . Improve this question I'm trying to piece together how these four things work together: 1)Assembly is the language which talks directly to hardware, there is no other language between Assembly and voltages on pins. 2)The Kernel of an OS is a set of Assembly functions that the OS

The x86 disassembly for C code generates: orq $0x0, %(rsp)

我们两清 提交于 2021-01-24 13:30:49
问题 I have written the following C code: It simply allocates an array of 1000000 integers and another integer, and sets the first integer of the array to 0 I compiled this using gcc -g test.c -o test -fno-stack-protector It gives a very weird disassembly: Apparently it keeps allocating 4096 bytes on the stack in a loop, and "or"s every 4096th byte with 0 and then once it reaches 3997696 bytes, it then further allocates 2184 bytes. It then proceeds to set the 4000000th byte (which was never

Bootloader is Not loading the kernel

江枫思渺然 提交于 2021-01-24 10:56:47
问题 I am developing my Operating System. I got error on booting my OS. The error was: KERNEL.BIN not found! Here are the Codes: Boot.asm ; The Aqua_Seven_OS Operating System bootloader ; ================================================================== BITS 16 jmp short bootloader_start ; Jump past disk description section nop ; Pad out before disk description ; ------------------------------------------------------------------ ; Disk description table, to make it a valid floppy ; Note: some of

Square Brackets ? why are these used in LEA?

喜你入骨 提交于 2021-01-24 08:18:13
问题 In assmebly the square brackets seem to have the same meaning as * in C. They are used to dereference a pointer. Dereferencing a pointer means going to refer to a specific memory location to read or write it. So it is quite logical to use square brackets in the case of a MOV. But what is the logical reason why they also use it for LEA. LEA EAX, [EBP -4], looks like dereferencing a pointer, ebp - 4, to refer to the pointed memory location but it will not read the value contained in the

Instruction FYL2XP1

自闭症网瘾萝莉.ら 提交于 2021-01-23 06:33:47
问题 I'm wondering why the instruction FYL2XP1 on x86-architecture computes exactly the mathematical formula y · log 2 ( x + 1). What's special with this formula? 回答1: The y operand is usually a compile time constant, for the moment forget about the x + 1 . Since log_b(x) = log_b(2) * log_2(x) the instruction allows to compute the logarithm in any base of x + 1 . Note that log_b(2) is a constant since it is seldom necessary to compute the logarithm with a degree of freedom in the base. FYL2XP1 and