advantages of PC-relative addressing

One reason why PC-relative jumps are advantageous is that they require fewer bits. A relative offset might be just 8 or 10 bits while a full, absolute address might be 32 bits. So, relative jumps take less memory in the instruction code. Since typical jumps are nearby, using relative jumps also makes the code smaller in addition to the advantage of relocatability.

Also, the offset for relative jumps can be computed at compile time, while the address for an absolute (direct) jump needs to be computed at link time. This makes building code with relative jumps a little faster.


Pretend I was your neighbour, who always lives one floor above yours. Even if you move, I will move after to a floor above yours. This means you'll easily find me all the time by walking a short distance, because you know my address relative to yours.

However, if I were to move away to somewhere random, the only way you could find me is by knowing my new absolute address. And every time I moved again, you would need to be updated on that address.

In this metaphor, you are a jump instruction that wants to execute a code block (me). "Moving" means code being reutilized or recompiled. Hope this helps.

Tags:

Addressing