Reputation: 61
I know that to declare a variable inside the .data section we use-
.data
x: .word 2
But, what if I want to create a variable called answer which I will store the multiplication of x and some other variable into using SW. Can I initialize a variable without putting any value into it? For ex-
answer: .word
Upvotes: 1
Views: 745
Reputation: 1837
If you're using SPIM, then use .space n
to reserve n bytes. Source the "Data Declarations" section here.
You'll probably want .space 8
given if you're using a 32 bit simulator, because multiplication can result in a number twice as large as the arguments (which are 4 bytes in 32 bit).
Upvotes: 2