I am working on a problem for my homework. I have to convert this C++ Code: int multiply(int x, int y) {     int product=0; if(x>y)     for(int i=0;ix)     for(int i=0;i

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I am working on a problem for my homework. I have to convert this C++ Code:

int multiply(int x, int y)
{
    int product=0;
if(x>y)
    for(int i=0;i<y;i++)
        product+=x;
if(y>x)
    for(int i=0;i<x;i++)
        product+=y;
return product;
}

I have received the MIPS Code of: 

multiply(int, int):
        daddiu  $sp,$sp,-48
        sd      $fp,40($sp)
        move    $fp,$sp
        move    $3,$4
        move    $2,$5
        sll     $3,$3,0
        sw      $3,16($fp)
        sll     $2,$2,0
        sw      $2,20($fp)
        sw      $0,0($fp)
        lw      $3,16($fp)
        lw      $2,20($fp)
        slt     $2,$2,$3
        beq     $2,$0,.L2
        nop

        sw      $0,4($fp)
        b       .L3
        nop

.L4:
        lw      $3,0($fp)
        lw      $2,16($fp)
        addu    $2,$3,$2
        sw      $2,0($fp)
        lw      $2,4($fp)
        addiu   $2,$2,1
        sw      $2,4($fp)
.L3:
        lw      $3,4($fp)
        lw      $2,20($fp)
        slt     $2,$3,$2
        bne     $2,$0,.L4
        nop

.L2:
        lw      $3,20($fp)
        lw      $2,16($fp)
        slt     $2,$2,$3
        beq     $2,$0,.L5
        nop

        sw      $0,8($fp)
        b       .L6
        nop

.L7:
        lw      $3,0($fp)
        lw      $2,20($fp)
        addu    $2,$3,$2
        sw      $2,0($fp)
        lw      $2,8($fp)
        addiu   $2,$2,1
        sw      $2,8($fp)
.L6:
        lw      $3,8($fp)
        lw      $2,16($fp)
        slt     $2,$3,$2
        bne     $2,$0,.L7
        nop

.L5:
        lw      $2,0($fp)
        move    $sp,$fp
        ld      $fp,40($sp)
        daddiu  $sp,$sp,48
        jr      $31
        nop

I continue to receive an error in my program QTSpim stating:

syntax error on line 1 of file 
  multiply(int, int):
          ^

How do I go about fixing this issue in my code?

Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY