Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MIPS Data Directives

Tags:

assembly

mips

I'm new in MIPS and trying to teach myself using this book. I'm trying to learn data directive and what are the difference between these three :

list:   .word 0:3
list:   .word 3
list:   .word

But I didn't find any clear document/reference.

Thank you.

like image 450
Node.JS Avatar asked Aug 06 '26 01:08

Node.JS


1 Answers

list:   .word 0:3

Will reserve 3 words and set each to the value 0. This would be similar to:

int list[3] = {0, 0, 0};

Or

list:   .space 12

(In which case, the value is implicitly 0).

The 0 in '0:3' could have very well be any other value. For example:

list:   .word 'X':3
# or
list:   .word 88:3

When the number of elements is missing, it's simply the value of the word

list:   .word 3

Which is similar to

int list = 3;

The last one,

list:   .word

Will likely cause assemblers to complain for the missing operand.

like image 198
Wiz Avatar answered Aug 08 '26 17:08

Wiz