4. * EE101/EE134 Exam 2 (The following is just a sample Main program)
Main
LDX #REGBAS ;set IX for indexed addressing of ports
BSR Init_PortC
New_Data
BSR Input_Data
BSR Display_Bit
BRA New_Data
*********************************************************
*Subroutine: Initialize Port C
*The MCU receives parallel data from the peripheral
*using interlocked handshaking.
* HNDS = 1, all other bits = 0
*Calling register: IX = REGBAS
*Return regiester: none, but ACCA changed
Init_PortC
BCLR DDRC,X $FF ; all inputs (It was OK to not include this)
LDAA #$10
STAA PIOC,X
RTS
*********************************************************
*Subroutine: Wait for data in PORTCL
*Calling register: IX = REGBAS
*Return register: ACCA contains input data
Input_Data
BRCLR PIOC,X $80 Input_Data ; wait for STAF=1
LDAA PORTCL,X ; ACCA = data
RTS
8. *********************************************************
*Subroutine: Display 0 if Z set, 1 if Z clear
*Uses common-anode 7-segment LED display (0=on, 1=off)
*Assume PB0 -> a, PB1 -> b, ..., PB6 -> g, PB7 -> N.C.
*Calling registers: IX = REGBAS, Z bit in CCR
*Return register: none, but ACCA changed
Display_Bit
BNE One ; be sure Z isn't changed before test
Zero
LDAA #$40 ; or $C0
STAA PORTB,X
RTS
One
LDAA #$79 ; or $F9
STAA PORTB,X
RTS
11. Problem 5:
a. Printers
b. Instruments
c. One microsecond (two clock cycles)
d. IRQ
e. 0
f. $D6
g. $1007
h. 0 (or no change)
i. Read, receive, or load
j. Data bus