Homework: # 10 - put in portfolio
org ROM
init: CLR DDRB ;Set PortB to be
inputs
LDA #$FF
STA DDRA
;Set PortA to be outputs
STA PORTA
;Blank the display by sending all 1's
loop: BRCLR 4,PORTB loop ;Wait for the switch
value to be 1
LDA
PORTB ;Get BCD value
BSR convert
STA PORTA
wait: BRSET 4,PORTB wait ;Wait for the switch to
go low
BRA loop
convert: AND #%0F ;Clear upper nibble of A
TAX ;Put BCD value
in X register
LDA $330,X
;Get 7-segment value from table
RTS
org $330
****************abcdefg****************
data: fcb %10000001 ;0
fcb %10011111 ;1
fcb %10100100 ;2
fcb %10001100 ;3
fcb %10011010 ;4
fcb %11001000 ;5
fcb %11000010 ;6
fcb %10011101 ;7
fcb %10000000 ;8
fcb %10011000 ;9
org $7FE
reset: fdb begin
Our program must output this, or any other string of characters over and over.
org ROM
start CLRA
STA PORTA
; blank the display
COMA
STA DDRA
; define portA pins to be outputs
over CLRX
; initialize
the X register to the beginning of data
again LDA data,X ; read a data value
BEQ over
; if it is the terminating character, start over.
STA PORTA
; if not, then write out the character to PORTA
BSR delay
; delay long enough for character to be read
INCX
; set X to point to the next data value
BRA again
; and do it again.
delay .... we've done this part in class