what does .space do in mips?

.space Len directive instructs the assembler to reserve Len bytes. As every word has 4 bytes, when Len is 20 you are instructing the assembler to reserve 5 words.

For example if you have

.data
array: .space 20
other_data: .asciiz 'This is other data'

then other_data will be 20 bytes after array address.

Due to architectural constraints in MIPS you may need to also instruct the assembler to align the reserved memory (.align 2) before your array label if you want to access on a word-by-word basis (in your particular example you would not need it, it should be already aligned).

Leave a Comment