Values of SPIM Code Execution: GT MIPS Datapath, Study notes of Electrical and Electronics Engineering

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

Pre 2010

Uploaded on 08/04/2009

koofers-user-bm8
koofers-user-bm8 🇺🇸

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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 0x00400028
Top 0x00400010
addi $t3, $t3, -1 (the encoding) 0x216bffff
.data
start: .word 0x32, 44, Top, 0x33
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, -1
bne $t3, $zero, Top
exit: li $v0, 10
syscall

Partial preview of the text

Download Values of SPIM Code Execution: GT MIPS Datapath and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

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