Added a list of registers along with descriptions of each of these.
This commit is contained in:
parent
6b8351f410
commit
33d1dc0851
47
registers.md
Normal file
47
registers.md
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
Registers in MAL
|
||||||
|
================
|
||||||
|
|
||||||
|
Program registers
|
||||||
|
-----------------
|
||||||
|
#### PC
|
||||||
|
The *Program Counter* holds the address of the next instruction byte.
|
||||||
|
|
||||||
|
#### MBR
|
||||||
|
The *Memory Buffer Register* stores the single byte that is read from the address specified in **PC**. This register is special as it can be read as two different registers:
|
||||||
|
###### MBR
|
||||||
|
When read as MBR, the register reads as a 32-bit signed integer. The 32-bit signed integer is sign extended from an 8-bit signed integer and thus has the range -128 to 127.
|
||||||
|
###### MBRU
|
||||||
|
When read as MBRU, the register reads as a 32-bit *unsigned* integer. The 32-bit signed integer is extended with zeroes from an 8-bit *unsigned* integer and thus has the range 0 to 255.
|
||||||
|
|
||||||
|
#### OPC
|
||||||
|
The *Old Program Counter* is used to store the old value of the **PC**-register, although it is very commonly used as a *scratch register* for storing other values.
|
||||||
|
|
||||||
|
Read and write
|
||||||
|
--------------
|
||||||
|
#### MAR
|
||||||
|
The *Memory Address Register* contains the address of the 32-bit word that the next read or write is going to use. This register can only be written to, not read from.
|
||||||
|
|
||||||
|
#### MDR
|
||||||
|
The *Memory Data Register* contains the data that has just been read in the case of a *read* operation or is to be written in the case of a *wr* operation.
|
||||||
|
|
||||||
|
#### MBR
|
||||||
|
See **MBR** under *Program registers*
|
||||||
|
|
||||||
|
Stack registers
|
||||||
|
---------------
|
||||||
|
#### SP
|
||||||
|
The *Stack Pointer* register contains a pointer to the top-most element of the stack.
|
||||||
|
|
||||||
|
#### LV
|
||||||
|
The *Local Variables* register points to the lowest of the local variables in the current *stack frame*, that is the lowest of the local variables for the currently executing function.
|
||||||
|
|
||||||
|
#### CPP
|
||||||
|
The *Constant Pool Pointer* points to the lowest element of the constant pool.
|
||||||
|
|
||||||
|
#### TOS
|
||||||
|
The *Top Of Stack* register contains the *value* of the uppermost element on the stack--it is *not* a pointer. This is, however, not a requirement that the developer is bound to follow when coding own instructions. The register should however always be set to the value of the top element at the end of the instruction.
|
||||||
|
|
||||||
|
Arithmetics
|
||||||
|
-----------
|
||||||
|
#### H
|
||||||
|
The *Hold* register is used to hold the left operand in the operations performed by the ALU.
|
Loading…
Reference in New Issue
Block a user