In MIPS, what are HI and LO

86,254

Solution 1

These are special registers used to store the result of multiplication and division. They are separate from the $0 .. $31 general purpose registers, not directly addressable. Their contents are accessed with special instructions mfhi and mflo (Move From HI/LO).

They are present in the Multiply Unit and are 32-bits each. More info here. As a pair, they hold the 64-bit full result of a 32x32-bit integer mult.


Raymond Chen's blog article The MIPS R4000, part 3: Multiplication, division, and the temperamental HI and LO registers has some very good info about early MIPS's non-intuitive behaviours, including mtlo / mtlo invalidating the previous hi / lo (respectively).

The incomplete integer instruction-set reference (linked in the question) for early MIPS also has some details, http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html, or see MIPS's official PDF manuals, or PDFs of manuals for classic MIPS CPUs.

Solution 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.

Solution 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.

Share:
86,254
hodgesmr
Author by

hodgesmr

Updated on December 11, 2020

Comments