Linked Questions

162 votes
6 answers
118k views

xor eax, eax will always set eax to zero, right? So, why does MSVC++ sometimes put it in my executable's code? Is it more efficient that mov eax, 0? 012B1002 in al,dx 012B1003 push ...
devoured elysium's user avatar
67 votes
6 answers
26k views

There're two well-known ways to set an integer register to zero value on x86. Either mov reg, 0 or xor reg, reg There's an opinion that the second variant is better since the value 0 is not stored ...
sharptooth's user avatar
  • 172k
3 votes
2 answers
9k views

I'm trying to write a boot loader, and all the code I am writing is being run in real mode. In all the examples I find there is either an xor ax, ax or xor eax, eax, and I don't understand what this ...
ragingSloth's user avatar
  • 1,104
4 votes
1 answer
214 views

I've developed a little benchmark. The result of the loop inside this benchmark should be transformed to zero and the next round of my calculation should depend on the zero-"result" of the ...
Bonita Montero's user avatar
1 vote
0 answers
452 views

The popular method to clear rax is xor rax,rax (0x4831C0) but that operation affects the flag bits. How to clear rax without affecting the flags? For example: mov rax,0 (0x48C7C0xxxxxxxx takes 7 ...
user2707695's user avatar
0 votes
0 answers
256 views

Compiling the following C program with GCC 6.4.1 using -O0 and -O2 gives the following results for the main() function. int main(int argc, char *argv[]) { if (argc == 2) { printf("Checking ...
Bernardo Sulzbach's user avatar
0 votes
0 answers
256 views

A setcc instruction writes to the low byte of a register. If I write, e.g., "setnl cl" will ecx/rcx be zero-extended? EDIT: after the comments made below, I see that setcc does not zero-...
RTC222's user avatar
  • 2,399
1 vote
0 answers
196 views

In Programming from the Ground Up one reads that the XOR operation is faster than the loading operation, so many programmers use it to load a register with a zero. For example, the code movl $0, %eax ...
Enlico's user avatar
  • 30.8k
959 votes
11 answers
189k views

I wrote these two solutions for Project Euler Q14, in assembly and in C++. They implement identical brute force approach for testing the Collatz conjecture. The assembly solution was assembled with: ...
rosghub's user avatar
  • 9,324
146 votes
23 answers
117k views

I am looking for an efficient way to determine the position of the least significant bit that is set in an integer, e.g. for 0x0FF0 it would be 4. A trivial implementation is this: unsigned ...
peterchen's user avatar
  • 41.4k
187 votes
4 answers
56k views

In the x86-64 Tour of Intel Manuals, I read Perhaps the most surprising fact is that an instruction such as MOV EAX, EBX automatically zeroes upper 32 bits of RAX register. The Intel documentation (...
Nubok's user avatar
  • 3,719
58 votes
11 answers
143k views

I'm getting into assembly and I keep running into xor, for example: xor ax, ax Does it just clear the register's value?
Chiggins's user avatar
  • 8,507
54 votes
12 answers
12k views

I've been working in C and CPython for the past 3 - 5 years. Consider that my base of knowledge here. If I were to use an assembly instruction such as MOV AL, 61h to a processor that supported it, ...
user407896's user avatar
73 votes
4 answers
6k views

Given this code: #include <string.h> int equal4(const char* a, const char* b) { return memcmp(a, b, 4) == 0; } int less4(const char* a, const char* b) { return memcmp(a, b, 4) < 0; ...
John Zwinck's user avatar
48 votes
10 answers
89k views

I'm curious how many ways are there to set a register to zero in x86 assembly. Using one instruction. Someone told me that he managed to find at least 10 ways to do it. The ones I can think of are: ...
user avatar

15 30 50 per page
1
2 3 4 5
15