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
Kevin needs to get his data from a database into a text file to send to another group. He needs to _____.
Rasek [7]
A.Export

I got it right on test
6 0
2 years ago
Read 2 more answers
Select the correct answer from each drop-down menu.
Dmitry_Shevchenko [17]

Answer:

Suzanne needs a blog

Explanation:

Because she wants to use a digital media tool that acts as a journal and facilitates discussion, Suzanne would need a blog for this.

A blog is a platform where people can meet and have discussions on the internet sometimes in a diary-like format.

Suzanne would need software like WordPress for her blog.

8 0
3 years ago
A group of students are collaborating on an online research project. What is an example of appropriate online behavior?
german
Helping each other out
4 0
3 years ago
Read 2 more answers
What option would fit the most content on a page?
zvonat [6]

Answer:

normal margins will fit the most content on a page

7 0
1 year ago
In addition to explaining the paper’s topic, a thesis statement provides instructions on how to read the paper. explains why the
tamaranim1 [39]

Answer: I believe it’s explains why the paper was written!

Explanation:

Took edge 2021

8 0
3 years ago
Read 2 more answers
Other questions:
  • Jack wants to store a large amount of data on his computer. He chooses to use a database for this purpose. What is a database? A
    8·1 answer
  • Stefan is finalizing his presentation by adding media files and preparing it for distribution. Stefan knows that saving a presen
    13·1 answer
  • Your bank contacts you asking you to phone a number supplied in the email.What do you?
    13·2 answers
  • Of which of the following devices are point, drag, and click actions?
    15·1 answer
  • Which kind of software allows users to draw pictures, shapes, and other graphical images with various on-screen tools such as a
    14·1 answer
  • Applications software is also known as
    14·2 answers
  • The IP protocol (and UDP) are called "connectionless" and "unreliable." Describe what those two words mean in the context of dat
    8·1 answer
  • Need answer ASAP.
    8·1 answer
  • I will have to goste yall im busting my butt off doing homework
    10·2 answers
  • How to install an older version of prettier on yarn
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!