Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following code is in a text file, I need to have C++ read that code, assembl

ID: 3543218 • Letter: T

Question

The following code is in a text file, I need to have C++ read that code, assemble the instructions and then output it into a file but I'm not entirely sure how to do this. My idea so far as been to write a code that parses each string and then just using s.find and then if else on la, addi to determine the function needed (in order). The issues I'm running into are how do I get the values or byte data out and also since C++ builds the solution from top to bottom, how do I get it to recognize the values since they are after the function assuming that the data for the function will always follow the "main:"


.text

       

main:

la $a0, mystery

addi $v0,$zero, 4

syscall


addi $v0, $zero, 10

syscall



.data


mystery: .byte 71

.byte 111

.byte 32

.byte 72

.byte 111

.byte 107

.byte 105

.byte 101

.byte 115

.byte 33

.byte 10

Explanation / Answer

Can you read MIPS assembler code? Start off by commenting the MIPS code snippet. What is it doing? What is the logical meaning of inputs used by the snippet; of outputs passed out of the snippet?Once you know what the MIPS code does, write a C++ program that does the same thing. You should definitely NOT focus on translating each line of assembler into an equivalent line of C++.
This little snippet of MIPS code doesn't stand alone. How do you get into it; how do you get out of it? Is this perchance an assembly language function called from a C++ program? If so, look at the context in the C++ program around where the MIPS function is called. That might give you a clue to what the snippet is supposed to do.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote