In MIPS, what is HI and LO

2019-02-03 03:39发布

问题:

I'm reading about division in MIPS and I've found that div

Divides $s by $t and stores the quotient in $LO and the remainder in $HI

http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html

And Wikipedia says

HI and LO are used to access the multiplier/divider results, accessed by the mfhi (move from high) and mflo commands.

http://en.wikipedia.org/wiki/MIPS_architecture

Are HI and LO registers? What number registers are they?

回答1:

These are special registers used to store the result of multiplication and division. They are not directly addressable. Their contents are accessed with special instructions mfhi and mflo

They are present in the Multiply Unit and are 32-bits each. More info here.



回答2:

HI and LO are not numbered registers, IIRC. They are only used to store the results of operations that would not fit in a single register (e.g. multiplying two 32-bit integers could result in a 64 bit integer, so the overflow goes in HI).

edit: according to this class description, they are indeed special registers, so they are not numbered, and only accessible using special commands.



回答3:

What LO does is that for multiplication, it stores the least significant bits, and HI stores the rest of the bits, but mainly, we just focus on the LO part for multiplication. In division, we focus on both. LO in division is where the quotient should be stored at and HI is the remainder.