Docsity

4 Problems on Microcomputers - Exam 1 | ECE 383, Exams of Electrical and Electronics Engineering

Partial preview of the text

Download 4 Problems on Microcomputers - Exam 1 | ECE 383 and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

ECE 383 - Microcomputers

Fall 2010 โ€“ Test 1

Name:__________________________________________________________________________

Student Number:_________________________________________________________________

Instructions:

  1. Print your name and student number above.
  2. Indicate your answers clearly in the spaces provided with each problem.
  3. Open book/notes/computer. No IDE/simulator/communication. INDIVIDUAL work ONLY.
  4. Problem 1 is 10 points. Problem 2 is 45 points. Problem 3 is 24 points. Problem 4 is 21 points.

[1] Correct the program area of the following code that rearranges the numbers in the buffer in descending order.

ORG $

STR DC.W $0035, $0040, $0030, $

ORG $

MAIN: LDX #STR

LOOP_FOR: CPX #STR+

BEQ END_MAIN

LDAA 1, +X

LDAB 2, +X

CBA

BGE NEXT

EXCHANGE: STAB 2, -X

STAA 2, +X

NEXT: DEX

BRA LOOP_FOR

END_MAIN: RTS

END

[2] Given the following codes, what will be the resulting values at the break points for the memories and registers?

#include ECE383_Dragon12plus_registers.inc #include ascii.inc

ORG $

STR DC.B โ€˜1432โ€™, NULL TARGET DS.W 1 DIGIT DS.W 1

$1000 $ $1001 $ $1002 $ $1003 $ $1004 $ $1005 $ $1006 $ $1007 $ $1008 $

ORG $

MAIN: LDX #STR

MOVW #0, TARGET

LOOP1: LDAB 1, X+

CMPB #NULL

BEQ LOOP1_END

SUBB #โ€™0โ€™

TFR B, D

[3] Complete the following code that initializes the serial port, reads inputs and display characters.

#include ECE383_Dragon12plus_registers.inc #include ascii.inc

ORG $ STR DCB.B 80, โ€˜Xโ€™

ORG $

MOVW #$0271 , SCI0BRH ;Baud rate 2400 for 24MHZ MCLK MOVW #$030C , SCI0CR1 ;8-bit transmission ;Odd parity Enable ;Bi-directional communication. LOOP1: **BRCLR SCI0SR1, #$20 , *** ;Is serial port ready for read? LDAA SCI0DRL ;Read the input **BRCLR SCI0SR1, #$80 , *** ;Is serial port ready for write? STAA SCI0DRL ;Echo the input CMPA #CR ;Is input a Carriage Return? BEQ END_LOOP1 ;End of the loop SUBA #$20 ;Convert the lower case to the ;Upper case STAA 1, X+ BRA LOOP_FOR END_LOOP1: MOVB #NULL , 0, X ;End the string with a NULL

LDX #STR LOOP2: LDAA 1, x+ CMPA #NULL BEQ END_MAIN ;End of the loop **BRCLR SCI0SR1, #$80 , *** ;Is serial port ready for write? STAA SCI0DRL ;Display the character BRA LOOP

END_MAIN: RTS END

[4] What are the values of registers or memories after each instruction for the given data initialization?

ORG $

STR DC.B $11, $10, $12, $13 ; ( SP = $3B00 )

a. LDY #STR ; Y = $ b. LDAB 2, +Y ; B = $12 Y = $ c. LDAA 1, Y  ; A = $10 Y = $ d. STD STR+2 ; D = $1012 [STR+3] = $ e. LDY #STR+1 ; Y = $

f. PSHA ; SP= $3AFF [SP] = $ g. PSHY ; SP= $3AFD [SP+1] = $

  • h. PULB ; SP= $3AFC D = $