Tag: assembly

66 votes
13 answers
1.7K views
Can num++ be atomic for 'int num'?

In general, for int num, num++ (or ++num), as a read-modify-write operation, is not atomic. But I often see co

avatar
Forrest
0 1 0 9
asked 07 September, 2021
54 votes
4 answers
2K views
What are the calling conventions for UNIX & Linux system calls (and user-space functions) on i386 and x86-64

Following links explain x86-32 system call conventions for both UNIX (BSD flavor) & Linux: http://www.int

avatar
Rufus
0 1 0 9
asked 07 September, 2021
50 votes
3 answers
1.8K views
Why does GCC generate such radically different assembly for nearly the same C code?

While writing an optimized ftol function I found some very odd behaviour in GCC 4.6.1. Let me show you the cod

avatar
Eddie
0 1 0 9
asked 07 September, 2021
64 votes
21 answers
380 views
Is inline assembly language slower than native C++ code?

I tried to compare the performance of inline assembly language and C++ code, so I wrote a function that add tw

avatar
Rudolf
0 1 0 9
asked 07 September, 2021
58 votes
8 answers
1.5K views
Show current assembly instruction in GDB

I'm doing some assembly-level debugging in GDB. Is there a way to get GDB to show me the current assembly

avatar
Juliane
0 1 0 9
asked 07 September, 2021
66 votes
24 answers
1.4K views
Protecting executable from reverse engineering?

I've been contemplating how to protect my C/C++ code from disassembly and reverse engineering. Normally

avatar
Lashawna
0 1 0 9
asked 07 September, 2021
56 votes
4 answers
3K views
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 i

avatar
Jesenia
0 1 0 9
asked 07 September, 2021
62 votes
5 answers
2.5K views
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

avatar
Xavier
0 1 0 9
asked 07 September, 2021
62 votes
10 answers
2.4K views
Assembly code vs Machine code vs Object code?

What is the difference between object code, machine code and assembly code? Can you give a visual example of

avatar
Xavier
0 1 0 9
asked 07 September, 2021
53 votes
7 answers
1.5K views
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 h

avatar
Jesenia
0 1 0 9
asked 07 September, 2021
49 votes
12 answers
1.4K views
Is 'switch' faster than 'if'?

Is a switch statement actually faster than an if statement? I ran the code below on Visual Studio 2010's

avatar
Renaldo
0 1 0 9
asked 07 September, 2021
50 votes
3 answers
1.7K views
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

avatar
Gigi
0 1 0 9
asked 07 September, 2021
54 votes
10 answers
1.6K views
What does multicore assembly language look like?

Once upon a time, to write x86 assembler, for example, you would have instructions stating "load the EDX regis

avatar
Trudy
0 1 0 9
asked 07 September, 2021
65 votes
4 answers
2.3K views
How to run a program without an operating system?

How do you run a program all by itself without an operating system running? Can you create assembly programs t

avatar
Georgie
0 1 0 9
asked 07 September, 2021
58 votes
16 answers
655 views
Is it possible to "decompile" a Windows .exe? Or at least view the Assembly?

A friend of mine downloaded some malware from Facebook, and I'm curious to see what it does without infec

avatar
Rudy
0 1 0 9
asked 07 September, 2021
63 votes
5 answers
1.7K views
Why does Java switch on contiguous ints appear to run faster with added cases?

I am working on some Java code which needs to be highly optimized as it will run in hot functions that are inv

avatar
Kristopher
0 1 0 9
asked 07 September, 2021
48 votes
10 answers
1.6K views
Using GCC to produce readable assembly?

I was wondering how to use GCC on my C source file to dump a mnemonic version of the machine code so I could s

avatar
Jesenia
0 1 0 9
asked 07 September, 2021
55 votes
17 answers
1.5K views
How do you get assembler output from C/C++ source in gcc?

How does one do this? If I want to analyze how something is getting compiled, how would I get the emitted ass

avatar
Winford
0 1 0 9
asked 07 September, 2021
52 votes
4 answers
665 views
How do I achieve the theoretical maximum of 4 FLOPs per cycle?

How can the theoretical peak performance of 4 floating point operations (double precision) per cycle be achiev

avatar
Dorian
0 1 0 9
asked 07 September, 2021
64 votes
17 answers
1.5K views
What's the purpose of the LEA instruction?

For me, it just seems like a funky MOV. What's its purpose and when should I use it?

avatar
Vi
0 1 0 9
asked 07 September, 2021