;
;*******************************************************************************
;
CODE_SEGMENT    SEGMENT 'CODE'
.286
;
;*******************************************************************************
;
MY_PROGRAM      PROC    FAR
                ASSUME  CS:CODE_SEGMENT

MY_START:       PUSH    CS                      ;
                POP     ES                      ;
                MOV     DI,OFFSET CLOCK_STRING  ;
                MOV     AH,0                    ;
                INT     1Ah                     ;
                SUB     AX,0008h                ;
                SBB     DX,0000h                ;
                MOV     AX,DX                   ;
                MOV     DX,CX                   ;
                MOV     CL,04h                  ;
                SHL     DX,CL                   ;
                MOV     BX,AX                   ;
                MOV     CL,0Ch                  ;
                SHR     BX,CL                   ;
                ADD     DX,BX                   ;
                MOV     CL,04h                  ;
                SHL     AX,CL                   ;
                MOV     BX,4446h                ;
                DIV     BX                      ;
                PUSH    DX                      ; Save SECONDS
                MOV     BX,003Ch                ;
                XOR     DX,DX                   ;
                DIV     BX                      ;
                PUSH    DX                      ; Save MINUTES
                CMP     AX,0000h                ;
                JNE     NO_AFTERNOON            ;
                MOV     AX,000Ch                ;
NO_AFTERNOON:   AAM                             ; Ascii adjust
                ADD     AX,3030h                ; Make True Ascii
                MOV     DX,AX                   ;
                MOV     AL,DH                   ; Display HOURS
                STOSB                           ;
                MOV     AL,DL                   ;
                STOSB                           ;
                INC     DI                      ;
                POP     AX                      ;--------------------
                AAM                             ; Ascii adjust
                ADD     AX,3030h                ; Make True Ascii
                MOV     DX,AX                   ;
                MOV     AL,DH                   ; Display Minutes
                STOSB                           ;
                MOV     AL,DL                   ;
                STOSB                           ;
                INC     DI                      ;
                POP     AX                      ;--------------------
                XOR     DX,DX                   ;
                MOV     BX,003Ch                ;
                MUL     BX                      ;
                MOV     BX,4446h                ;
                DIV     BX                      ;
                AAM                             ; Ascii adjust
                ADD     AX,3030h                ; Make True Ascii
                MOV     DX,AX                   ;
                MOV     AL,DH                   ; Display Seconds
                STOSB                           ;
                MOV     AL,DL                   ;
                STOSB                           ;
                MOV     AH,62h                  ;
                INT     21h                     ;
                MOV     DS,BX                   ;
                MOV     SI,0082h                ;
                MOV     CX,0050h                ; FULL LINE CHECK
                MOV     BX,0001h                ;
                MOV     DX,0101h                ;
READ_CMDLINE:   LODSB                           ;
                CMP     AL,'X'                  ; Compare AL with 'X'
                JE      X_PARAM                 ;
                CMP     AL,'Y'                  ; Compare AL with 'Y'
                JE      Y_PARAM                 ;
                CMP     AL,'I'                  ; Compare AL with 'I'
                JE      INK_PARAM               ;
                CMP     AL,'P'                  ; Compare AL with 'P'
                JE      PAPER_PARAM             ;
                CMP     AL,0Dh                  ;
                JE      STOP_READ               ;
LOOP_AGAIN:     LOOP    READ_CMDLINE            ;
                JMP     STOP_READ               ;
X_PARAM:        LODSB                           ;
                LODSB                           ;
                CALL    MAKE_ASCII_NUMBER       ;
                SHL     AL,4                    ;
                MOV     DH,AL                   ;
                LODSB                           ;
                CALL    MAKE_ASCII_NUMBER       ;
                OR      DH,AL                   ;
                SUB     CX,3                    ;
                DEC     DH                      ;
                JMP     LOOP_AGAIN              ;
Y_PARAM:        LODSB                           ;
                LODSB                           ;
                CALL    MAKE_ASCII_NUMBER       ;
                SHL     AL,4                    ;
                MOV     DL,AL                   ;
                LODSB                           ;
                CALL    MAKE_ASCII_NUMBER       ;
                OR      DL,AL                   ;
                DEC     DL                      ;
                SUB     CX,3                    ;
                JMP     LOOP_AGAIN              ;
INK_PARAM:      LODSB                           ;
                LODSB                           ;
                CALL    MAKE_ASCII_NUMBER       ;
                SHL     AL,4                    ;
                MOV     BL,AL                   ;
                LODSB                           ;
                CALL    MAKE_ASCII_NUMBER       ;
                OR      BL,AL                   ;
                SUB     CX,3                    ;
                JMP     LOOP_AGAIN              ;
PAPER_PARAM:    LODSB                           ;
                LODSB                           ;
                CALL    MAKE_ASCII_NUMBER       ;
                SHL     AL,4                    ;
                MOV     BH,AL                   ;
                LODSB                           ;
                CALL    MAKE_ASCII_NUMBER       ;
                OR      BH,AL                   ;
                SUB     CX,3                    ;
                JMP     LOOP_AGAIN              ;
STOP_READ:      PUSH    BX                      ;
                PUSH    DX                      ;
                MOV     AX,1301h                ;
                MOV     BL,BH                   ;
                AND     BX,000Fh                ;
                MOV     CX,0008h                ;
                MOV     BP,OFFSET NULL_STRING   ;
                MOV     BH,0                    ;
                INT     10h                     ;
                POP     DX                      ;
                POP     BX                      ;
                MOV     AX,1301h                ;
                AND     BX,00FFh                ;
                MOV     CX,0008h                ;
                MOV     BP,OFFSET CLOCK_STRING  ;
                MOV     BH,0                    ;
                INT     10h                     ;
                MOV     AX,4C00h                ;
                INT     21h                     ;
CLOCK_STRING    LABEL   WORD
                DB      '  :  :  '
NULL_STRING     LABEL   WORD
                DB      'лллллллллллллллллллллллл'

MY_PROGRAM      ENDP
;
;*******************************************************************************
;
MAKE_ASCII_NUMBER       PROC    NEAR

                        SUB     AL,030h                 ;
                        CMP     AL,09h                  ;
                        JLE     MAKE_ASCII_NUMBER_EXIT  ;
                        SUB     AL,07h                  ;
MAKE_ASCII_NUMBER_EXIT: RET                             ;

MAKE_ASCII_NUMBER       ENDP
;
;*******************************************************************************
;
CODE_SEGMENT    ENDS
                END     MY_START
