; FILENAME      J31E21.ASM
; DESCRIPTION   SEGMENT SHIFT
; HARDWARE      JAZZ31 V2.0
; ASSEMBLER     SXA51
; START-DATE    17/11/37
; COMPANY       SILA RESEARCH CO.,LTD.

         ORG    8100H

CONA     EQU    0F800H            ;SEGMENT (0-7)
CONB     EQU    0F801H            ;DIGIT (0-3)
SOUND    EQU    00A2H             ;SOUND SYSTEM CALL

; ********** MAIN **********

EXAM:    MOV    R7,#8             ;8 DIGIT LOOP
         MOV    R6,#0             ;START DIGIT

EXAM1:   MOV    DPTR,#CONB        ;SET DIGIT
         MOVX   A,@DPTR           ;READ,MODIFY,WRITE
         ANL    A,#11111000B      ;AND BIT 0-2
         ORL    A,R6              ;DIGIT BY R6
         MOVX   @DPTR,A

         MOV    R5,#8             ;8 SEGMENT LOOP
         MOV    R4,#1             ;START SEGMENT
EXAM2:   MOV    DPTR,#CONA        ;WRITE SEGMENT
         MOV    A,R4
         MOVX   @DPTR,A
         RL     A                 ;SHIFT LEFT
         MOV    R4,A
         CALL   EXAMD
         DJNZ   R5,EXAM2          ;BACK LOOP

         MOV    A,R6              ;SOUND (FREQUENCY BY R6)
         ORL    A,#20H
         MOV    R2,A
         MOV    R3,#08H
         CALL   SOUND
         INC    R6                ;NEXT DIGIT
         DJNZ   R7,EXAM1          ;BACK DIGIT LOOP
         SJMP   EXAM              ;LOOP FOREVER

; ********** EXAMD SUB **********
; DELAY SUBROUTINE

EXAMD:   MOV    R3,#80H
EXAMD1:  MOV    R2,#0
         DJNZ   R2,$
         DJNZ   R3,EXAMD1
         RET

         END

