You are on page 1of 4
IL SA aw 2b to UNCA CSCI 255 Exam Fall 2011 This is a closed book and closed notes exam. Laptops, cell phones, and any other electronic storage or communication devices may not be used during this exam. ‘Name: Joh ve Lay wider , Joshua lancache? Ifyou want partial credit for imperfect answers, “plan the reason for your answer! Problem 1 (20 points) True/False Questions ' Li (Gor false) The PIC24 data memory is byte addressable. i fradgtrrene We veiny isnt WAS Lue or £(43)) The PIC24 has 24 working registers, Woe. / aatg ll L othe genre em false) A PIC24 instruction can be stored in 24 bits. + a, adnuckinn be A? this — (t€aDor false) The PIC24 data bus is 16 bits wide. daly tales tae obs. stuuchee x (GB or false) The program counter stores an instruction. stoves, al Lf the ia -Z dott + 16 (Ere or (iS) The PIC24 instruction cycle is the same as its clock mh instruction is executed each clock cycle. Sous wsteaucho 1. Briefly, contrast machine code and assembly,code. Machine code is in binary anol ascembly Code an F remmones, 0 walt, ryrestidehons oF dec * bine Las. no He a i ge ogee ete ASL adatessable unit? 2 x yav pigts Exy a*=2* BLA Kays 7 Ais stom fh we 3. Ifa memory has 100 words, and each word contains 16 bits, hi contained in this memory? lone" = 400 bytes x ' -7 4, Explain why the stack is needed to implement subroutines. Je stack i perleA 4. iesplewowt a Stack fame whidk is weed te bold tack. pict af a subranhue, Namely the menor addnss Lor the telurang 58 Vt 900s. 5. Explain thé difference between MOV [W1++],WO and MOV [+401] , WO. beck tote ue fit inuimeuds AFTER Hee die» 15 eketubeal. Tex second cloes the tetinnend BEFOR- This iac ie done on ts dda lavabed ip the wom. address, Problem 3 (10 points) Finite State Machines tye jw, nob what gst ine Ww) A finite state diagram is given below. This FSM has four states, labeled Ato D. At each state ‘transition, it receives a single input bit and produces a single output bit (the output is shown inside the state). The starting state for the FSM is A. Qo 6l , 1, Suppose the FSM is started (jp state A) and then receives three successive inputs 0 1 1, After the 3 input bit is repefved, whjch state is the FSM in and what is its output? O ® Wun —1 2. In the table below give a bwo-bit state encoding for the four states of the FSM. In other words, represent each state with a unique 2-bit pattern. There are many possible correct answers for this subproblem. : * Sate as leier State as two bits A oO oO a B ° ) c ° D L 1 3, Complete the following table to show the state transitions of the FSM at the top of the page using your state encodings from the previous subproblem. Seckun laneasher wet state Wesbne lancer present state ‘input ° ° oO o © a| 6 ! oo L 2 1 © 1 OQ 2 1 t A to to ° o | O° n plo 1 ay an 2° ito ih t ott Problem 4 (20 points) Translating C to Assembly Using the PIC24 assembly language instruction summary attached to this test, write a PIC24 instruction sequence that accomplishes each of the C statements below. Assume that i,j, and k are 16-bit variables that have already been allocated in memory. In other words, assume that the following assembly code has already been written: . -bss rdata section ‘space 2 Allocating space (in bytes) to variable. -space 2 #Allocating space (in bytes) to variable. ‘space 2 ;Allocating space. (in bytes) to variable. 1: k=@-j)>>2 Mov), WOE Gas poet sub 1, WREG |p gol , LSR Wo, RL, Wo mov WO k 3 - ifi=j { cher? if-body statements } iF tops sno whe Caw, od 2 ood 7 H0SG endaift 3. while (i != 0) { loop-body statements ‘ohesto: ve L whew u ao? A Wh Uble BBA bale top ° Problem 5 (15 points) Register and Memory Contents Assume the memory/register contents shown below at the start of the instruction in each subproblem. For each subproblem, state the memory location or register that is modified along with its new contents. ‘Location ‘Value ‘Location Value wo Ox080A" bOx0800 0x382A_ Wi 0x0808 - ‘Ox0802 OxFB80 w2 Ox0804 Ox0804 Ox4D19) w3 0x0800 -0x0806 ‘OxE7CO Wa @x0806 (0x0808 OxFFOO ‘WIS 0x0802 Ox080A Ox0808 1. MOV 0x0802, WREG WO = Ox FR8O.6-- 2. MOV #0x0802, WO Wo = Ox0@OX o~ 3. MOV [W3], [W4] Ox0%l = Ox3S1A LE 5 ot 4, MOV W3, W4 wd = 0.4000 —~ 5. PUSH WI Mov wl Ewise] ., Problem 6 (10 points) C Expressions WIS = Oxovou OrxO080r = Ox C2O.Y eto Evaluate each of the following expressions assuming i, and j have been declared as follows: uintl6_1'i=1, 0; _ ‘Expression Evaluation i O,Selee oe jae ox0or 9.0020 =H. 7 && 0x0001 0, fale 7 0x0001 3 il 2 Oxo001 7) 1110x0001 Oxo00)a) ,-o tue = —

You might also like