Formatting. Sorry if this is too intruding @christoffermadsen.

Add Z & N section.
This commit is contained in:
Jon Michael Aanes 2015-12-16 22:08:25 +01:00
parent 33d1dc0851
commit 41bd896cfe

View File

@ -3,45 +3,75 @@ Registers in MAL
Program registers
-----------------
#### PC
### 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.
### 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:
#### 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.
#### 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 zeros 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.
### 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.
#### MBR
### 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.
### SP
The *Stack Pointer* register contains a pointer to the top-most element of the
stack.
#### CPP
### 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.
### 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.
### H
The *Hold* register is used to hold the left operand in the operations performed
by the ALU.
### Z & N
The *Z* and *N* registers are *virtual registers*. They are automatically set
after any ALU operation. A MAL `if(x)` statement can only accept *Z* and *N* as
input.