code    segment byte public
        assume  cs:code
        PUBLIC  readctr

readctr        proc    far 

        push    bp
        mov     bp,sp            
        mov     dx,word ptr [bp+10]      ;base address of SEC-PC.
        mov     bx,word ptr [bp+8]      ;to copy or not to copy.
        mov     ax,word ptr [bp+6]      ;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               ;high byte in dx
        mov     dl,bh
        mov     ah,bl              ;low byte in ax
        mov     al,ch

        mov     sp,bp
        pop     bp
        ret     6 
readctr        endp
code    ENDS
END




