In this lab we will be using segments in our assembly program. We will now start...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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:\n" 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 -- 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:\n" 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 --
Expert Answer:
Related Book For
Posted Date:
Students also viewed these accounting questions
-
Describe how you would select a supplier partner and the criteria you would use.
-
establishing minimum qualification standards for specific marketing and or sales jobs would most closely be associated with which support activity
-
(c) (i) A firm wants to obtain information on the hours of overtime work of employees. Stratified random sampling is used and the employees are stratified as follows: Stratum Nh S Managers 25 36...
-
Three balls A, B, and C, with masses of 3 kg, 1 kg, and 1 kg, respectively, are connected by massless rods. The balls are located as in Figure. What are the coordinates of the center ofmass? y. m 1...
-
Explain with reference to Figure 5.13 how Capital One has achieved competitive advantage through creating value through e-business.
-
On the Internet, research the topic of manufacturing cells and write a brief report on company experiences using those cells.
-
During 20x6, Chester Corporation reported a net income of $1,529,500. On January 1, Chester had 1,400,000 shares of common stock outstanding. The company issued an additional 840,000 shares of common...
-
1. Economic profit equals ________minus________. 2. Economic cost equals ________cost plus ________cost. 3. For a perfectly competitive firm, marginal revenue equals ________, and to maximize profit,...
-
If using the FIFO method to calculate ending inventory, the first units purchased are assumed to be the last units sold. True False
-
A piston moves upward a distance of 5cm while 200 J of heat is added as shown. Calculate the change in internal energy of the vapor if the spring is originally not stretched. K = 50 kN/m 60 kg Water...
-
The cost of goods sold computations for Crane Company and Bramble Company are shown below. Crane Company Bramble Company Beginning inventory $ 49,000 $ 73,000 Cost of goods purchased 266,080 254,500...
-
Do we need a MS SQL Server for a small to medium size organization, may be if their data needs are greater, an Oracle database?
-
Assume 20% of the population has an average income of 10 cents (because 20% of the population has a daily income below 20 cents). Assume 15% of the population has an average income of 30 cents...
-
After having read A Doll's House, explain which literary theory you think is most appropriate to discuss either the play as a whole or a specific aspect of it.
-
Investigate the role of computational fluid dynamics (CFD) in hydraulic engineering, focusing on its application in modeling complex flow phenomena and optimizing the design of hydraulic structures...
-
Moe's reservation price for his economics textbook is $100. Theweek before the semester begins, Moe finds a copy of his textbookonline for $75. Moe's consumer surplus from buying the textbookonline...
-
Gordon and Lisa estimate that they will need $1,875,000 in 40 years for their retirement years. If they can earn 8 percent annually on their funds, how much do they need to save annually?
-
Lower of Cost and Net Realizable Value} Silk Road Systems sells a limited line of specially made products, using television advertising campaigns in large cities. At year-end, Silk Road has the...
-
During 20x7, Minh Corporation had a net income of $144,000. Included on its income statement were depreciation expense of $16,000 and amortization expense of $1,800. During the year, Accounts...
-
During 20x7, Howard Company purchased land for $375,000. It paid $125,000 in cash and signed a $250,000 mortgage for the rest. The company also sold a building that originally cost $90,000, on which...
Study smarter with the SolutionInn App