Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use MIPS $k0 and $k1 registers

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

The k registers are reserved for use by the OS kernel.

But I couldn't find anything about what are they usefull for? and also how to use them?

Thank you.

like image 274
AliLotfi Avatar asked Jan 13 '15 12:01

AliLotfi


1 Answers

An interrupt handler must save any general - purpose registers that it is going to use (to be restored at return). But to do so requires you to modify at least one register first (something like sw $t0, saved_t0 expands to two machine instructions using $at).

This situation is resolved by forbidding user programs from using two general - purpose registers, $k0 and $k1 (The k stands for kernel, which an exception handler is part of). The interrupt handler is allowed to use $k0 and $k1 without having to save or restore their values. This allows just enough leeway to start saving registers, as well as making returning from the interrupt handler possible.

like image 153
AliLotfi Avatar answered Oct 07 '22 15:10

AliLotfi