T
T
Tolik2015-12-07 21:38:34
assembler
Tolik, 2015-12-07 21:38:34

Why do we need alignment of (assembler) code when compiling (linking)?

Here I wrote some code, in C's for example. I fed it to the compiler, got a binary (executable). Why does the compiler (or maybe the linker) add NOPs after functions so that functions start from addresses that are multiples of some number?
I understand that you can store data on hard drives this way, round to sectors, tracks, or something like that, but in RAM, access to any section takes the same amount of time, so I don’t understand the point of rounding function addresses.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2015-12-08
@Diel

Why alignment of (assembler) code is needed

Because it requires less cache and works faster.
Also, on some architectures, some branch instructions can only branch to aligned addresses.
No.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question