2001-Computer_Architecture-scanned-solutions

2001-Computer_Architecture-scanned-solutions - Computer...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: Computer Science Comprehensive Examination Solution Computer Architecture Autumn 2001 (Total time = 60 minutes, Total Points = 60) Magic Number: Solution Set In recognition of and in the spirit of the Stanford University Honor Code, I certify that I will neither give nor receive unpermitted aid on this exam. Magic Number Signature: This examination is open book Please do all your work on these sheets. Do not do your work in a blue book. You have one hour to complete the exam. Before starting, please check to make sure that you have all 10 pages. 7 Total 12 60 Arch Comp Exam 2001 1. Short Answer Question (1 0 points) Assume that you have written the following fixnction: double AddCond(doub1e *a, double *b, double startVal) i. if (a != NULL) { startVal = startVal + (*a) ; if (b != NULL) { startVal = startVal + (*b) ; I 1 return startVal; After you turn in the function to your professor you re-read the instructions and discover that the function could not include any branch instructions! You decide your best hope is to submit an addendum to your assignment that describes a compiler and architectural features that allow this function to be generated with no branch instruction. Describe here the architectural features you are assuming the compiler has to work with. Show the branch-less assembly language of this function in a pseudo assembly language of your choosing. Let's assume we have some kind of predicated or conditional instructions. Assume that a is passed in Ra, b is passed in Rb, and startVal is passed in Fv. SetNe RI, Ra, 0 //Set RI with (a !=NULL) S d e R-b,O //Set Rl with (b !=NULL) SetAnd R3,RI,R2 //Set R3 with (a != NULL) && (b I= NULL) CondLoad FI,(Ra),Rl // if(R1) then load Fl with *a CondLoad F2, (Rb),R3 //if(R3) then load F2 with *b CondAdd Fv,FI,RI //if(Rl) then add F1 to Fv CondAdd Fv,F2,R3 //if(R3) then add F2 to Fv Ret Fv //return startVal; Page 2 of 10. 10....
View Full Document

This note was uploaded on 11/18/2011 for the course EE 282 at Stanford.

Page1 / 10

2001-Computer_Architecture-scanned-solutions - Computer...

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

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