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 Program registers
----------------- -----------------
#### PC
### PC
The *Program Counter* holds the address of the next instruction byte. The *Program Counter* holds the address of the next instruction byte.
#### MBR ### 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: The *Memory Buffer Register* stores the single byte that is read from the
###### MBR address specified in **PC**. This register is special as it can be read as two
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. different registers:
###### 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 #### MBR
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. 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 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 ### MAR
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. 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* See **MBR** under *Program registers*
Stack registers Stack registers
--------------- ---------------
#### SP
The *Stack Pointer* register contains a pointer to the top-most element of the stack.
#### LV ### SP
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. 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. The *Constant Pool Pointer* points to the lowest element of the constant pool.
#### TOS ### 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. 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 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.