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
How many people are in Siver, on the game Valorant?
german

Answer:

probably like more than 20

5 0
3 years ago
Type the correct answer in the box. Spell all words correctly.
Pepsi [2]

Answer:

the diaphragm

hope it helps

6 0
2 years ago
Read 2 more answers
A test's directions often clarify any questions a student might have about answering a response question.
alina1380 [7]
True, hope you have Have a good day
8 0
3 years ago
Read 2 more answers
Derek needs to shift from his desk to a new work area in his office. Which ergonomic principle should he follow while moving his
Paul [167]

Answer:

One should be in neutral posture, which is the ergonomic principle that needs to be followed while moving our belongings from one location to the other. Its because in this position the work done is zero, and hence we never lose any energy. And this is the posture you should ensure while you are working. Also, the goods packed when moved in this manner, has least chance of wear and tear. Thus, the goods remain safe.

Also, Derek should keep things in a box with padding and then lift to move them to the new work area.

Explanation:

The answer is self explanatory.

3 0
3 years ago
ILL GIVE BRAINLIEST You are taking a photograph of a valley and want to draw attention to a hamlet hidden amid the hills. Which
lana [24]
Answer: A
Explanation: Because it’s close to the hamlet but not blocking it like option B or drawing attention away from it like option C or D
Hope this helps!
7 0
3 years ago
Read 2 more answers
Other questions:
  • Computers spend most of their time in loops, so multiple loop itera- tions are great places to speculatively find more work to k
    10·1 answer
  • The tone a writer takes is referred to as the writing _____.
    7·2 answers
  • ⭐️⭐️⭐️ what Network is larger in size? MAN or WAN? Thank you ⭐️⭐️⭐️
    5·1 answer
  • MIDI is a A.technology based on placing brief digital recordings of live sounds under the control of a synthesizer keyboard. B.t
    10·1 answer
  • Several new projects are being staffed by outside contractors who will be working on servers in the contractors’ office, not in
    5·2 answers
  • Listed here are a few camera angles and their images.
    10·1 answer
  • There are several design goals in building an operating system; for example, resource utilization, timeliness, robustness and so
    11·1 answer
  • Please what do you guys think about this ?
    10·2 answers
  • How to transfer mysql database from one server to another
    6·1 answer
  • 1.Microsoft Word is a/an ........​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!