Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are there (load byte unsigned) and (load byte) instructions in MIPS but only (store byte)?

There is only a store byte instruction, so I don't get it why there are both load byte and load byte unsigned...

I tried looking for it but couldn't find anything helpful.

like image 316
user2465695 Avatar asked Jun 08 '13 06:06

user2465695


1 Answers

MIPS registers are 32 bits wide. When you load a single 8-bit byte into one of those registers from memory, you have to decide whether to sign-extend it or not. Hence the two load instructions. When storing, there's no such ambiguity.

A loading example:

.data

variable: .byte 0x80

.text

lb  $t0, variable
lbu $t1, variable

After this code runs, t0 will be 0xffffff80 (-128), and t1 will be 0x00000080 (128).

like image 152
Carl Norum Avatar answered Dec 31 '22 16:12

Carl Norum