Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Midterm Practice - Computer Architecture | CS 25000, Study notes of Computer Architecture and Organization

midtermpractice Material Type: Notes; Professor: Xu; Class: Computer Architecture; Subject: CS-Computer Sciences; University: Purdue University - Main Campus; Term: Fall 2011;

Typology: Study notes

2010/2011

Uploaded on 10/24/2011

nick-mccollum
nick-mccollum 🇺🇸

1 document

1 / 7

Toggle sidebar

Related documents


Partial preview of the text

Download Midterm Practice - Computer Architecture | CS 25000 and more Study notes Computer Architecture and Organization in PDF only on Docsity! L CS 250: Computer Architecture Midterm Exam - October 25, 2011 Closed-book/notes/discussion TIME: 90 minutes (8:00 PM - 9:30 PM) LOCATION: PHYS 114 Sample Questions 10 “True or False” statements. Sample statements are: d)[ F 15 bits “Need? to represent every state of the United States. 6 bits for S0 Stakes (2) [ T ] A demultiplexor has more output lines than input lines. BL / ] In both one’s complement and sign-and-magnitude schemes, there are two representations for zero. AL F ] ln MIPS, some R-type instructions also access the data memory. Woe R-type fastpuchen accesges dala memeRy 6) [ EF ] In MBPS, the 16-bit “address” field of the beq instruction is treated as afi unsigned integer. [ts a Signed # vege (6) [ T ] In the simple MIPS processor, the subset of datapath involved in the execution of an instruction can be predicted except the branching instructions. MI ] A stack grows from low address to high address. /t grous from h Pi add, Co law actde, 2. 10 short “Q&A”s. Your answer to each question should have no more than three sentences. Sample questions are: (1) Name at least three hardware components inside the processor. 4 9. — Repistea file —- ALL 2 — SMolbpdpxops a A. de bfer S 1 (2) Under two’s complement, what is the decimal value of binary number 1111 0000? What if this is a binary number under one’s complement? — Under 25 conrphmerts 16 oT — Under ['5 Corplenod: —/$ (3) What does the digital circuit below do? Inputs x; AMD odtpot Xo o—0 Aw 5 a Y a Ther Kya A-te-L roll jofeXoR 3 Xr o Outpot S (4) Translate the following C statement into MIPS assembly. If (x == y) { itt; } J++; You can assume that the values of variables x, y, i, and j are already in registers $1, $2, $10, $20, respectively. bne #L $2, labe| add: $10, $10, | sw tie, rFo labels add; $20, $20, / sw $20, } (Fo) 4. One MIPS assembly programming problem A recursive definition of a function will be given and you will be asked to implement the recursive function in MIPS. Study the factorial and Fibonacci examples in the lecture notes. §. One problem on simple, single-cycle MEPS processor Sample problem: The “jump- and-link” instruction (3a1) is used for making function calls in MIPS: jal Label ref et] Of L3lrRby label [25-0] Before the function is called, the return address (PC+4) will be written to $ra (namely $31). (1) Modify the MIPS processor diagram on the next page to support the execution of jal. (2) Highlight the subset of the modified datapath involved in the execution of jal. (3) In the same situation as in (2), indicate (in the same figure) the values of control signals ‘RegDst’, ‘RegWrite’, ‘PCSre’, and ‘MemToReg’. gee nat page — (a) sea diagram above (dD KepDit= 2 Cacimel) ; Rey eile = [> PCSee =X > Nemte Reg = Z. ss 2-0 Held size _[gg6 bes agly 56 bits 21.5 bits g] 26 bitsy [4,5-bits gle G bits pl All MIPS instructions 32 bits Riommat_ [op 15 1 rd | shamt | tenct _ fArthmetic instruction format fd FEF E Hormat_ op 1S nt address /immediate Transfer, branch, mm format B, CLS. FFE, ai [Atonmat ep target adores Jump instruction format adde fh FIGURE 2.26 MIPS instruction Formats in this chapter. Highfightec portions show instruction formats introduced Category hE etn d-to~ tlt/po Meaning add “$10, $1, $2 BO =$u + $12 Arithmetic sab S$tO, Std, $e2 $tO = $tl — $i2 rem $10, Stl, $t2 $tO = $t] % $t2 div $t0, Stl, $42 $tO = Stl / $42 and —- $tO, $ti, $t2 $t0 = $t} & $2 (Logical AND) or $10, $t1, $12 $tO = $t1 | $12 (Logical OR) Logical sil $tO, $t1, $t2 $10 = $11 << $12 (Shift Left Logical) sr] $tO, Sth, $t2 $t0 = $tl >> $t2 (Shift Right Logical) sra $10, $t1, $12 $10 = $tl >> $12 (Shift Right Arithmetic) move $10, Stl $tO = $tt Register Setting $10, 100 $10 = 100 lw $10, 100($11) $t0 = Mem[100 + StI] 4 bytes Ib $t0, 100(St1) $t0 = Mem[100 + $t1] 1 byte Data Transfer sw $10, 100(St1) Mem[i00 + $ti] =$t0 4 bytes sb $t0, 100($t1) Mem[100 + $t1] = $t0 1 byte beq —- $0, St, Label if ($tO = $t1) go to Label bne —-$t0, $t], Label if ($10 4 $tl) go to Label bge —-$t0, $ti, Label if ($0 > $tl) go to Label Branch bet $10, Stl, Label__| if (St0 > St!) go to Label ble $tO, $t], Label if ($10 < $t}) go to Label bit $t0, Sti, Label if ($tO < $t1) go to Label sit $0, $t1, $12 if (Stl < $t2) then $t0 = 1 else $t0=0 Set sli $t0, $t1, 100 if ($t} < 100) then $t0 = I else $t0 = 0 J Label go to Label Jump ye $ra go to address in $ra jal Label $ra= PC + 4; go to Label The second source operand of the arithmetic, logical, and branch instructions may be a constant. Register Conventions The caller is yesponsible for saving any of the following registers that it needs, before invoking a function. $10-$t9 $a0-$a3 $v0-$v1 The cailee is responsible for saving and restoring any of the following registers that it uses. $s0-$s7 $s8/$fp Ssp $ra Pointers in C: Declarartion: either char *char_ptr -or- char char_array{] for chare Dereference: ¢ = ¢_arrayfi] -or- c =*¢_pointer Take address of: c_pointer = &e 42
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved