H2DFLAG DB 0

H2A     PROC
        CMP DX,0
        JZ DX_0
        CMP DX,1
        JA H2DFLAG_1
        JB H2DFLAG_0
        CMP AX,34464
        JB H2DFLAG_0
H2DFLAG_1:
        MOV H2DFLAG,1
H2DFLAG_0:
        MOV BX,10000
        DIV BX
        PUSH DX
        CALL H2D
        POP AX
        CALL H2D_HI
        RET
DX_0:
        CALL H2D
        RET
H2A     ENDP

H2D     PROC NEAR
        MOV BX,10
        XOR CX,CX
H2DJMP1:
        INC CX
        XOR DX,DX
        DIV BX
        PUSH DX
        OR AX,AX
        JNZ H2DJMP1
H2DJMP2:
        POP AX
        ADD AL,48
        MOV AH,14
        INT 10H
        LOOP H2DJMP2
        RETN
H2D     ENDP

H2D_HI  PROC NEAR
        MOV BX,10
        XOR CX,CX
H2D_HIJMP1:
        INC CX
        XOR DX,DX
        DIV BX
        PUSH DX
        OR AX,AX
        JNZ H2D_HIJMP1
        CMP H2DFLAG,1
        JNZ H2D_HIJMP3
H2D_HIJMP2:
        CMP CX,4
        JZ H2D_HIJMP3
        MOV AX,0E30H
        INT 10H
H2D_HIJMP3:
        POP AX
        ADD AL,48
        MOV AH,14
        INT 10H
        LOOP H2D_HIJMP3
        RETN
H2D_HI  ENDP
