COMP 122 Problem set 3 (Fall 2018 ) Your Name COMP 122: Computer Architecture November 29, 2019 Problem 1. Convert the following code to MIPS: 1 int main() 2 { 3 printf("Hello, World!"); 4 return 0; 5...

1 answer below »
Please take a look on this pdf


COMP 122 Problem set 3 (Fall 2018 ) Your Name COMP 122: Computer Architecture November 29, 2019 Problem 1. Convert the following code to MIPS: 1 int main() 2 { 3 printf("Hello, World!"); 4 return 0; 5 } Problem 2. Convert the following C code to MIPS 1 int result[100]; 2 int main () 3 { 4 int i = 0; 5 for (int i = 0; i <100; i+="0)" 6="" {="" 7="" result[i]="i;" 8="" }="" 9="" }="" problem="" 3.="" convert="" the="" following="" mips="" code="" to="" c="" 1="" 1="" .data="" 2="" sz:="" .word="" 10="" 3="" array:="" .word="" 1,="" 1,="" 2,="" 3,="" 5,="" 8,="" 13,="" 21,="" 34,="" 55="" 4="" .text="" 5="" main:="" 6="" lw="" $t0,="" sz="" 7="" move="" $t1,="" $zero="" 8="" move="" $t2,="" $zero="" 9="" 10="" back:="" 11="" bge="" $t1,="" $t0,="" end="" 12="" sw="" $t1,="" array($t2)="" #shift="" 13="" addi="" $t1,="" $t1,="" 1="" 14="" addi="" $t2,="" $t2,="" 4="" 15="" j="" back="" 16="" 17="" end:="" problem="" 4.="" unroll="" the="" following="" code="" (in="" c)="" 1="" int="" result[10];="" 2="" int="" main="" ()="" 3="" {="" 4="" int="" i="0;" 5="" for="" (int="" i="0;" i=""><10; i+=0) 6 { 7 result[i] = i; 8 } 9 } problem 5. unroll the following code (in mips) 1 .data 2 sz: .word 10 3 array: .word 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 4 .text 5 main: 6 lw $t0, sz 7 move $t1, $zero 8 move $t2, $zero 9 10 back: 11 bge $t1, $t0, end 12 sw $t1, array($t2) #shift 13 addi $t1, $t1, 1 14 addi $t2, $t2, 4 15 j back 16 17 end: i+="0)" 6="" {="" 7="" result[i]="i;" 8="" }="" 9="" }="" problem="" 5.="" unroll="" the="" following="" code="" (in="" mips)="" 1="" .data="" 2="" sz:="" .word="" 10="" 3="" array:="" .word="" 1,="" 1,="" 2,="" 3,="" 5,="" 8,="" 13,="" 21,="" 34,="" 55="" 4="" .text="" 5="" main:="" 6="" lw="" $t0,="" sz="" 7="" move="" $t1,="" $zero="" 8="" move="" $t2,="" $zero="" 9="" 10="" back:="" 11="" bge="" $t1,="" $t0,="" end="" 12="" sw="" $t1,="" array($t2)="" #shift="" 13="" addi="" $t1,="" $t1,="" 1="" 14="" addi="" $t2,="" $t2,="" 4="" 15="" j="" back="" 16="" 17="">
Answered Same DayNov 29, 2021

Answer To: COMP 122 Problem set 3 (Fall 2018 ) Your Name COMP 122: Computer Architecture November 29, 2019...

Gaurav answered on Dec 01 2021
136 Votes
Problem -1
    .data
str:    .asciiz "Hello, World!"    
    .text
main:
    la $a0, str
    li $v0, 4
    syscal
l        # printf    
    li $v0, 10
    syscall        # exit
Problem -2
        .data
result: .space 400        # result[100] in words
    .text
main:
    la $t0, result        # address of the result
    li $t1, 0        # i = 0
loop:    
    sw $t1, 0($t0)        # result[i] = i
    addi $t0, $t0, 4    # result += 4
    addi $t1, $t1, 1    # i++    
    ble $t1, 100, loop    # while(i...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here