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
  • what is the output of the following assembly code ? .data A: .word 84 111 116 97 108 32 105 115 32 . text main:​li $v0, 1l ​li $s0,0 ​la $s1, A ​li $t3, 0 loop: ​slti $t0, $s0, 17   ​be...

    what is the output of the following assembly code ? .data A: .word 84 111 116 97 108 32 105 115 32 . text main:​li $v0, 1l ​li $s0,0 ​la $s1, A ​li $t3, 0 loop: ​slti $t0, $s0, 17   ​beq: $t0, $zero, end ​sll $t1, $s0 2 ​add $t2 $s1 $t1   ​syscall ​addi $s0, $s0, 1 ​j loop end: ​li $v0, 1 ​add $a0, $zero, $t3 ​syscall

  • im trying to complete mips program code about a calculator program that can calculate integer addition...

    im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...

  • .data A: .word 84 111 116 97 108 32 105 115 32 . text main:​li $v0,...

    .data A: .word 84 111 116 97 108 32 105 115 32 . text main:​li $v0, 1l ​li $s0,0 ​la $s1, A ​li $t3, 0 loop: ​slti $t0, $s0, 17   ​beq: $t0, $zero, end ​sll $t1, $s0 2 ​add $t2 $s1 $t1   ​syscall ​addi $s0, $s0, 1 ​j loop end: ​li $v0, 1 ​add $a0, $zero, $t3 ​syscall /// whats the output of above assembly program

  • WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS IN ASSEMBLY LANGUAGE USING MIPS IN MARS .data...

    WRITE THE FOLLOWING CODE IN FLOATING POINT NUMBERS IN ASSEMBLY LANGUAGE USING MIPS IN MARS .data prompt: .asciiz "\nMaximum number is : " prompt1: .asciiz "\nMinimum number is : " prompt2: .asciiz "\nRange of the array is : " size: .word 10 #load array array: .word 23, -12, 45, -32, 52, -72, 8, 13,22,876 .text #load address of array and size la $s4,array #load address of A lw $t0,size #load i to t0 jal getArrayRange li $v0, 4    la...

  • Question 4) (12 Marks) This question is based on the MIPS assembly code shown below. data...

    Question 4) (12 Marks) This question is based on the MIPS assembly code shown below. data the Array: space 160 main: li $t6, 1 li $17, 4. sw $17, the Array($0) sw $17, theArray($17) li $t0, 8 loop: addi $t3, $t0, -8 addi $t4, $t0, -4 lw 1, the Array($t3) lw $12, the Array(St4) add $15, $t1, $t2 sw $15, theArray($to) addi $t0, $t0, 4 blt $t0, 160, loop jr Sra. Question 4 Assembly code a) what is the contents...

  • Create a program that performs the following operations: 1. Prompt for and accept a string of...

    Create a program that performs the following operations: 1. Prompt for and accept a string of up to 80 characters from the user. • The memory buffer for this string is created by: buffer: .space 80 #create space for string input The syscall to place input into the buffer looks like: li $v0,8 # code for syscall read_string la $a0, buffer #tell syscall where the buffer is li $a1, 80 # tell syscall how big the buffer is syscall 2....

  • I want to calculate Y[2]=X[3]+X[4] I'm not sure that I wrote right codes. .text main ....

    I want to calculate Y[2]=X[3]+X[4] I'm not sure that I wrote right codes. .text main . la $50, x #get base address of x la $s1, y #get base address of y lw $to, 12 ($50)#get data from memory of x[3] lw $t1 , 1 6($50) #get data from memory of x[4] add $t2, $t0, $t1 sw $t2, 8($51 ) #store result to y[2] li $v0, 10 #exit program syscall data x: word 5, 1, 17,-4, 6, 3 y: .word...

  • Write an assembly program that takes two values, a and b, multiplies them, and then stores...

    Write an assembly program that takes two values, a and b, multiplies them, and then stores the result in c. When the program begins: • a is located in $fp + 1 • b is located in $fp + 2 At the end of the program: • a is located in $fp + 1 • b is located in $fp + 2 • c is located in $fp + 3 In doing this, there must be at least one function,...

  • My C++ program is give me extra characters in my output. Below is an example of input.txt and the section of code that reads it. input.txt (x/y), x = 20, y = 5; ((y>x)&(x<z)),x=5,y=10,z=3; o...

    My C++ program is give me extra characters in my output. Below is an example of input.txt and the section of code that reads it. input.txt (x/y), x = 20, y = 5; ((y>x)&(x<z)),x=5,y=10,z=3; output I get: Value=4 20, y=5; Value=0z)), x=5, y=10, z=3; ifstream fin;         fin.open("input.txt");     while (true)     {         symbolTable.init();         fin.getline(line, SIZE);         if (!fin)             break;         stringstream in(line, ios_base::in);         in >> paren;         cout << line << " ";         expression = SubExpression::parse(in);         in >> comma;         parseAssignments(in);         double result = expression->evaluate();         cout...

  • I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that...

    I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. Efficient sorting is important for optimizing the use of other algorithms (such as search and merge algorithms) which require input data to be in sorted lists; it is also often useful for canonical zing data and for producing human-readable output. More formally, the output must satisfy...

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