Question

Turn the Following c-code into MIPS assembly code. You are given the main procedure which calls...

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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

Add a comment
Know the answer?
Add Answer to:
Turn the Following c-code into MIPS assembly code. You are given the main procedure which calls...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT