How to use MIPS registers $ k0 and $ k1

I was wondering what $k0 and $k1 registers are in the MIPS architecture. As is on the WikiBooks MIPS Assembly

Registers k are reserved for use by the OS kernel.

But I could not find anything about what they are useful for. as well as how to use them?

Thanks.

+6
source share
1 answer

The interrupt handler must save all the general registers that it will use (for recovery upon return). But for this, you must first change at least one register (something like sw $t0, saved_t0 expands to two machine instructions using $at ).

This situation is resolved by prohibiting the use of user programs using two general-purpose registers, $k0 and $k1 (K means the kernel, which includes the exception handler). The interrupt handler is allowed to use $k0 and $k1 without having to save or restore their values. This allows enough free time to start saving registers, as well as making returning from the interrupt handler possible.

+10
source

Source: https://habr.com/ru/post/980927/


All Articles