Converting C++ code to Mips

1k views Asked by At

I am converting a C++ project in Mips assembly language. In c++ you can initialize an array like

int array[5]={1,2,3,4,5};

How can I initialize an array of characters in MIPS assembly language?

1

There are 1 answers

4
gusbro On BEST ANSWER

In MIPS assembly you would instruct the assembler to statically allocate enough memory for the array, and its initial value using the directives .data and .word. E.g:

.data
arrayOfInts:
.word 1, 2, 3, 4, 5
arrayOfChars
.word 'a', 'b', 'c'

This works for compile-time defined variables. If your intent is to dynamically allocate the array you'd have to do it yourself.