** Please show your output to the program to see if it is running correctly. Int
ID: 3831384 • Letter: #
Question
** Please show your output to the program to see if it is running correctly.
Introduction In this lab, you will convert a C program with functions into a MIPS program Feel free to do this lab (and all assembly programming labs) in Windows. You must use MARS Getting started 1. In MARS, create a new assembly file with the name hailstone. asm. 2. Use the following code to get started: Description Data segment data our data will go here Code segment text globl MAIN MAIN our code will go here EXIT #End of file 3. Assemble the file (F3). You should receive no warnings or errors. Requirements: 1. The following is a C program that reads in a positive value from the user and then outputs a sequence of numbers, starting with the input value as the first number, such that, if the current number is even, then the next number output is the current number divided by 2, otherwise the next number output is the current number, multiplied by 3, plus 1. This process continues while the current number is greater than 1. #include "stdio.h" int divide-by-20int)Explanation / Answer
.data
.text
.globl main
main:
#set syscall to get integer from user
li $v0,5
syscall
#perform bitwise AND and store in $a0
move $s0, $v0
and $a0,$v0,1
#jump to odd if the result of the AND operation
beq $a0,1,odd
even:
#load $s0/2, and print
li $v0,1
div $s0, $s0, 2
move $a0, $s0
syscall
#exit program
li $v0,10
syscall
odd:
#load $s0*3+1, and print
li $v0,1
mul $s0, $s0, 3
add $s0, $s0, 1
move $a0, $s0
syscall
#exit program
li $v0,10
syscall
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.