Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this lab we will be using segments in our assembly program. We will now start adding in the data segment in addition to
In this lab we will be using segments in our assembly program. We will now start adding in the "data" segment in addition to the ".text" segment as discussed in class previously. As a reminder, the "text" segment will contain instructions that our program will run and the "data" segment will contain labels, or addresses, that contain the locations of larger pieces of information, such as strings of text or arrays. For this lab, we will use the ".data" segment to allow us to print more detailed instructions to the user for how our program works and what we are expecting to be entered as user input. We will also create two basic operations as part of our "text" section for our program to do after getting in user input. The goal for this lab will be to create strings to give the user information about our program, prompt the user both for input, and to give them information about what we are printing out for each section. Instructions: Name your program Lab2LastNameFirstName.asm Keep both sections in the same file. Refer to the quick example of the MIPS segments and the syscall table as needed. In general, we will setup items in the .data segment as follows: o Label: .dataType data o So for a String prompt we would use a label, then the asciiz data typing (since it's a string of ASCII characters), and then the String we want to print. o TextPromt: .asciiz "Enter a value: " o Notice we must again do our own formatting, such as adding the new line in the above String (assuming we want a new line at that location). Section 1 - Read in two input values and output the result of adding these two values together. o You don't need to store the input values long term, just long enough to use them. Be sure to prompt the user for each input and then let them know what you are outputting in a readable format. Section 2 - Read in a string and repeat that string back to the user. o For this one we will need to have an address with enough space created to store the input string. The general form of this will be in the data segment as follows: Label: .space # Where # is a value for how much space we are allocating to hold our string. Keep it to a small number for this lab, 1 byte per character is needed, but keep in mind our alignment restriction. I recommend going one multiple of 4 over what you think you need for now. We then need to load the address that this label is at to store the string there, so that we can retrieve it later for printing. 0 Remember to still prompt and to give the user information about what you are printing. Submission: Submit only your asm file to Moodle. You may leave it as a draft so that you can easily make changes to your submission should you upload the wrong file, catch a mistake, etc. However, remember that I can only see the time of the final upload, not every upload, so I can only use the final submission time to go by. Double check that you have correctly uploaded the right file before leaving. By either uploading a draft or submitting the assignment you are agreeing to the academic honesty policy as noted in the syllabus. Sample Output: Note: the bold, underlined portions are user input not something you need to do. As always, your program output does not need to match mine exactly. This section of the program will take in two values, add them together, and then return the result. Enter the first value: 2 Enter the second value: 3 The sum of the two values is: 5 This section of the program will take in a string and echo it back to you. Enter your string here: Hello, world! The string you entered is: Hello, world! - program is finished running --
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started