m8pple / arch2-2019-cw

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception Handling

olly-larkin opened this issue · comments

If an instruction attempts to write to register which it shouldn't (i.e. the zero register), would this exit with a memory exception (-11) or an invalid instruction (-12)?

commented

Why should an instruction not be able to (attempt to) write to $0?

The $0 register should always have the value 0 and I read online that registers $1, $26 and $27 were reserved for pseudo instructions and the kernel so I had assumed that writing to these registers would be illegal and throw an exception?

commented

$0 is hard-wired to GND; there are no physical registers present.

It is convention that certain registers are used for certain purposes. How would your CPU be able to tell, though, that it's executing an instruction injected by an assembler (e.g. affecting $1) or that's part of the OS kernel ($26, $27)?