Question

The code below generates 10 random lowercase characters a – z and stores the characters in...

The code below generates 10 random lowercase characters a – z and stores the characters in memory. Expand this code to CAPITALIZE all the characters in memory. Your code should iterate all characters in memory and change their value to their uppercase equivalent. For instance, character ‘a’ would become ‘A and ‘z’ would become ‘Z’.   
Hint: The ASCII table on the backside of this sheet will be necessary in answering this question.

li $t0, 0 # i= 0
move $s0, $gp # copy base adress to s0

#for(i = 0; i<10; i++)
loop: bgt St0, 10, exitloop

#Generate Random Number in to $a0
#Random ASCII value between 97 and 122
li $a1, 25
li $v0, 42
syscall
addi $t2, $a0, 97
  
sw $t2, 0($s0)
addi $t2, $a0, 4
  
addi $t0, $t0, 1#i++
j loop
  
exitLoop:

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

Please find the code below:::

.data
prompt: .asciiz " Generated random numbers : "
prompt1: .asciiz " Capatilized random numbers : "
.text
li $t0, 0 # i= 0
move $s0, $gp # copy base adress to s0

#for(i = 0; i<10; i++)
loop:
bgt $t0, 10, exitloop

#Generate Random Number in to $a0
#Random ASCII value between 97 and 122
li $a1, 25
li $v0, 42
syscall
addi $t2, $a0, 97
  
sw $t2, 0($s0)
addi $s0, $s0, 4
  
addi $t0, $t0, 1#i++
j loop

exitloop:
li $t0,0
move $s0,$gp

li $v0,4
la $a0,prompt #it will print prompt
syscall
printLoop:
mul $t1,$t0,4
add $t1,$t1,$s0
lw $t1,($t1)
li $v0,11
move $a0,$t1
syscall

li $v0,11
li $a0,' '
syscall

add $t0,$t0,1
blt $t0,10,printLoop

li $t0,0
move $s0,$gp
li $v0,4
la $a0,prompt1 #it will print prompt
syscall
printLoop2:
mul $t1,$t0,4
add $t1,$t1,$s0
lw $t2,($t1)
sub $t2,$t2,32
sw $t2,($t1)
li $v0,11
move $a0,$t2
syscall

li $v0,11
li $a0,' '
syscall

add $t0,$t0,1
blt $t0,10,printLoop2


output:

Add a comment
Know the answer?
Add Answer to:
The code below generates 10 random lowercase characters a – z and stores the characters in...
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