Question

please translate these c++ coding to the simplest QtSPIM MIPS assembly language statement #include<iostream> using namespace...

please translate these c++ coding to the simplest QtSPIM MIPS assembly language statement

#include<iostream>

using namespace std;

int main()

{

int change;

int totalCredit;

cout<<"Please scan your card";

cin>>totalCredit;

if(totalCredit>=3)

{

change=totalCredit-3;

cout<<"45 min";

}

else

{

cout<<"00";

}

return 0;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:

.globl main
.data
prompt1: .asciiz "Please scan your card : "
promptZero: .asciiz "00"
promptTime: .asciiz "45 min"

.text
main:
li $t0,0 #using as change

li $v0, 4
la $a0, prompt1
syscall
li $v0,5
syscall
move $t1, $v0 #t1 as totalCredit
blt $t1,3,else #if total credit less than 3
sub $t0,$t1,3 #change = totalCredit - 3
li $v0, 4
la $a0, promptTime
syscall
j exit
else:
li $v0, 4
la $a0, promptZero
syscall
exit:

output:

や 1 忄 110x1 0010000 (.data) ▼||K Hexa Mars Messages Run I/O Please scan your card : 4 45 mirn program is finished running (dropped off bottom) Clear

Add a comment
Know the answer?
Add Answer to:
please translate these c++ coding to the simplest QtSPIM MIPS assembly language statement #include<iostream> using namespace...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT