x86

Order of variable declaration in asm x86?

試著忘記壹切 提交于 2021-01-27 05:42:14
问题 Here the piece of code : int main() { char buffer[64]; int check; ... As you can see, check is declared AFTER buffer , so in the stack, we must have check ABOVE buffer in the stack right? However, when I disassembly (x86) it with gdb, this is what I got : --> check at 0xbffff4f8 --> buffer at 0xbffff4b8 My question : is there a specific order in the stack for local variable? Also, I have to tell you that I tried the same thing on another computer (x86 too, same gcc compilation options, but

Why doesn't Ice Lake have MOVDIRx like tremont? Do they already have better ones?

杀马特。学长 韩版系。学妹 提交于 2021-01-27 04:46:49
问题 I notice that Intel Tremont has 64 bytes store instructions with MOVDIRI and MOVDIR64B. Those guarantees atomic write to memory, whereas don't guarantee the load atomicity. Moreover, the write is weakly ordered, immediately followed fencing may be needed. I find no MOVDIRx in IceLake. Why doesn't Ice Lake need such instructions like MOVDIRx ? (At the bottom of page 15) Intel® ArchitectureInstruction Set Extensions and Future FeaturesProgramming Reference https://software.intel.com/sites

Difference between MOV r/m8,r8 and MOV r8,r/m8

荒凉一梦 提交于 2021-01-27 04:39:44
问题 By looking at intel volume of instructions, I found this: 1) 88 /r MOV r/m8,r8 2) 8A /r MOV r8,r/m8 When I write a line like this in NASM, and assemble it with the listing option: mov al, bl I get this in the listing: 88D8 mov al, bl So obviously NASM chosed the first instruction of the two above, but isn't the second instruction an option two? if so, on what basis did NASM chosed the first? 回答1: These two encodings exist because a modr/m byte can only encode one memory operand. So to allow

Using rdmsr/rdpmc for branch prediction accuracy

我与影子孤独终老i 提交于 2021-01-27 04:21:27
问题 I am trying to understand how does a branch prediction unit work in a CPU. I have used papi and also linux's perf-events but both of them do not give accurate results (for my case). This is my code: void func(int* arr, int sequence_len){ for(int i = 0; i < sequence_len; i++){ // region starts if(arr[i]){ do_sth(); } // region ends } } My array consists of 0's and 1's. It has a pattern with a size of sequence_len . For example, if my size is 8, then it has a pattern of 0 1 0 1 0 0 1 1 or

Using rdmsr/rdpmc for branch prediction accuracy

浪尽此生 提交于 2021-01-27 04:21:08
问题 I am trying to understand how does a branch prediction unit work in a CPU. I have used papi and also linux's perf-events but both of them do not give accurate results (for my case). This is my code: void func(int* arr, int sequence_len){ for(int i = 0; i < sequence_len; i++){ // region starts if(arr[i]){ do_sth(); } // region ends } } My array consists of 0's and 1's. It has a pattern with a size of sequence_len . For example, if my size is 8, then it has a pattern of 0 1 0 1 0 0 1 1 or

Using rdmsr/rdpmc for branch prediction accuracy

孤街浪徒 提交于 2021-01-27 04:21:08
问题 I am trying to understand how does a branch prediction unit work in a CPU. I have used papi and also linux's perf-events but both of them do not give accurate results (for my case). This is my code: void func(int* arr, int sequence_len){ for(int i = 0; i < sequence_len; i++){ // region starts if(arr[i]){ do_sth(); } // region ends } } My array consists of 0's and 1's. It has a pattern with a size of sequence_len . For example, if my size is 8, then it has a pattern of 0 1 0 1 0 0 1 1 or

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

How to use gnu gcc flag -mpc32, -mpc64 and -mpc80?

故事扮演 提交于 2021-01-25 20:23:07
问题 I got these GCC flags from the GNU GCC compiler Manual. But when I tried to use those flags ( -mpc32 , -mpc64 and -mpc80 ) I couldn't observe the behavior. So I need help on how to use these flags with a sample code. sample code I tried: test.cpp #include<stdio.h> #include<iomanip> #include<math.h> int main() { double weight = 1.0f; double roiSize = 137.142364501953125f; double thresholdValue = 5400.0f; double alpha = weight / (roiSize * thresholdValue * thresholdValue); std::cout<<std:

How to use gnu gcc flag -mpc32, -mpc64 and -mpc80?

回眸只為那壹抹淺笑 提交于 2021-01-25 20:22:53
问题 I got these GCC flags from the GNU GCC compiler Manual. But when I tried to use those flags ( -mpc32 , -mpc64 and -mpc80 ) I couldn't observe the behavior. So I need help on how to use these flags with a sample code. sample code I tried: test.cpp #include<stdio.h> #include<iomanip> #include<math.h> int main() { double weight = 1.0f; double roiSize = 137.142364501953125f; double thresholdValue = 5400.0f; double alpha = weight / (roiSize * thresholdValue * thresholdValue); std::cout<<std: