1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Arlecino [84]
3 years ago
6

4-Translate the following C program to MIPS assembly program (Please explain each instruction in your code by a comment and subm

it a .asm file) int main() { char Str1[6]= {'h','e','l','l','o','\0'}; char Str2[5]= {'m','a','r','s','\0'}; int i, j; i = 0; while( Str1[i]!='\0') { i++; } j = 0; while( Str2[j]!='\0') { Str1[i] = Str2[j]; i++; j++; } Str1[i] = '\0'; printf("\n String after the Concatenate = %s", Str1); return 0; }
Computers and Technology
1 answer:
earnstyle [38]3 years ago
3 0

Answer:

.data

str1: .asciiz "Hello"

str2: .asciiz "mars"

msg: .asciiz "String after the concatenate: "

.text

main:

#load the address str1 to $a0

la $a0,str1

#initialize $t0 with 0

li $t0,0

#loop to find the length of str1

#$t0 stores the length of str1

loop1:

#load byte of $a0 to $t1

lb $t1,0($a0)

#branch for equal.If $t1 equal to 0,jump to label stop1

beq $t1,0,stop1

addi $t0,$t0,1 #increase the count

addi $a0,$a0,1 #increase the address

#jump to label loop1

j loop1

stop1:

#load the address of str2 to $a1

la $a1,str2

#loop2 concatenate the each element in str2 to str1

loop2:

lb $t2,0($a1) #load character in str2 to $t2

sb $t2,0($a0) #store value in $t2 to str1

beq $t2,0,stop2

addi $a1,$a1,1 #increase the address of str2

addi $a0,$a0,1 #increase the address of str1

j loop2

stop2:

#syscall for print string is $v0 = 4

#syscall to termiante the program is $v0 = 10

#print the message

li $v0, 4

la $a0, msg

syscall

#print the concatenated string

li $v0,4

la $a0,str1

syscall

#termiante the program

li $v0, 10

syscall

Explanation:

You might be interested in
Which of the following factors will have the greatest impact on your credit score?1. Length of credit history 11. Payment histor
irinina [24]
I believe your payment history would have the greatest impact on your credit score
4 0
4 years ago
Juan has performed a search on his inbox and would like to ensure the results only include those items with attachments which co
Mars2501 [29]

Answer:

refine

Explanation:

3 0
3 years ago
Read 2 more answers
A(n) ____________ is a group of similar or identical computers, connected by a high-speed network, that cooperate to provide ser
scoundrel [369]

Answer:

cluster

Explanation:

A cluster in a computer system is a collection of servers and other resources that work together to provide high reliability and, in certain situations, load balancing and parallel processing.

6 0
2 years ago
Pls someone help me with these four questions
ipn [44]

Answer:

16. Grace Hopper. 1959.

8 0
3 years ago
Type the correct answer in each box. Spell all words correctly. Programmers utilize to convert a program from language, which is
natulia [17]

Answer: Binary

Explanation: Binary is a system of 1s and 0s that tell the system when and where to flip a digital switch very fast

3 0
3 years ago
Other questions:
  • Assume you have the following array: int[] values = new int[15]; What will happen if the following code is executed? int[15] = 2
    12·1 answer
  • A(n) _ is a book of synonyms.
    14·1 answer
  • You are trying to access the Wi-Fi network at a coffee shop. What protocol will this type of wireless networking most likely use
    11·1 answer
  • Which option will you use to expose your presentation to the audience
    11·2 answers
  • The measure of how quickly things may be converted to something of value is called.
    10·2 answers
  • Assume the existence of an UNSORTED ARRAY of n characters. You are to trace the CS111Sort algorithm (as described here) to reord
    14·1 answer
  • When a primitive type variable is passed as an argument to a method, what is passed into the receiving method's parameter variab
    12·1 answer
  • Could u help me on this u just have to compare how its alike please help ​
    5·2 answers
  • Choose one skill needed to become Computer Network Administrator?
    10·2 answers
  • 1. Who was able to complete the puzzle the fastest in Trial 1?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!