ECE243_2005_exam_1299387059.pdf

12 Pages
140 Views

Department
Electrical & Computer Engineering
Course Code
ECE385H1
Professor
Robert Brym

This preview shows pages 1,2 and half of page 3. Sign up to view the full 12 pages of the document.
Description
Student # ____________________________________ (In case pages get detached) ECE 243S - Computer Organization The Edward S. Rogers Sr. Department of Electrical and Computer Engineering Mid-term Examination, March 2005 Name Student # Please circle your lecture section for exam return LEC0101 LEC0102 LEC0103 LEC0104 Mochovos MTuTh Mochovos MWTh Anderson MWF Anderson TuThF Answer all questions. Write your answers on the exam paper. Show your work. Each question has a different assigned value, as indicated. Not all questions will require the same amount of time and effort, use your time wisely. Permitted: textbook and lab manual; one extra page. No other printed or written material. No calculator. NO PHOTOCOPIED MATERIAL Total marks availabl100 + 10 Verify that your exam has all the pages. Only exams written in ink will be eligible for remarking. ECE243 Midterm pg 1 of 12 Feb. 2005 Student # ____________________________________ (In case pages get detached) 1. [20] Quick Answer – Circle the correct answer in A to E. A. Memory address $40000 contains the word $0034. Is this: a) Data only. b) An instruction only. c) Could be either data or an instruction. B. How many times will the instruction sub be executed in the following code? move.w# d0, Ebe:qkoko sub.w # d20, braETA ETB: a) integer part of N / 2 b) integer part of (N - 1) /2 c) either integer part of N / 2 or infinite times The instructions form a loop starting at label ETA. As long as d0 is non-zero the loop will continue executing and at every iteration will subtract 2 from d0. So, if N is an even number the loop will iterate N/2 times. If N is an odd number, then subtracting 2 will never produce 0. Instead, d0 will cycle through 3, 1, -1, -3, …. d) either integer part of (N - 1)/2 or infinite times e) 2N f) N + (N – 1) g) None of the above C. Which C language construct the following assembly code corresponds to? cmp.w d d1, bEtTA ETB: add.w # d1, bEaTG ETA: add.w # d1, ETG: a) if (a > b) { a = a + 1; } else { a = a + 2; } b) if (a <= b) { a = a + 1; } else { a = a + 2; } Notice that d1 is either incremented by 1 or 2. The question is whether d1 holds a or b. The cmp and bgt instructions provide the necessary clues. The cmp compares d1 to d1 and the bgt branches to the code that increments d1 by 2 if (d1 > d0). In other words, we will increment d1 by 2 if d1 is greater than d0 or increment it by 1 if d1 is less than or equal than d0. c) if (a > b) { b = b + 1; } else { b = b + 2; } d) if (a <= b) { b = b + 1; } else { a = b + 2; } ECE243 Midterm pg 2 of 12 Feb. 2005 Student # ____________________________________ (In case pages get detached) D. What will happen when the following code is executed? jsr ETB ETB rts a) jsr and rts will execute an infinite number of times b) jsr and rts will execute once and then execution will continue immediately after rts. c) jsr will execute once, rts will execute twice and then execution will resume at an unspecified address (value at the top of the stack prior to executing the code). Ignoring any memory alignment issues (i.e., assuming that the value of a7 is divisible by 2) the first jsr instruction will push on the stack the address ETB (its return address) and then jump to ETB. At ETB the rts instruction will be executed. It will a long word from the top of the stack and jump there. As explained this value will be ETB. So, the rts will execute once more. It will again read the long word at the top of the stack but now this value is unknown to us (it can not be determined with the information given to us). Hence, execution will continue at an unspecified address. d) None of the above. This will happen: ________________________________ E. How many seconds is taken on a serial link to send the message “MY MESSAGE” (ignore the quotation marks) over a UART set to 9600 BAUD, 1 Stop Bit, 8 Bit Data, No parity. Ignore the time to set up the communication and assume that characters are sent as fast as possible. a) 80/9600 b) 90/9600 c) 100/9600 In serial communication, each character is transmitted using 8 bits (as stated in the question “8 bit data”). To send a character we always need a stop and a start bit as we have explained in the lectures. The stop/start bit force a 1 to 0 transition on the communication line and this helps us correct any phase differences that may exist. Thus, we need 8 + 2 bits per character. There are 10 characters, so in total we need to be able to sent 100 bits. The BAUD rate is the rate at which bit cells occur and it follows that we need 100 x 1/9600 bit cells to sent the message. d) 110/9600 ECE243 Midterm pg 3 of 12 Feb. 2005 Student # ____________________________________ (In case pages get detached) 2. [15] Basic Addressing Modes Memory and registers are as on the left side of the table below. Show what happens after all of the following instructions are executed: INST_1 AA equ $1003 INST_2 move.b #6,AA+1 INST_3 move.l $100C,d1 INST_4 move.l #$100C,d2 INST_5 movea.l #$1008,a1 INST_6 move.l (a0)+,d0 INST_7 move.b 5(a2),d3 Address Before After Word contents $1000 $4963 $1002 $1000 $1004 $2039 $0639 The $06 is from INST_1 $1006 $3322 $1008 $5544 $100A $FAA5 $100C $B2FC $100E $0000 $1010 $0203 Registers Long Words d0 $12345678 $49631000 from INST_6 d1 $23282A2C $B2FC0000 from INST_3 d2 $45342312 $100C from INST_4 d3 $ABCDEF $ABCD00 from INST_7 d4 $0 a0 $1000 $1004 from INST_6 a1 $4670 $1008 from INST_5 a2 $FFE a3 $6 ECE243 Midterm pg 4 of 12 Feb. 2005 Student # ____________________________________ (In case pages get detached) 2. [15] Parallel Interface In the following diagram of one bit of a PIT: Vdd Registor DIR Read Data D Q DOR External DOR Write connection Write D Q DDR DDR Write Write a. What is the purpose of the Resistor? The resister is there to set the line at Vdd if no external source is currently drives the wire. It also allows an external source to set the wire’s voltage at any value desired. Finally, it can help an external device set the wire to Vdd (in case the device is not as strong at forcing a “high” voltage). Of course, the latter benefit comes at the expense of making driving the wire to 0V harder. b. What drives “DDR Write”? An address decoder. The address decoder is a combinatorial circuit that inspects the processor’s memory interface and determines whether an access is currently being requested by the CPU for the memory address where DDR is mapped to. c. What drives “DOR Write”? As in (b). d. What is the purpose of the DDR? To control the direction of the external connection. If DDR is set to 1 then the tri-state buffer is activated passing the value of DOR onto the external wire. In this case, the external connection is an output (from the computer’s perspective). If DDR is set to 0 then the tri-state buffer is de-activated effectively isolating DOR’s output from the external connection. In this case, an external device can set the wire to any voltage it desires. e. How many flipflops would be in an 8 bit PIT interface of this type? EIGHT per register Æ one per bit. There are two registers DDR and DOR, hence in total we need 16 bits. ECE243 Midterm pg 5 of 12 Feb. 2005 Student # ____________________________________ (In case pages get detached) 4. [25] Writing Assembly Code Write a subroutine in 68k assembly that takes as input three long word parameters on the stack: The first parameter is the base aess of an array oflong words. The second parameter is the number of array elements counting from 1. The third parameter is a number. The routine should calc ulate and return in d0 the number of array elements whose value matches that of the third parameter. Assume that all registers are callee- saved. Note that parameters are pushed on the stack in reverse order so that at the end the first parameter appears at the top. There are many possible implementations. We present one of them. We start with what the stack will contain when this function is called. This is part of the calling conve
More Less
Unlock Document

Only pages 1,2 and half of page 3 are available for preview. Some parts have been intentionally blurred.

Unlock Document
You're Reading a Preview

Unlock to view full version

Unlock Document

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit