Converting C++ to MIPS

General Tech Bugs & Fixes 2 years ago

2 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 28 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

Hello I've recently started working with MIPS and have been converting some of my old projects (in C++) onto MIPS. I thought I did everything correctly, but when I started to compile it assembled but I didnt get expected results. The little snippet I'm showing you should be able to do a full loop but stops midway through for some reason.I would add all the code but its over 500 lines long and dont want to make it a bigger problem.

I think the problem deal with this reading in the *hopPtr1 I've tried altering the sw but I couldn't find the problem

begDW1:
#                  used1 = 0;
                   li $t1, 0
#                  hopPtr1 = a1;
                   la $t4, array
#//                do
begDW2:
#                  cout << einStr;
                   li $v0, 4
                   la $a0, einStr
                   syscall
#                  cout << (used1 + 1);
                   li  $v0, 1
                   addi $a0, $t1,1
                   syscall
#                  cout << ':' << ' ';
                   li $v0, 4
                   la $a0, colSpa
                   syscall 
#                  cin >> *hopPtr1;   
                   li $v0,5
                   syscall
                   sw $v0, 0($t4)                          
#                  ++used1;
                   addi $t1,$t1,1
#                  ++hopPtr1;
                   addi $t4,$t4,1          
#//                if (used1 == 12)
#                  if (used1 != 12) goto else1;
                   li $t0, 12
                   bne $t1, $t0, else1
begI1:
#                  cout << moStr;
           li $v0, 4
           la $a0, moStr
           syscall 
#                  cout << 12;
           li $v0, 1
           li $a0, 12
           syscall
#                  cout << ieStr;
           li $v0, 4
           la $a0, ieStr
           syscall
#                  cout << endl;
                   li $v0, 11
                   li $a0, '\n'
                   syscall
#                  reply = 'n';
                   li $t8,'n'
#                  goto endI1;
                   j endI1
#//                }
else1:
#//                {
#                  cout << emiStr;
                   li $v0, 4
                   la $a0, emiStr
                   syscall
#                  cin >> reply;
           li $v0, 12
                   syscall
                   move $t8, $v0

The loop should be repeated 12 com/tag/times">times and not stopped midway through the 2nd loop

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community