; X Timer Test Program  - By Tenie Remmel
; Link with XTIMER

Ideal

Extrn       StartTimer:Near, StopTimer:Near, ReadTimer:Near

Model Tiny
CodeSeg
P186
Org 100h

Start:      call Main
            mov ax,4C00h
            int 21h

OutMsg      db 'Time in microseconds: '
SBuf        db 10 dup(0)

Proc        Main

            call StartTimer

            call TestProc

            call StopTimer
            call ReadTimer

            push cs cs
            pop ds es

            mov di,offset SBuf

            xor cx,cx
            test ax,ax
            jnz NoZero

            push '0'
            inc cx
            jmp PLoop

NoZero:     mov si,10

DLoop:      xor dx,dx
            div si
            mov bl,dl
            add bl,30h
            push bx
            inc cx
            test ax,ax
            jnz DLoop

PLoop:      pop ax
            mov [di],al
            inc di
            loop PLoop

            mov [byte di],'$'

            mov ah,9
            mov dx,offset OutMsg
            int 21h
            ret

EndP        Main

Proc        TestProc

            mov cx,10000
            even
tloop:      nop
            dec cx
            jnz tloop
            ret

EndP        TestProc

End Start
