Close

PC should belong to the register set

A project log for PDP - Processor Design Principles

Distilling my experience and wisdom about the architecture, organisation and design choices of my CPUs

yann-guidon-ygdesYann Guidon / YGDES 02/02/2018 at 05:421 Comment

The registers are a precious resource. Using the coding space for something else reduces the orthogonality and flexibility of the whole architecture.

However, including the PC as a read/write register has many benefits. AMD introduced the RIP-relative addressing mode with their AMD64, though it's not directly visible. You might still be able to do a LEA [0] to get RIP in a register.

Classic operations with the PC can emulate many special opcodes and free some space in the opcode map. Make sure though that you correctly handle the value : is PC pre- or post-incremented ?

In my design, there is often a cohabitation of PC and NPC :

Now, if the PC is a user-visible and writable register, you can have some fun :

This approach uses one register in an already tight register set but the gain in opcode space and flexibility are worth it, IMHO.

Discussions

Ken Yap wrote 03/18/2019 at 00:40 point

No mention of the venerable PDP11 where the PC is R7 and SP by convention is R6? I realised how elegant this was ages ago. For example local variables in languages like C are just indexed off SP. Well maybe a better example is load constant is actually load indirect PC with auto increment.

  Are you sure? yes | no