The point of test %eax %eax [duplicate]

This question already has answers here: Closed 9 years ago. Possible Duplicate: x86 Assembly – ‘testl’ eax against eax? I’m very very new to assembly language programming, and I’m currently trying to read the assembly language generated from a binary. I’ve run across test %eax,%eax or test %rdi, %rdi, etc. etc. I’m very confused as … Read more

Why aren’t programs written in Assembly more often? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for … Read more

Why would introducing useless MOV instructions speed up a tight loop in x86_64 assembly?

Background: While optimizing some Pascal code with embedded assembly language, I noticed an unnecessary MOV instruction, and removed it. To my surprise, removing the un-necessary instruction caused my program to slow down. I found that adding arbitrary, useless MOV instructions increased performance even further. The effect is erratic, and changes based on execution order: the … Read more

Why does GCC use multiplication by a strange number in implementing integer division?

I’ve been reading about div and mul assembly operations, and I decided to see them in action by writing a simple program in C: File division.c #include <stdlib.h> #include <stdio.h> int main() { size_t i = 9; size_t j = i / 5; printf(“%zu\n”,j); return 0; } And then generating assembly language code with: gcc … Read more

What is exactly the base pointer and stack pointer? To what do they point?

Using this example coming from wikipedia, in which DrawSquare() calls DrawLine(), (Note that this diagram has high addresses at the bottom and low addresses at the top.) Could anyone explain me what ebp and esp are in this context? From what I see, I’d say the stack pointer points always to the top of the … Read more

What is a retpoline and how does it work?

In order to mitigate against kernel or cross-process memory disclosure (the Spectre attack), the Linux kernel1 will be compiled with a new option, -mindirect-branch=thunk-extern introduced to gcc to perform indirect calls through a so-called retpoline. This appears to be a newly invented term as a Google search turns up only very recent use (generally all … Read more