Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(USING THE PROGRAM MARS) Using the MemoryAccess program we wrote in class as a starting point, write a program called LoadStore # Title : Memory

(USING THE PROGRAM MARS) Using the MemoryAccess program we wrote in class as a starting point, write a program called LoadStore

# Title : Memory access.asm #Desc: Practice initially memory, #in val1 = 0x0a; #int val2 = 0x0b; #int result; #string resultstring = " final answer : "; #string returnchar = " "; #void main() { # result = val1 + val2; # cout<<< resultstring << returnchar; #} .data val1: .word 0x0a #store 0xa into variable val1 val2: .word 0x0b #store 0xb into val2 result: .word 0 #destination resultstring: .asciiz "final answer is: " returnchar: .asciiz " "

.text .globl main main: #load our values into registers lw $t0, val1 lw $t1, val2 #do the math add $t0, $t0, $t1 #store the total back into result sw $t0, result #series of 3 prints. string then number then string li $v0, 4 #syscode for printing a string la $a0, resultstring #address of string to print syscall #print an integer li $v0, 1 #syscode for printing an int lw $a0, result #we want the value in $a0 syscall #print return charater li $v0, 4 la $a0, returnchar syscall #get out of dodge li $v0, 10 syscall

^^^^^^^^^^^^^^^^^^memory access program

The Algorithm for your program is as follows:

  1. Ask the user for a first number
  2. Get that number
  3. Store that number to val1 in Data Storage
  4. Ask the user for a second number
  5. Get that number
  6. Store that number to val2 in Data Storage
  7. Ask the user for a third number
  8. Get that number
  9. Store that number to val3 in Data Storage
  10. Load val1, val2 and val3 into $s0, $s1 and $s2
  11. Set $s3 to $s0 + $s1 - $s2
  12. Store $s3 into results
  13. Print the final answer. This could be tricky
  14. Exit cleanly as always.

Your output should look as follows (Example User Input is shown in bold):

Please enter the first number: 12 Please enter the second number: 13 Please enter the third number: 14 Result: 12 + 13 14 = 11

---------------------------------------

Hint: The operators are strings

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

Discuss the goals of financial management.

Answered: 1 week ago