Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise #4. Consider the execution of the following block of SPIM code. The text segment starts at 0x00400000 and that the data segment starts at

image text in transcribed

Exercise #4. Consider the execution of the following block of SPIM code. The text segment starts at 0x00400000 and that the data segment starts at Ox 10010000. Note that some instructions may be pseudoinstructions or directives, which are explained in the below. data start: Word Ox32, 44, Top, 0x33 str: asciiz "Top" .align 8 end: .space 16 exit: addi $t3, $t3, -1 bne St3, Szero, Top li $v0,0 syscall .text .globl main main: li $t3, 4 la $t0, start la $t1, end Top: lw $t5, 0($t0) sw $t5, 0($t1) addi $t0,$t0,4 addi $t1,$t1,4 Directives: .text - Program section in memory .data - Data section in memory .alignn - Align the next datum in 2" bytes boundary in memory location .byte bytel, byte2,... - Store byte data in memory (consecutive locations in data section) word word1, ... - Same as above but store word data instead of byte data asciiz str - Store the string in memory and null-terminate it. .space n - Allocate bytes of space in the current segment. Pseudo- and "syscall" instruction: "li Sd, data" - Load data to register $d (addi $d, SO, data) "la $d, address" - Load "address" to register $d - Should be translated into two instructions, "lui $d, upper-16-bit-address" and "ori $d, $d, lower-16-bit-address" "syscall" - CPU halts (a) What are the values of the following. Note that all instructions are 4 bytes wide (32 bits) but the pseudo-instruction "la" takes 2 instructions or 8 bytes. exit Top (b) What does the program do? Exercise #4. Consider the execution of the following block of SPIM code. The text segment starts at 0x00400000 and that the data segment starts at Ox 10010000. Note that some instructions may be pseudoinstructions or directives, which are explained in the below. data start: Word Ox32, 44, Top, 0x33 str: asciiz "Top" .align 8 end: .space 16 exit: addi $t3, $t3, -1 bne St3, Szero, Top li $v0,0 syscall .text .globl main main: li $t3, 4 la $t0, start la $t1, end Top: lw $t5, 0($t0) sw $t5, 0($t1) addi $t0,$t0,4 addi $t1,$t1,4 Directives: .text - Program section in memory .data - Data section in memory .alignn - Align the next datum in 2" bytes boundary in memory location .byte bytel, byte2,... - Store byte data in memory (consecutive locations in data section) word word1, ... - Same as above but store word data instead of byte data asciiz str - Store the string in memory and null-terminate it. .space n - Allocate bytes of space in the current segment. Pseudo- and "syscall" instruction: "li Sd, data" - Load data to register $d (addi $d, SO, data) "la $d, address" - Load "address" to register $d - Should be translated into two instructions, "lui $d, upper-16-bit-address" and "ori $d, $d, lower-16-bit-address" "syscall" - CPU halts (a) What are the values of the following. Note that all instructions are 4 bytes wide (32 bits) but the pseudo-instruction "la" takes 2 instructions or 8 bytes. exit Top (b) What does the program do

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions