user3547291
user3547291

Reputation: 11

Mips - Is there any way to get the space in an array into a variable?

Is there any way to get the number of bytes in an array?

     .data
array: .space 40
...
some other code

Is there anyway to put the number 40 into a register to use it as a variable?

Upvotes: 1

Views: 378

Answers (1)

markgz
markgz

Reputation: 6266

.data 
array: space 40
array_end: 
...

.text
...
la $t0, array
la $t1, array_end
sub $t2, $t1, $t0   # $t2 should contain 40
...

The above code should leave the size of array in $t2

Upvotes: 1

Related Questions