Question

C2. Convert the following c-code to MIPS code. The base memory address of the array a is 0x8000_400C, which must be loaded in

0 0
Add a comment Improve this question Transcribed image text
Answer #1
.file   1 ""
        .section .mdebug.abi32
        .previous
        .nan    legacy
        .module fp=32
        .module nooddspreg
        .abicalls
        .text
        .align  2
        .globl  main
        .set    nomips16
        .set    nomicromips
        .ent    main
        .type   main, @function
main:
        .frame  $fp,64,$31              # vars= 48, regs= 1/0, args= 0, gp= 8
        .mask   0x40000000,-4
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro
        addiu   $sp,$sp,-64
        sw      $fp,60($sp)
        move    $fp,$sp
        sw      $0,8($fp)
        b       $L2
        movz    $31,$31,$0
        nop

$L3:
        lw      $3,8($fp)
        nop
        move    $2,$3
        sll     $2,$2,1
        addu    $3,$2,$3
        lw      $2,8($fp)
        nop
        sll     $2,$2,2
        addiu   $4,$fp,8
        addu    $2,$4,$2
        sw      $3,4($2)
        lw      $2,8($fp)
        nop
        addiu   $2,$2,1
        sw      $2,8($fp)
$L2:
        lw      $3,8($fp)
        li      $2,10                   # 0xa
        bne     $3,$2,$L3
        nop

        move    $2,$0
        move    $sp,$fp
        lw      $fp,60($sp)
        addiu   $sp,$sp,64
        j       $31
        nop

        .set    macro
        .set    reorder
        .end    main
        .size   main, .-main
        .ident  "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609"
Add a comment
Know the answer?
Add Answer to:
C2. Convert the following c-code to MIPS code. The base memory address of the array a is 0x8000_4...
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
  • C3. Convert the following C-code to MIPS code. [Use register $al for the variable i, temporary re...

    C3. Convert the following C-code to MIPS code. [Use register $al for the variable i, temporary registers for other values, and load the base memory address of the array OxA0000080 to Şao] int i i int array [101; for (i= 0; i<5 ; i=i+1 ) { [i+1] [i] 8; * array = array C3. Convert the following C-code to MIPS code. [Use register $al for the variable i, temporary registers for other values, and load the base memory address of...

  • IN MIPS AND MUST RUN IN QTSPIM Translate the following C code to MIPS assembly code....

    IN MIPS AND MUST RUN IN QTSPIM Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a, b, i and j are stored in registers Ss0, Ss1, St0 and Stl, respectively. Also assume that register Ss2 holds the base address of the array D. for (i=0; i<a; itt) for (i-0j<b:jt+)

  • B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: ...

    B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write MIPS assembly code segment for the following C code snippet for (i - 0, i < 100; i++) -array Register assignment: i-) $ao Base of array -> $s0 array [ i+1] [i] / 2; B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write...

  • 7. Translate the following C code to MIPS assembly code. Use a minimum number of instructions....

    7. Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a,b, i and j are in registers Ss0, Ss1, St0, and St1, respectively. Also, assume that register SS2 holds the base address of the array D. for(i-0; i<a; i++) for(j=0 ; j<b; j++)

  • Write an equivalent MIPS code for the following C code. Assume that the base address of...

    Write an equivalent MIPS code for the following C code. Assume that the base address of an array A is stored in register 450. Variables x, i, j and h are stored in registers $t0,$t1, $t2 and $t3 respectively. do{ x = x + A[i]; i = i + j; } (while i != h); Make sure your MIPS code has sufficient comments.

  • its brr[8] (40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program...

    its brr[8] (40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the required directives). You can use any register. You must comply, however, with the convention of register usage. Before writing your code perform an explicit register allocation phase. Note that the C snippet is int arr[8]; int brr[4]-{1, 2, 3, 4, 5, 6, 7, 8) int i-8; while (i>-0) arrli]-brr[i-); (40%) Convert the following C-pseudo code into MIPS assembly code...

  • 1. Convert the following C statement to MIPS code. Assume x, y and z are assigned...

    1. Convert the following C statement to MIPS code. Assume x, y and z are assigned to registers $s0, $s1 and $s2 respectively and the starting address of array A is $s6. x = y + z + A[3] 2. 2.Convert the following C statement to MIPS code. Assume the base address of array A is $s3 and h is assigned to register $s2 . A[7] = h + A[7]

  • CS51 Lab 8 1. Assume x goes to Ss0, y goes to $s1, and z goes to Ss2. Convert the following C cod...

    CS51 Lab 8 1. Assume x goes to Ss0, y goes to $s1, and z goes to Ss2. Convert the following C code to MIPS. Use labels Else, Exit, and Loop when needed MIPS if (x== y) { y=y+z; else z=z-x; while (x < z) ( y=y-z; for (int x=1; x < 5; x++){ Y--i Assume x goes to $a0, y goes to Sa1, and z goes to $a2. Convert the folowing C code to MIPS. Include a statement to...

  • Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b,...

    Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigened to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. Assume that the base address of the array A and B is in register $a0 and $a1 respectively. if (a > 0)            b = a + 10;            else                b = a - 10;

  • MIPS assembly language Implement the following code in MIPS int array [ ] {2, 3, 4,...

    MIPS assembly language Implement the following code in MIPS int array [ ] {2, 3, 4, 5, 6); int main) int num, position; scanf("%d",&num) ; position search(array, printf("The position is: num, 5); %d\n",positio int search(int array, int num, int size int position =-1; for(int i-0;i<size; i++) if(array [i]=num) { position-i; break; return position; Register map $s1: position $a0: array address $a1: num . $a2: size . $VO: return value

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