
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The execution of a spim code block on the gt mips datapath. It explains how some instructions, such as 'la $t0, start', are translated into native instructions and provides examples. The document also mentions the optimization capabilities of the spim assembler and the assumptions that can be made about instruction translations. The text segment starts at 0x00400000 and the data segment starts at 0x10010000.
Typology: Study notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Consider the execution of the following block of SPIM code on the GT MIPS datapath. The
text segment starts at 0x00400000 and the data segment starts at 0x10010000. You may make
assumptions about how some of these instructions are translated into native instructions. For
example, some instructions may have to be translated into two native instructions.
What are the values of the following.
The preceding solution is based on what you would see if you placed this program in the
SPIM simulator. If we made the assumption (a reasonable one) that instructions of the form
“la $t0, start” are translated into two instructions the first two answers would be 0x0040002c
and 0x00400014. This answer would be acceptable.
The reality is that the SPIM assembler is able to optimize away one instruction. Recall that the
reason the la instruction cannot be encoded on one 32-bit word is that the I-format instruction
has only 16 bits for the immediate operand. The value of an address label such as start
requires 32-bits. Check the SPIM code that is produced.
exit 0x
Top 0x
addi $t3, $t3, -1 (the encoding) 0x216bffff
.data start: .word 0x32, 44, Top, 0x str: .asciiz “Top” .align 8 end: .space 16 .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 addi $t3, $t3, - bne $t3, $zero, Top exit: li $v0, 10 syscall