TranslateMIPS

TranslateMIPS - assembly inst op rs rt rd shamt func...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
6/3/10 1 Translating into machine code assembly inst op rs rt rd shamt func comment add $s0, $0, $0 # i = 0 slti $t0, $s0,100 # t0 <= (i < 100 ?) beq $t0, $0, end # if (i >= 100) goto end la $t0, A # t0 <= r0 + A lw $t2, 0($t1) # ti <= M[A+i] = A[i] addi $s0, $s0, 1 # i++ jump loop # goto loop Translating into machine code assembly inst op rs rt rd shamt func comment add $s0, $0, $0 0 0 32 # i = 0 slti $t0, $s0,100 10 # t0 <= (i < 100 ?) beq $t0, $0, end 4 # if (i >= 100) goto end la $t0, A 8 # t0 <= r0 + A lw $t2, 0($t1) 35 # ti <= M[A+i] = A[i] addi $s0, $s0, 1 8 # i++ jump loop 2 # goto loop 1. Begin with op codes listed in MIPS reference sheet MIPS Registers – 32 registers Name Reg Number Usage Preserved across call? $zero 0 The constant 0 Yes $v0-$v1 2-3 Function results No $a0-$a3 4-7 Arguments Yes??? $t0-$t7 8-15 Temporaries No $s0-$s7 16-23 Saved Yes $t8-$t9 24-25 More temporaries No $gp 28 Global pointer Yes $sp 29 Stack pointer Yes $fp 30 Frame pointer Yes $ra 31 Return address Yes Page 140, Figure 3.13 Translating into machine code
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: assembly inst op rs rt rd shamt func comment add $s0, $0, $0 0 0 32 # i = 0 slti $t0, $s0,100 10 # t0 &lt;= (i &lt; 100 ?) beq $t0, $0, end 4 # if (i &gt;= 100) goto end la $t0, A 8 # t0 &lt;= r0 + A lw $t2, 0($t1) 35 # ti &lt;= M[A+i] = A[i] addi $s0, $s0, 1 8 # i++ jump loop 2 # goto loop 2. Fill in register numbers 16 8 16 8 8 10 16 16 6/3/10 2 Arithmetic Instructions Operation rs rt rd shamt funct # meaning add 3 5 2 0 32 # $2 &lt;- $3 + $5 sub 3 5 2 0 34 # $2 &lt;- $3 - $5 addu 3 5 2 0 33 # $2 &lt;- $3 + $5 andi 3 5 2 0 # $2 &lt;- $3 &amp; $5 Translating into machine code assembly inst op rs rt rd shamt func comment add $s0, $0, $0 0 0 0 16 0 32 # i = 0 slti $t0, $s0,100 10 # t0 &lt;= (i &lt; 100 ?) beq $t0, $0, end 4 # if (i &gt;= 100) goto end la $t0, A 8 # t0 &lt;= r0 + A lw $t2, 0($t1) 35 # ti &lt;= M[A+i] = A[i] addi $s0, $s0, 1 8 # i++ jump loop 2 # goto loop 3. Look at MIPS reference sheet for what field the reg #s go in 16 8 16 8 8 10 9 16 16...
View Full Document

Page1 / 2

TranslateMIPS - assembly inst op rs rt rd shamt func...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online