Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of a $zero register in MIPS?

Tags:

mips

What is the use of a $zero register in MIPS?

What does it mean?

lw $t0, myInteger($zero)
like image 271
user366312 Avatar asked Aug 26 '15 18:08

user366312


People also ask

Is $zero a register?

A zero register is a processor register that always returns the value zero. It is found primarily in high-performance instruction set architectures, notably the CDC 6600, System/360 and MIPS architecture, among others.

What are a registers used for MIPS?

MIPS has two primary types of registers, integer registers and floating point registers. In addition, MIPS has a small number of special purpose control registers. There are register usage conventions that specify how main programs and subprograms should coordinate their use of registers.

How many S registers are there in MIPS?

Registers. MIPS has 32 general-purpose registers and another 32 floating-point registers.


1 Answers

The zero register always holds the constant 0. There's not really anything special about it except for the fact that 0 happens to be a very useful constant. So useful that the MIPS designers dedicated a register to holding its value. (This way you don't have to waste another register, or any memory, holding the value.)


EDIT:

As for the question of what that line of code means, it loads the word from MEMORY[myInteger + 0] into the $t0 register. The lw command takes both a constant (myInteger) and a register ($zero). Not sure why that is, but that's just how the instructions work. Since myInteger was used as the constant, a register had to be provided, so $zero was used.

like image 73
GJK Avatar answered Oct 16 '22 11:10

GJK