Question

spim mips processor


6. Experimental Procedure: Use SPIM (a MIPS processor) . Review the program specification and write the program in NotePad. O

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

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You.

code.asm

.data
prompt1 : .asciiz "\nInput a character (lowercase letter or digit 0-9)"
error : .asciiz "\nNeed a lower case letter or digit. Try again"
retry : .asciiz "\nDo you want to re-run the program(Y for yes)?"
char :.asciiz "0123456789abcdefghijklmnopqrstuvwxyz"
prompt3 : .asciiz "\n The ordered string is : "
prompt4 : .asciiz "\n Program ternimated "
display : .space 40
.text

askAgain:

li $v0,4
la $a0,prompt1 #it will print prompt
syscall
li $v0, 12
syscall
bge $v0,'a',checkZ
j checkDigit
checkZ:
ble $v0,'z',lowercase
checkDigit:
bge $v0,'0',check9
j errorShow
check9:
ble $v0,'9',digit
j errorShow
lowercase:
digit:
move $t1,$v0 #move data to t0
li $v0,11
li $a0,'\n'
syscall
li $v0,4
la $a0,prompt3 #it will print prompt
syscall
la $t0,char
loop:      
   lb $t2,0($t0)
   beqz $t2,end  
  
   li $v0,11
   move $a0,$t2 #move character to print
   syscall
   beq $t2,$t1,end
   add $t0,$t0,1
   j loop
end:
  
li $v0,4
la $a0,retry #it will print prompt
syscall  

li $v0, 12
syscall

beq $v0,'Y',askAgain
beq $v0,'y',askAgain

li $v0,4
la $a0,prompt4 #it will print prompt
syscall  
li $v0,10
syscall

errorShow:
li $v0,4
la $a0,error #it will print prompt
syscall
j askAgain

.data prompt1 : .asciiz \nInput a character (lowercase letter or digit 0-9) error : .asciiz \nNeed a lower case letter or

j errorShow lowercase: digit: move $t1,$v0 #move data to to li $v0,11 li $a0,\n syscall li $v0,4 la $a0, prompt3 #it will p

li $v0, 12 syscall beq $v0, Y, askAgain beq $v0, y, askAgain #it will print prompt li $v0,4 la $a0, prompt4 syscall li $v

output:

ssages Run I/O Input a character (lowercase letter or digit 0-9) The ordered string is : 0123456789abcde Do you want to re-ru

Add a comment
Know the answer?
Add Answer to:
spim mips processor
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