; FILENAME      XDP75.ASM
; DESCRIPTION   DP-75 TEST PROGRAM
; HARDWARE      JAZZ31 + DP75 (CONNECT WITH 8255 PORT)
; ASSEMBLER     SXA51
; START-DATE    14/12/36
; SOFTWARE ENG. KRIANGSAK B.
; COMPANY       SILA RESEARCH CO.,LTD.

; FUNCTION      DISPLAY 3 STEP TO DP-75
;               1. DISPLAY SEGMENT (SHIFT 0-7) 2 ROUND
;               2. FLASH DISPLAY (ALL SEGMENT)
;               3. DISPLAY NUMBER 0-F

SEGM     EQU    0FC01H
DIGT     EQU    0FC02H
CONT     EQU    0FC03H

; ********** MAIN **********

         ORG    8100H

MAIN:    MOV    DPTR,#CONT        ;SET A,B,C=OUT
         MOV    A,#80H
         MOVX   @DPTR,A

MAIN1:   MOV    R6,#2             ;DISPLAY SEGMENT
MAIN2:   MOV    R7,#8
         MOV    A,#1
MAIN3:   PUSH   ACC
         CALL   OUTDP
         MOV    R2,#5
         CALL   DTSEC
         POP    ACC
         RL     A
         DJNZ   R7,MAIN3
         DJNZ   R6,MAIN2

MAIN4:   MOV    R7,#8             ;FLASH ALL-SEGMENT
MAIN5:   MOV    A,#0FFH
         CALL   OUTDP
         MOV    R2,#1
         CALL   DTSEC
         CLR    A
         CALL   OUTDP
         MOV    R2,#1
         CALL   DTSEC
         DJNZ   R7,MAIN5

MAIN6:   MOV    R7,#16            ;DISPLAY 0-F
         MOV    R6,#0
MAIN7:   MOV    A,R6
         MOV    R2,A
         CALL   HTOSX
         CALL   OUTDP
         MOV    R2,#5
         CALL   DTSEC
         INC    R6
         DJNZ   R7,MAIN7
         LJMP   MAIN1

; ********** OUTDP SUB **********
; OUT TO DISPLAY
; IN  = A  SEGMENT CODE
; REG = A,DPTR

OUTDP:   MOV    DPTR,#SEGM        ;SEGMENT
         MOVX   @DPTR,A
         MOV    DPTR,#DIGT        ;DIGIT
         CLR    A
         MOVX   @DPTR,A
         MOV    A,#0FFH
         MOVX   @DPTR,A
         RET

; ********** HTOSX SUB **********
; ONE BYTE HEX TO SEGMENT
; IN  = R2 HEX 0-F
; OUT = A SEGMENT CODE
; REG = A,DPTR

HTOSX:   MOV    A,R2              ;MAKE SURE 0-F
         ANL    A,#0FH
         MOV    R2,A
         MOV    DPTR,#SEGTAB      ;TABLE
         MOV    A,DPL
         ADD    A,R2
         MOV    DPL,A
         MOV    A,DPH
         ADDC   A,#0
         MOV    DPH,A
         CLR    A
         MOVC   A,@A+DPTR
         RET

SEGTAB:  DB     3FH,06H,5BH,4FH        ;0123
         DB     66H,6DH,7DH,07H        ;4567
         DB     7FH,6FH,77H,7CH        ;89AB
         DB     39H,5EH,79H,71H        ;CDEF

; ********** DTSEC SUB **********
; DELAY 1/10 SECOND
; IN  = R2
; REG = R2,R3,R4

DTSEC:   MOV    R3,#179
DTSEC1:  MOV    R4,#0
         DJNZ   R4,$
         NOP
         NOP
         DJNZ   R3,DTSEC1
         DJNZ   R2,DTSEC
         RET

         END

