This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 1/11 EE 319K Spring 2010 Final Exam Ramesh Yerraballi TTh Full Name : Duration : 75 minutes This is a closed book exam; You may use your calculators; Write answers within the space provided after each of the questions. There are 7 questions on the test, read all of them first so you may properly allocate your time to answer them. Please provide comments for all code you write to help understand your answer and possibly award you partial credit. You may use the back of the sheets for extra space. 1. [4 points] In the FIFO implementation that uses a counter, what causes a race condition? How do you fix it? Modification of the shared variable Count in FiFo_Get and FiFo_Put routine could leave it in an inconsistent state. Specifically, if a Consumer (say the main) program calls FiFo_Get and in the middle of decrementing the Count it gets interrupted by a Producer that calls FiFo_Put which increments Count. Fix: Disable interrupts when a shared variable is being modified and enable them once done --- asm sei; count--; asm cli; 2. [6 points] To convert from temperature expressed in Fahrenheit to Celsius, the following formula is used: C = (5/9)x(F-32) . Given the range of F is 0 to127, write C code that will do the conversion without the use of float/double declarations or casts. Specifically, write the appropriate declarations for F and C and the expression that realizes the given formula. unsigned char Faren; // can also define as short char Cels; // can also define as short Cels = (5*(Faren-32))/9; // multiply first divide last 3. [5 points] For a clock frequency of 8 Mhz, $______ should be written into the 9S12 SCIBD register to provide a bandwidth of 24 kbps. The protocol is 8 bits data. 1 start bit, 1 stop bit and no parity bit. Bandwidth(=24x10^3) =(Useful Bits=8/Total Bits=10) x Baud-Rate Therefore, Baud-Rate = 24 x 10^3 x (10/8) SCIBD = M-clock/(16 x Baud-Rate) = 8 x 10^6 / [(16 x 24 x 10^3) x 10/8] = 16.6666.. ≈ 17 = $0011 2/11 4. [20 pts] In the following code the stack is used for passing an input parameter, a return value and, to save registers that the subroutine modifies. The subroutine makes use of two local variables, which are accessed using Register X as the stack frame pointer. Read the comments to understand the code and pay attention to instructions to figure out the sizes of input/output parameters and variables. org $0800 reslt rmb 2 org $4000 main lds #$4000 des ; Allocate space des ; for the return value movb #100,1,-sp ; Allocate and pass input parameter jsr sub ldd nnn ,sp ; get return value into reg D std reslt ; store result leas 3,sp ; De-allocate input and output space infty bra infty ;****************sub************* inp equ aaa ; binding for input parameter out equ bbb ; binding for return value sum equ ccc ; binding for local variable sum num equ ddd ; binding for local variable num sub pshx ; save register X tsx ; Setup Frame Pointer leas -2,sp ; Allocate space for sum leas -1,sp ; Allocate space for num ; ..... other stuff .....; ....
View Full Document
- Fall '08
- X86, Interrupt, Interrupt handler, regb