# Lab 5 Name: I.Kalyan Anudeep Roll No.: CS22B025 --- ## Question 1 **Code** (if required) ```assembly= .data demo: .string "This is where you can display your assembly code" ``` ```c= .data .word 0x1 0x1 0x5 0x6 0x7 0x5 0x6 0x4 0x4 0x8 0x6 0x7 base: .word 0x10000000 str: .string " " .text lw x16 base addi x4 x0 3 addi x5 x0 0 addi x8 x0 0 addi x7 x0 3 addi x20 x0 12 Loop1: lw x6 44(x16) addi x6 x6 3 sw x6 44(x16) addi x16 x16 -4 lw x6 44(x16) addi x6 x6 3 sw x6 44(x16) addi x16 x16 -4 lw x6 44(x16) addi x6 x6 3 sw x6 44(x16) addi x16 x16 -4 lw x6 44(x16) addi x6 x6 3 sw x6 44(x16) addi x16 x16 -4 addi x5 x5 1 bne x7 x5 Loop1 lw x16 base Loop2: lw x1 0(x16) li a7 1 addi a0 x1 0 ecall li a7 4 la a0 str ecall addi x16 x16 4 addi x8 x8 1 bne x8 x20 Loop2 ``` _You can use either one of these according to the question_ **1** ![1image](https://hackmd.io/_uploads/rJG8wlTnp.jpg) Before Optimization ![2image](https://hackmd.io/_uploads/HyZOPlThp.jpg) After Optimization 1. As IPC=Instruction count/(Execution time * Clock Frequency) 2. Before Optimization value of IPC is 0.74 3. After Optimisation value of IPC is 0.71 **Observation:** (if required) This is where you will write your observations * Line 1 * Line 2 * Line3 --- ## Question 2 **Code** (if required) ```assembly= .data demo: .string "This is where you can display your assembly code" ``` ```c= .data node1: .word 11 .word 0 node2: .word 2 .word 0 node3: .word 4 .word 0 node4: .word 6 .word 0 node5: .word 7 .word 0 node6: .word 56 .word 0 node7: .word 43 .word 0 node8: .word 78 .word 0 node9: .word 90 .word 0 node10: .word 12 .word 0 .text la x12 node1 la x13 node2 la x14 node3 la x15 node4 la x16 node5 la x17 node6 la x18 node7 la x19 node8 la x20 node9 la x21 node10 sw x13 4(x12) sw x14 4(x13) sw x15 4(x14) sw x16 4(x15) sw x17 4(x16) sw x18 4(x17) sw x19 4(x18) sw x20 4(x19) sw x21 4(x20) sw x20 4(x21) sw x19 4(x20) sw x18 4(x19) sw x17 4(x18) sw x16 4(x17) sw x15 4(x16) sw x14 4(x15) sw x13 4(x14) sw x12 4(x13) ``` _You can use either one of these according to the question_ **2 a** Your answer **2 b** Your answer **2 c** Your answer **Observation:** (if required) This is where you will write your observations * Line 1 * Line 2 * Line3 --- ## Question 3 **Code** (if required) ```assembly= .data demo: .string "This is where you can display your assembly code" ``` ```c= #allocating 10 nodes .equ NODE_SIZE 8 j main .global allocate_node allocate_node: addi sp sp -8 lw a0 NODE_SIZE(sp) j Loop .global main main: addi x5 x0 10 addi x4 x0 0 Loop: addi x4 x4 1 bne x4 x5 allocate_node ``` _You can use either one of these according to the question_ **3 a** Your answer **3 b** Your answer **3 c** Your answer **Observation:** (if required) This is where you will write your observations * Line 1 * Line 2 * Line3 ---