Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Turn the Following c-code into MIPS assembly code. You are given the main proced

ID: 3890851 • Letter: T

Question

Turn the Following c-code into MIPS assembly code.

You are given the main procedure which calls multiply.

You are also given the argument registers to be used.

/* C-program */

int multiply (int number, int times)

{

int f;

f = number * times

return f;

}

# MIPS PROGRAM

# assumes we have called the program leaf_example

# $a0=number, $a1=times, $s0=f

main:

$addi $a0,$zero,3

$addi $a1,$zero,2

jal multiply # place the address into $ra

j EXIT2

EXIT2: j OS

###############################################

# SOLUTION CODE GOES BELOW

Explanation / Answer

The MIPS code is given below for your C code:

code:

.file 1 ""

.section .mdebug.abi32

.previous

.nan legacy

.module fp=32

.module nooddspreg

.abicalls

.text

.align 2

.globl multiply

.set nomips16

.set nomicromips

.ent multiply

.type multiply, @function

multiply:

.frame $fp,24,$31 # vars= 8, regs= 1/0, args= 0, gp= 8

.mask 0x40000000,-4

.fmask 0x00000000,0

.set noreorder

.set nomacro

addiu $sp,$sp,-24

sw $fp,20($sp)

move $fp,$sp

sw $4,24($fp)

sw $5,28($fp)

movz $31,$31,$0

lw $3,24($fp)

lw $2,28($fp)

nop

mult $3,$2

mflo $2

sw $2,8($fp)

lw $2,8($fp)

move $sp,$fp

lw $fp,20($sp)

addiu $sp,$sp,24

j $31

nop

.set macro

.set reorder

.end multiply

.size multiply, .-multiply

.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"

Hope This Helps, if you have any doubts Please comment i will get back to you, thank you and please thumbs up

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote