Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Converting C++ to MIPS

General Tech Bugs & Fixes

Max. 2000 characters
Replies

usr_profile.png

User

( 6 months 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 times and not stopped midway through the 2nd loop

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif