1

I am new to Assembly, and based on my understanding, an ISA (Instruction Set Architecture) specifies what instructions are available for a particular CPU.

But does an ISA also specify what registers are available in the CPU?

  • 2
    An ISA specify the logical registers visible from the instruction set. What actually happens on the silicon could be different. – Basile Starynkevitch Jun 30 '17 at 10:44
3

Yes. It also specifies which instructions can be used with which registers, which instructions can be used after which instructions, which instructions and instruction sequences are atomic, and so on.

Of course, the ISA only specifies "as if" rules, so the CPU could have more registers and switch them between threads or it could have less registers and emulate them somehow.

3

An instruction set specifies instructions that can contain several parts: opcodes, addressing modes, addresses or literal data. The addressing mode that specifies registers or register-indirect destinations and sources for an instruction references specific registers (e.g. the bit pattern 0001 might mean "The AX register" and 0010 "The BX register", etc.).

Insofar as an instruction set contains such addressing modes, yes, a CPU that implements this set has to have the corresponding registers. If it didn't, the computer would have to signal an operational exception at such a low level that it would be difficult to recover from, or even to communicate it reasonably. Practically, it really only makes sense to implement 100% of an instruction set, and that includes all the CPU registers that it assumes.

  • 1
    And a practical concern it is. It's an implementation detail from a theoretical perspective, as anyone who's written a CPU simulator can attest. – Robert Harvey Jun 30 '17 at 17:04
1

But does an ISA also specify what registers are available in the CPU?

An ISA defines very specific behaviors in terms of individual instructions and the various fields that can be encoded in each instruction. Some of those behaviors define the setting of some state that is available for some subsequent instructions to consume.

It comes down to the exact instructions, which, by their definitions, provide for the existence, updating, and consuming of the registers, and these instructions expose this state to programming.

Of course, taking a view of the register set as a whole is crucial to understanding an ISA. All the instruction definitions — taken together — can be seen as essentially defining the externally visible register set, which @Basile refers to as the logical registers.

Still, to one way of looking at it, the registers exist in the ISA because instructions exist that define and manipulate them.

Programs, of course, are created by using sequences of instructions (behaviors) that modify the state in a desirable way to compute something of interest.

And as others are pointing out, the modern physical hardware usually provides more internal state than defined in the ISA, and, these additions are basically not visible through the instructions. These extras are used to increase performance, such as by allowing more things to be worked on in parallel by the hardware, or by eliminating stalls.


from wikipedia:

An instruction set architecture (ISA) is an abstract model of a computer.

An instruction set architecture is effectively an interface or contract between a hardware family that implements it and the software that uses it.

The contract asserts a guarantee of the documented behaviors of the instructions, which includes setting and getting register values. Through an ISA, a hardware processor family publishes a contract that makes guarantees of being able to run operating system and user software that rely on the defined behaviors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.