QuestionQuestion

In this project, you’ll be getting some basic experience with how to write assembly language. You will write a main() function. In main(), you will read four different variables, which will tell you what sorts of operations you must perform. For each of these four operations, you will read a set of four other variables and use the values in your calculations.

For instance, one testcase might be:

.data
print: .word 1
sum: .word 0
multiply: .word 0
minimum: .word 1
foo: .byte 0
bar: .word 42
baz: .word 17
fred: .half -123

Your program will read the values of print, sum, multiply, and minimum. For each that is nonzero, your program will perform that operation; you may have to perform zero, one, or multiple operations.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

.data
msg1: .asciiz "Printing the four values:"
msg2: .asciiz "Running totals:"
msg3: .asciiz "\"Multiplying\" each value by 7:"
msg4: .asciiz "Minimum:"
newline: .asciiz "\n"
blank: .asciiz " "
blank2: .asciiz " "
.text
main:
# Function prologue -- even main has one
addiu $sp, $sp, -24   # allocate stack space -- default of 24 here
sw    $fp, 0($sp)    # save caller's frame pointer
sw    $ra, 4($sp)    # save return address
addiu $fp, $sp, 20    # setup main's frame pointer

lw $t0, print # t0 = print
beq $t0, 0, action2 # if print==0 skip to action2

la $a0, msg1 # printing the message
addi $v0, $zero, 4
syscall

la $a0, newline # printing new line
addi $v0, $zero, 4
syscall

lb $a0, foo # printing foo
addi $v0, $zero, 1
syscall

la $a0, newline # printing new line
addi $v0, $zero, 4
syscall

lw $a0, bar #printing bar
addi $v0, $zero, 1
syscall...

By purchasing this solution you'll be able to access the following files:
Solution.s.

$35.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Assembly Language Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats