EER-018
Introduction to Digital Computers
 Lecture 28

Homework: # 10 - put in portfolio

Program Data Continued

Let's do that last example again:

         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

Using data to control the program

Another program: Repeatedly output any length string followed by terminating character. This time use the 7-segment display for letters rather than numbers.
User input will look like the following, assuming $00 is terminating character:
            org $330
data     fcb  %11101110     ; A
            fcb %00111110      ; b
            ...
            fcb %00011100      ; L
            fcb %00000000      ; terminating character

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