Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a complete MIPS assembly language program that implements the following pseudocode. program h2 define global integer variables w , x , y , z

Write a complete MIPS assembly language program that implements the following pseudocode.

program h2 define global integer variables w, x, y, z -- in the .data section function main()

SysPrintStr("Enter an integer >= 0 for w? ") w SysReadInt() SysPrintStr("Enter an integer >= 0 for x? ") x SysReadInt()

SysPrintStr("Enter an integer < 0 for y? ") y SysReadInt() z 16(w + x) - (3 -y mod 7) SysPrintStr("z = ")

SysPrintInt(z)

SysExit() end function main

end program h2

Miscellaneous program requirements and hints:

Write the code so its output and behavior would match mine shown below, where user input is in bold:

Enter an integer >= 0 for w? 9 Enter an integer >= 0 for x? 17 Enter an integer < 0 for y? -5 z = 415

De ne the four variables w, x, y, and z as words in the .data section. Initialize each to 0.

Place the string literals in the .data section using the .asciiz directive.

Information about the MARS system calls can be found by selecting Help | Help on the main menu (or hit F1). In

the Help window, click on the Syscalls tab. Information on MARS-implemented MIPS32 instructions can be found by clicking on the Basic Instructions and Extended (pseudo) Instructions tabs. Information on MARS-impl- emented assembler directives can be found by clicking on the Directives tab. For this program you will need to use the following directives: .data for the data section; .text for the text section; .word for the de nitions of the inte- ger variables; and .asciiz to place the strings in the data section.

For my solution, I used these MIPS32 instructions so familiarize yourself with them: add (addition), addi (addi- tion with an immediate), div (division), lw (load word), mul (multiplication), sll (shift logical left), sub (sub- traction), sw (store word), syscall (perform system call). I also used these pseudoinstructions: la (load address), and neg (negate). Note: MARS implements many non-standard pseudoinstructions, documented in the Help sys- tem. You are not permitted to use these non-standard pseudoinstructions in your homework assignments or exams. The only instructions you may use are those that we discussed and are documented in the notes. The rea

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

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago