| EE371 Home Page | EE Home Page |
EE371 Quiz #1 September 15, 1999 THE D-BUG12 MONITOR MD DISPLAY SHOWS: 4040 BD 7C 96 84 - FE FF C2 76 - 11 22 33 44 - 55 66 77 88 1 WHAT IS IN MEMORY LOCATION $4040 (GIVE YOUR ANSWER IN HEX) $BD 2 WHAT IS IN MEMORY LOCATION $4041 (GIVE YOUR ANSWER IN BINARY) %0111 1100 3 GIVE THE RESULTS IN THE REGISTER AFTER THE FOLLOWING INSTRUCTIONS ARE EXECUTED: LDAB $4040 B = ? $BD LDAA #$40 A = ? $40 LDX #$4040 X = ? $4040
EE371 Quiz #2 October 18, 1999 THE MEMORY MAP FOR AN HC12 MICROCONTROLLER SHOWS: RAM: $0800 to $0BFF ROM: $8000 to $FFFF GIVE APPROPRIATE EQUATES TO DEFINE THE LABELS FOR THE FOLLOWING: 1. ORG PROG ; LOCATE THE PROGRAM CODE PROG EQU $8000 2. LDS #STACK ; INITIALIZE STACK POINTER STACK EQU $0C00 3. ORG DATA ; LOCATE VARIABLES DATA EQU $0800 4. WHERE SHOULD PROGRAM CONSTANT DATA BE LOCATED? In the rom area located directly after the code. THE INSTRUCTION CMPA #$86 IS EXECUTED WHEN THE A REGISTER CONTAINS $55. STATE YES OR NO WHETHER THE FOLLOWING CONDITIONAL BRANCHES ARE TAKEN: 5. BGT Yes 6. BHI No
EE 371 First Semester Test - Tuesday September 28, 1999 40 Points, 15% of Final Grade Please put your name on the outside of the paper also Name _______________________ 1. Assume the following program is downloaded and run on the HC12 EVB in the lab: (22 points) 0000 1 P EQU $4000 0000 2 R EQU $6000 0000 3 S EQU $8000 4000 4 ORG P 4000 CF8000 5 LDS #S 4003 CE4012 6 LDX #CONST 4006 FE4012 7 LDX CONST 4009 B64012 8 LDAA CONST 400C 8B0A 9 ADDA #!10 400E 7A6000 10 STAA BUF 4011 3F 11 DONE: SWI 4012 4546 12 CONST: DB $45,$46 6000 13 ORG R 6000 14 BUF: DS 1 a. Where is the program located? _$4000____ b. Where is the variable data located? _$6000___ c. With what value is the stack pointer loaded when the code on line 5 is executed? _$8000___ d. With what value is the X register loaded when the code on line 6 is executed? _$4012___ e. With what value is the X register loaded when the code on line 7 is executed? _$4546___ f. What value is in memory location $6000 after the program has run? _$4F_____ g. What addressing mode is used in the instruction in line 5? _Immediate h. What addressing mode is used in the instruction in line 6? _Immediate i. What addressing mode is used in the instruction in line 7? _Extended j. What addressing mode is used in the instruction in line 8? _Extended k. What addressing mode is used in the instruction in line 9? _Immediate 2. Give the requested codes for the following information. Assume all binary codes have 8-bits. (12 points)
| Decimal Information | Unsigned Binary | Two's Complement Binary | Signed/magnitude Binary |
|---|---|---|---|
| +127 | 0111 1111 | 0111 1111 | 0111 1111 |
| -56 | Not possible | 1100 1000 | 1011 1000 |
EE 371 Second Semester Test - Tuesday October 26, 1999
35 Points, 15% of Final Grade
Please put your name on the outside of the paper alsoName ____KEY________________
1. The following program has been downloaded and run on the EVB. The register display, BEFORE
the program is executed, shows:
PC=0000, SP=0A00, X=1234, Y=5678, A=AA, B=BB, CCR=90
4000 3 org $4000
4000 CF8000 4 lds #$8000
4003 37 5 pshb
4004 32 6 pula
4005 164009 7 jsr sub
4008 3F 8 swi
4009 37 9 sub: pshb
400A 36 10 psha
400B A7 11 nop
400C 32 12 pula
400D 33 13 pulb
400E 3D 14 rts
Give the expected contents of the registers AFTER
the program has executed.
PC= 4008 SP=_$8000_ X=_$1234_Y=_$5678_
A=_$BB___ B=_$BB___ CCR=91
Give the contents of the following memory
locations AFTER the program has executed.
$7FFC _BB____
$7FFD _BB____
$7FFE _40____
$7FFF _08____
(9 points)
2. For each of the following code snippets, state if the branch is taken (Y or N) or unknown (U):
ldaa #$FF . ldaa #$81 . ldaa #$81
beq SAM cmpa #$FE cmpa #$02
bhi GEORGE bgt SUE
Y ___ N _X_ U ___ Y ___ N _X_U ___ Y ___ N _X_U ___ (6 points)
3. The MC68HC912B32 microcontroller has 32 Kbytes of Flash EEPROM (ROM) in memory space
$8000 - $FFFF and 1 Kbyte of RAM in memory space $0800 - $0BFF. (12 points)
Give a range of addresses (in hex) suitable for locating code: $8000___ to $FFFF____
Give a range of addresses (in hex) suitable for allocating variable data storage: $0800___ to
$0BFF___
Your program turns out to be exactly 256 (base 10) bytes long. Give the location in memory (in hex) where
your first byte of constant data can be located: $8100_____
Write the instruction you will use to initialize the stack pointer in your program.
LDS #$C00
4. Insert code to implement the following structured design immediately after each design comment.
Assume the following 8-bit two's-complement variable data allocations have been made and have been
initialized in some other part of the program. (8 points)
Var1: DS 1
Var2: DS 1
; Implement the following design
; IF Var1 > Var2
LDAA Var1
CMPA Var2
BLE Else_part
; THEN Var1 = Var2
MOVB Var2,Var1
BRA Endif
; ELSE Var2 = Var1
Else_part:
STAA Var2
; ENDIF
Endif:
EE 371 Third Semester Test - Tuesday November 16, 1999
45 Points, 15% of Final Grade
Please put your name on the outside of the paper alsoName _____KEY_______________
1. Assume K1 and K2 are 8-bit signed (2's-complement) variables and K3 is an 8-bit unsigned variable.
Assume the following memory map equates:
ROM EQU $8000
RAM EQU $0800
a. Show how to allocate storage for these variables in an assembly language program. (5 points)
ORG RAM
K1 DS 1
K2 DS 1
K3 DS 1
b. Write structured assembly language segment code for the following design: (17 points)
; Initialize K1 to the most positive number
movb #!127,K1
; Initialize K2 to the most negative number
movb #$80,K2
; Initialize K3 to zero
clr K3
; WHILE K1 > K2
while_start:
ldaa K1
cmpa K2
ble end_while
; DO
; K1 = K1 - 1
dec K1
; K2 = K2 + 1
inc K2
; K3 = K3 + 1
inc K3
; ENDO
bra while_start
; ENDWHILE
end_while:
swi
; =========
c. What value (in decimal or hex) do you expect to find in K3 when this code segment has run? (3
points) !128 = $80
2. Complete the follow address decoder design sheet to completely decode the 16-bit address $4C86 using
three 74LS138 decoders. Be sure to complete the schematic diagram showing what is connected to all
three 74LS138 decoders. (20 points)
|
|
Address Bus |
|
|||||||||||||||||
|
Adr-Hex L |
4 |
C |
8 |
6 |
ADR_ OK |
||||||||||||||
|
|
15 |
14 |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|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
||
|
A0 |
A0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
0 |
||
EE 371 Final Exam, December 13, 1999
80 Points, 25% of Final Grade
Please put your name on the outside of the paper also.Name ______KEY____________
1. You are to define a serial cable to connect two PC's configured as RS-232 DTE devices. Each PC has
a DE9P connector on it's back panel. The software used in each PC for file transfer makes use of
hardware (RTS/CTS) flow control. Draw an appropriate cable using the minimum number of wires
necessary (wires are expensive). Be sure to show each connection, what the signal name is, what the
data flow direction is, and what connectors are to be used on each end of the cable. (20 points)
2. Show the code necessary to initialize and enable the keywakeup interrupt on Port H, bit-3. Assume
you ARE NOT using a system with the D-Bug12 monitor (i.e. do not call SetUserVect). Assume the
code for the ISR is:
KWISR: ldaa #Bit3
staa KWIFH ; Reset the flag
rti
Your code example must properly define all registers and bits and must include all code to allow this
interrupt to happen. You do not have to write code for any foreground job or the interrupt service
routine. (20 points).
f99p2.asm Assembled with CASM 12/13/1999 09:43 PAGE 1
0000 1 DDRH: EQU $25
0000 2 BIT3: EQU %00001000
0000 3 KWIFH: EQU $27
0000 4 KWIEH: EQU $26
0000 5 KWHVEC: EQU $ffce
6 ; Set port H-3 to input (not necessary if default
exists)
0000 4D2508 7 bclr DDRH,BIT3
8 ; Clear the key wakeup flag
0003 8608 9 ldaa #BIT3
0005 5A27 10 staa KWIFH
11 ; Enable the key wakeup bit
0007 4C2608 12 bset KWIEH,BIT3
13 ; Unmask interrupts
000A 10EF 14 cli
15 ; Foreground job
16 ; ISR
000C 8608 17 KWISR: ldaa #BIT3
000E 5A27 18 staa KWIFH
0010 0B 19 rti
20 ; Initialize vector
FFCE 21 ORG KWHVEC
FFCE 000C 22 DW KWISR
23
24
3. Design an input interface for an A/D converter. Assume the A/D START_CONVERT and
END_OF_CONVERT control signals are taken care of and now you must design the data input
interface. Assume a 16-bit address bus and that you have a magic address decoder that will assert an
active-low logic signal ADR_OK* when the correct address is on the address bus. Assume that the CPU
produces active low RD* and WR* to indicate when it is reading and writing respectively. Show the
complete design to allow data to be input to the CPU. (20 points)
4. Write a segment of code to start the A/D converter described in problem 3. Assume both control signals
are active-high and that START_CONVERT is on Port J bit-0 and END_OF_CONVERT is on Port J
bit-1. Your code is to start the A/D converter by strobing START_CONVERT high and then low and
then to wait until END_OF_CONVERT is asserted before reading the data from address $70. (20 points)
f99p4.asm Assembled with CASM 12/13/1999 09:58 PAGE 1
1 ; EE371 Final F99 Prob 4
0000 2 DDRJ: EQU $29
0000 3 BIT0: EQU %00000001
0000 4 BIT1: EQU %00000010
0000 5 PORTJ: EQU $28
6 ; Initialize Port J-0 output and -1 input
0000 4C2901 7 bset DDRJ,BIT0 ; output
0003 4D2902 8 bclr DDRJ,BIT1 ; input
9 ; Make sure Port J-0 is low so the A/D doesn't start
0006 4D2801 10 bclr PORTJ,BIT0
11 ; Strobe PortJ-0 high and then low to start the A/D
0009 4C2801 12 bset PORTJ,BIT0
000C 4D2801 13 bclr PORTJ,BIT0
14 ;
15 ; Spin waiting for the A/D END-OF-CONVERT signal
000F 4F2802FC 16 spin brclr PORTJ,BIT1,spin
17
18 ;
19