Mips 2D(字符串)数组

时间:2018-11-23 02:34:58

标签: mips

this is a c++ code that will traverse through a string array with columns and rows. 

它具有(2)列A和菱形。每行(5) 然后经过for循环(带有换行符)以输出图纸。而不是只是从左到右,它会换行来打印星号。

我知道缺少一些代码,但是我想向您介绍我要问的内容,即,如何在Mips中像此代码一样在Mips中进行2D字符串数组处理?

const int numberletter = 2;     
const int lettersize = 5;       
string letters[numberletter][lettersize] =      //values to call  on the images colomes and rows
{
    { " ***    ",
      "*   *   ",
      "*****   ",
      "*   *   ",
      "*   *   " },

    { "  *     ",
      " ***    ",
      "*****   ",
      " ***    ",
      "  *     " }
};

    cout << "\nGuess the number (1-13)";        //prompt the user 
    cin >>The_guess;                                            //input guess for number
    cout << "Guess the face";       //prompt the user
    cin >> guess;                                               //input guess for face
    cout << endl;


    for (int i = 0; i < lettersize; i++) {
        cout << "\n" << (char)(179);
    if (The_guess == 1) {
        cout << " " << letters[0][i];       //this would output A
                }
    if (The_guess == 2) {

        cout << " " << letters[1][i];       //this would output dimond
                }

这就是我这么远,这有什么不对吗?

.data

stringarray1:

            .asciiz " ***","*   *","*****","*   *","*   *"

            .asciiz " ***","*   *","*****","*   *","*   *"

大小:.word 2、5

.eqv data_size 8

.text

la $a0, stringarray1
lw $a1, size
jal readarray
move $a0, $v0
li $v0, 4
syscall
li $v0,10
syscall

readarray:

li $v0, 0
li $v0, 0

arrayloop:

mul $t1, $t0, $a1   #colomsize * rowindex
add $t1, $t1, $t0       #+colmindex
mul $t1, $t1, data_size
add $t1, $t1, $a0

lw $t2, ($t1)

jr $ ra

0 个答案:

没有答案
相关问题