{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

A3_2 - branch delay CLessThanB slt $8 $12 $11 if C< B bne...

Info icon This 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
Image of page 1

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

View Full Document Right Arrow Icon
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern