_TEXT   SEGMENT  BYTE PUBLIC 'CODE'
_TEXT   ENDS
_DATA   SEGMENT  WORD PUBLIC 'DATA'
_DATA   ENDS
CONST   SEGMENT  WORD PUBLIC 'CONST'
CONST   ENDS
_BSS    SEGMENT  WORD PUBLIC 'BSS'
_BSS    ENDS
DGROUP  GROUP  CONST, _BSS, _DATA
        ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP

;_DATA   SEGMENT
;        EVEN
;cdata:  db      00
;
;_DATA   ENDS

_TEXT      SEGMENT
        PUBLIC  _readctr

_readctr        proc    near

        push    bp
        mov     bp,sp
        mov     dx,word ptr [bp+4]      ;base address of SEC-PC.
        mov     bx,word ptr [bp+6]      ;to copy or not to copy.
        mov     ax,word ptr [bp+8]      ;which axis

        cmp     bl,0                    ;is copy true?
        jz      nocopy
        push    ax
        mov     al,1
        out     dx,al                    ;copy ctrs
        pop     ax

nocopy: add     dx,3                    ;base address plus 3.
        out     dx,al                   ;select which counter
        sub     dx,3                    ;dx to base address

        in      al,dx                   ;read in 6 nibbles and crunch.
        mov     bh,al
        in      al,dx
        mov     bl,al

        in      al,dx
        mov     ch,al
        in      al,dx
        mov     cl,al

        in      al,dx
        mov     ah,al
        in      al,dx

        shl     bh,1
        shl     bh,1
        shl     bh,1
        shl     bh,1

        or      bh,bl

        shl     ch,1
        shl     ch,1
        shl     ch,1
        shl     ch,1

        or      ch,cl
        mov     bl,ch
        mov     cx,ax

        shl     ch,1
        shl     ch,1
        shl     ch,1
        shl     ch,1

        or      ch,cl
        mov     dh,0                    ;put high word in DX
        mov     dl,bh
        mov     ah,bl                   ;put low word in AX
        mov     al,ch

        mov     sp,bp                   ;return to calling program.
        pop     bp
        ret 
_readctr        endp
_TEXT   ENDS
END




