;FILENAME:   STLAB052.ASM
;DATE:       March 16, 1996
;TITLE:      7 segment LED and keyborad scan
;HARDWARE:   MLAB-121

; Pin Interface
DISCON1  EQU    P1.0    ;DIGIT0
DISCON2  EQU    P1.1    ;DIGIT1
PA_8255  EQU    0FA00H  ;8255 port A (SEGMENT)
PC_8255  EQU    0FA02H  ;8255 port c (pc0-pc3 = KEYIN)
CTL_8255 EQU    0FA03H  ;8255 control port
; Variables
DISBUF   EQU    32H     ;LED display buffer
HEXBUF   EQU    3AH     ;HEX buffer
SCANPF   EQU    60H     ;SCAN  - PRESS FLAG

;Program 2: keyboard scan and character display

        ORG     8100H
MAIN:
        LCALL   INIT_8255       ;set 8255 mode
        MOV     A,#88H          ;initial value to display
LOOP:
        MOV     HEXBUF,A
        MOV     HEXBUF+1,A
        LCALL   HEXBUF_TO_SEGMENT       ;convert to segment code
        LCALL   SCAN_AND_WAIT           ;scan keyboard and display
        CJNE    A,#00H,LOOP             ;loop until key 0 pressed
        LJMP    0036H
;
        $INCLUDE "STLAB05H.ASM"
;
        END
