T.I.M | ISA Specification
 All Pages
Status Register

Address: 0100, Memonic: SR

Functionality:

Stores various status bits each indicating different pieces of information. This register cannot be written too in the normal way. Its value may only be queried using the TEST instruction and coppied to a general purpose register using MOVSR.

The following pieces of information are stored in the status register and are updated automatically:

Bit Description
0 Zero Flag. Set if the result of the previous operation was zero.
1 Carry Flag. Set if the result of the previous operation did not fit in the register.
2 Negative Flag. Set if the result of the previous operation was negative.
3 Overflow Flag. Indicates the result of an arithmetic operation did not fit in the target register.
4 Undefined / Reserved.
5 Interrupt Servicing Flag. Set high if the currently executing function is handling an interrupt.
6 Supervisor Flag. When set all operations are valid. When unset certain memory regions are not accessable.
7 Undefined / Reserved.

This register is 8 bits wide.

Access

This can be read by:

  • TEST
  • MOVSR

The only permissable write operations on the status register are performed on the Supervisor and Interrupt servicing flag. Both flags may only be written too when the supervisor flag is set. Otherwise, the write is treated as a NOP.

To perform the write, A bit mask must be constructed in a general purpose register, with the desired bit values set or unset. The MOVRS instruction is then used to move the mask into the status register. Only bits corresponding to the supervisor and interrupt servicing flag are cared about.

To avoid accidentally setting or unsetting the supervisor flag and the interrupt service flag, the least significant bit is used to select between the interrupt flag and the supervisor flag. When zero, the interrupt flag is set, when one, the supervisor flag is written too. The other mask bits can take any value and will have no effect.

The example below shows how to set and then un-set the interrupt servicing flag.

0xAB0000 | MOVI R0 0b00100000 ; Set the mask bits
0xAB0004 | MOVRS R0 SR ; Move the mask into the test register.
...
... ; Interrupt handling occurs here.
...
0xAB0502 | MOVI R0 0b00000000 ; Set the mask bits, this time a zero
0xAB0506 | MOVRS R0 SR ; Move the mask and unset bit 5

Note that whenever a zero is written to the Interrupt servicing flag, this is taken to mean that the interrupt has been completely serviced.