A3_2 - branch delay CLessThanB slt $8 $12 $11 if C< B bne $8 $0 MedianC branch if $8!= $0 sll $0 $0 $0"branch delay" or $13 $0 $11

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

View Full Document Right Arrow Icon
## A1_3.asm ## Written by: Colin Swelin 0308676 ## Program to computes the median of three values in memory: ## ## Registers ## $8 - branch control (in slt, beq, bne, etc. instructions) ## $9 - base register (loaded initially with 0x1000) ## $10 - word A ## $11 - word B ## $12 - word C ## $13 - median $ .text .globl main . main: m lui $9, 0x1000 # $9 is base register lh $10, 0($9) # $10 <-- A or $8, $0, $0 # $8 <-- 0 # lh $11, 4($9) # $11 <-- B sll $0, $0, $0 # "load delay" # lh $12, 8($9) # $12 <-- C sll $0, $0, $0 # "load delay" # slt $8, $10, $11 # if A < B bne $8, $0, CLessThanA # branch if != 0 sll $0, $0, $0 # "Branch delay" # CLessThanB2: slt $8, $12, $11 # if C < B beq $8, $0, CLessThanA2 # branch if $8 != $0 sll $0, $0, $0 # "Branch delay" # or $13, $0, $11 # $13 <-- B j End # jump to end sll $0, $0, $0
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: # branch delay # CLessThanB: slt $8, $12, $11 # if C < B bne $8, $0, MedianC # branch if $8 != $0 sll $0, $0, $0 # "branch delay" # or $13, $0, $11 # $13 <-- B j End # jump to end # CLessThanA: slt $8, $12, $10 # if C < A beq $8, $0, CLessThanB # branch if $8 == $0 # sll $0, $0, $0 # "branch delay" or $13, $0, $10 # $13 <-- A j End sll $0, $0, $0 s CLessThanA2: slt $8, $12, $10 # if C < A bne $8, $0, MedianA # branch if $8 != $0 # sll $0, $0, $0 # "branch delay" # or $13, $0, $10 # $13 <-- A # MedianC: or $13, $0, $12 # $13 <--- C j End # jump to end sll $0, $0, $0 MedianA: or $13, $0, $10 # $13 <--- A # End: sh $13, 12($9) s .data A: .word 3 B: .word 5 C: .word 7 D: .word 0 D ## end of file...
View Full Document

This note was uploaded on 02/14/2010 for the course COMPUTER S COIS-3030 taught by Professor Hircock during the Spring '10 term at Trent University.

Page1 / 2

A3_2 - branch delay CLessThanB slt $8 $12 $11 if C< B bne $8 $0 MedianC branch if $8!= $0 sll $0 $0 $0"branch delay" or $13 $0 $11

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