home *** CD-ROM | disk | FTP | other *** search
- ; ping.asm
- ;========================================================================
-
- ; Copyright (C) 1991 by Jan.Engvald@ldc.lu.se, see file COPYING.
-
- MsgEchoHead db CR, LF, "Ping with packet size "
- MsgEchoSweep db "<"
- MsgEchoSize db "0 and interval"
- MsgEchoMs db " 0 ms to "
- MsgEchoTarget db "1.2.3.4 :", CR, LF, LF
- MsgEchoStats db "───────── Packets ──────── ║ ────── Delay ms ────── ║ Packet ║ Load ║ Time ", CR, LF
- db "transmit receive diff ║ this min avg max ║ loss ║ kb/s ║ s ", CR, LF, "$$"
- MsgEcho db " 0 0 0 0 0 0 0 0.0000 % 0 0 ", CR, '$'
- MsgEchoSeqEr equ MsgEcho+26
- MsgEchoTime equ $-11
- MsgEchoLen equ $-MsgEcho-2
-
- MsgSerrTbl dw offset MsgSerrUnr
- dw offset MsgSerrObuf
- dw offset MsgSerrNoarp
- dw offset MsgSerrTimout
- dw offset MsgSerrNotraf
- SERRTABLEN equ $-MsgSerrTbl
- dw offset MsgSerrUnimpl
-
- MsgSerrUnr db LF, "Host or net unreachable", CR, LF, '$'
- MsgSerrObuf db LF, "Temporarily out of buffers", CR, LF, '$'
- MsgSerrNoarp db LF, "Got no ARP reply", CR, LF, '$'
- MsgSerrTimout db LF, "Timeout", CR, LF, '$'
- MsgSerrNotraf db LF, "Received no traffic from destination", CR, LF, '$'
-
- MsgSerrUnimpl db LF, "Send Error.", CR, LF, '$'
-
- MsgCalling db "Calling nameserver(s)... $"
- MsgNameRep db "got reply in "
- MsgNameRepTim db " ms.", CR, LF, '$'
- MsgBadName db LF, "Bad hostname (or no nameserver).$"
-
- EchoLoadCnt db 2
- even
- EchoTarget dw 0, 0 ; echo argument values
- EchoSize dw -50
- EchoInterval dw 220
- EchoData dw 101h
- EchoDataIncW dw 1
- EchoMinSize dw IPHDRLEN+UDPHDRLEN+6
-
- EchoStart dw 0, 0, 0 ; echo variables
- EchoNext dw 0
- EchoLastDispl dw 0
- EchoLastHi dw 0
- EchoMaxSize dw 1500
- EchoAvgSum dw 0, 0
- EchoFudge dw 0
- EchoLoad dw 0, 0
- EchoDrop dw 0
- EchoBufSeg dw 0
- EchoSeqRx dw 0
- EchoTxTime dw 0
- EchoRxTime dw 0
- EchoErTmpTime dw 0
- EchoErSeqHi equ EchoSizeVec+2
- EchoErSeqLo equ EchoSizeVec+4
- EchoErRepHi equ EchoSizeVec+6
- EchoErRepLo equ EchoSizeVec+8
- EchoErLosHi equ EchoSizeVec+10
- EchoErLosLo equ EchoSizeVec+12
- EchoErTmp equ EchoSizeVec+14
- EchoLastErr dw 0
- PingRowCnt dw 17
- k51200 dw 51200
- k54925 dw 54925
- k64000 dw 64000
- EchoLoadTime dw 0, 0
-
- EchoTxHi dw 0 ; echo display variables
- EchoTxLo dw 0
- EchoRxHi dw 0
- EchoRxLo dw 0
- EchoDifHi dw 0
- EchoDifLo dw 0
- EchoThis dw 0
- EchoMin dw 0ffffh
- EchoAvg dw 0
- EchoMax dw 0
- EchoLoss dw 0, 0
- EchoElapsed dw 0, 0
-
-
- ;************************************************************************
- ;* EchoAwhile
- ;************************************************************************
-
- EchoAwhile proc near
- assume ds:code_s
- call HwTicksNoHi
- mov EchoStart,si ; note start ticks
- mov EchoStart+2,dx
- mov EchoLoadTime,dx
-
- mov di,offset EchoSizeVec ; clear error size table
- mov cx,(EchoSizeEnd-EchoSizeVec)/2
- xor ax,ax
- rep stosw
-
- cmp EchoTarget,ax ; want to ping someone?
- jne EchoYes
-
- test ArgFlags,TERM_WAIT ; ping serving?
- jz EchoNo
-
- mov dx,offset MsgEchoStats
- call DosPr$
- or GenFlags,ECHO_DISPL
- EchoNo:
- ret
-
- EchoYes:
- call InitTimer ; prepare millisecond timing
-
- mov ax,ArgFlags
- and ax,STOP_ON_ERR
- xor ax,NO_ERR_YET+STOP_ON_ERR+NO_DROP_YET
- or GenFlags,ax
-
- call HardwareTicks
- mov EchoStart,si ; note start ticks
- mov EchoStart+2,dx
- mov EchoStart+4,ax
- mov EchoLoadTime,dx
- mov EchoLoadTime+2,ax
- mov si,dx
-
- call DblShrX
- mov EchoNext,ax
-
- cmp EchoTarget,127 ; dns lookup to do?
- jne EchoIpAddr
-
- mov dx,offset MsgCalling
- call DosPr$
-
- mov dx,2345h ; ping udp src port
- xor ax,ax ; NsId
- mov si,offset EchoNameBuf ; Ns question string
-
- call NsResolve ; call nameserver(s)
-
- call HardwareTicks ; response time
- mov si,dx
- sub ax,EchoStart+4
- sbb dx,EchoStart+2
- div kTimerScale
- mov di,offset MsgNameRepTim
- call PutNumD4Fb
-
- mov dx,offset MsgNameRep ; display it.
- call DosPr$
-
- cmp EchoTarget,127 ; name resolved?
- jne EchoIpAddr
- EchoErrTerm:
- mov dx,offset MsgBadName
- mov al,'e'-'0'
- call PrTerminate
-
- EchoIpAddr:
- mov EchoTxTime,si ; intialize timers
- mov EchoRxTime,si
- if TBLBUILD
- test ArgFlags,MAKE_TABLE
- jz EchoNotTbl
- call TableReady ; allow tablebuilding now
- EchoNotTbl:
- endif ; TBLBUILD
- or GenFlags,ECHO_DISPL
-
- mov ax,EchoInterval ; check interval
- test ArgFlags,NOT_SAFE
- jnz EchoAsIs
-
- cmp ax,128
- jge EchoAsItIs
- mov ax,128
- EchoAsItIs:
- test ArgFlags,MICRO_100
- jz EchoAsIs
- cmp ax,128*10
- jge EchoAsIs
- mov ax,128*10
- EchoAsIs:
- mov EchoInterval,ax
-
- call BufAlloc ; get a send buf
- assume ds:nothing
- jz EchoErrTerm
-
- call MakeSendDescr
-
- mov [di].uIcmpTypeCode,8 ; type = echo request
- test cs:GenFlags,UDP_ECHO
- jz EchoUseIcmp
-
- mov word ptr cs:MsgEchoHead+2,'cE'
- mov word ptr cs:MsgEchoHead+4,'oh'
- mov word ptr [di].uUdpSrc,0703h ; my udp echo port
- mov word ptr [di].uUdpDst,0900h ; dst discard port
- test cs:ArgFlags,UDP_DISCARD
- jnz EchoUseIcmp
- mov word ptr [di].uUdpDst,0700h ; dst echo port
- EchoUseIcmp:
- mov cx,cs:MyGiant ; fill buffer with data
- sub cx,HWHDRLEN+IPHDRLEN+ICMPHDRLEN+6
- shr cx,1
- add di,ICMPHDRLEN+6
- mov ax,cs:EchoData
- EchoFillLoop:
- stosw
- add ax,cs:EchoDataIncW
- loop EchoFillLoop
- EchoFillEnd:
- mov dx,cs:EchoTarget ; set IP destination
- mov ax,cs:EchoTarget+2
- call SetIpDst
-
- mov ds,cs:MySegm
- assume ds:code_s
- mov EchoBufSeg,es
-
- mov si,offset EchoTarget
- mov di,offset MsgEchoTarget
- call PutIpNum ; tell who we are pinging
-
- mov dx,EchoMinSize
- sub dx,IPHDRLEN
- cmp dx,ICMPHDRLEN+6
- jns EchoMinOK
- mov dx,ICMPHDRLEN+6
- EchoMinOK:
- mov ax,EchoSize
- neg ax
- jns EchoSizeNeg
- mov dx,GIANTTR
- neg ax
- mov MsgEchoSweep,' '
- EchoSizeNeg:
- mov cx,MyGiant
- sub cx,HWHDRLEN+IPHDRLEN+ICMPHDRLEN+6
- sub ax,IPHDRLEN+ICMPHDRLEN+6
- cmp ax,cx
- jbe EchoOkSize
- xor ax,ax
- EchoOkSize:
- add ax,ICMPHDRLEN+6
- mov EchoSize,ax
- mov EchoMaxSize,ax
-
- cmp dx,ax
- jbe EchoMinMax
- mov dx,ax
- EchoMinMax:
- mov EchoMinSize,dx
-
- cmp ax,dx
- je EchoFixedSz
- push ax
- mov ax,dx
- add ax,IPHDRLEN
- mov di,offset MsgEchoSweep-4
- call PutNumD4Fb ; and the min size used
- pop ax
- EchoFixedSz:
- add ax,IPHDRLEN
- mov di,offset MsgEchoSize
- mov PutMinDigits,1
- call PutNum ; and the packet size used
-
- mov ax,EchoInterval
- push ax
- mov di,offset MsgEchoMs
- mov PutMinDigits,6
- call PutNumFb ; and interval in ms
- pop ax
- test ArgFlags,MICRO_100
- jz Echo1ms
- mov dh,MsgEchoMs+5
- mov dl,'.'
- mov word ptr MsgEchoMs+5,dx
- mul k51200 ; make interval close to 0.1 ms
- jmp short EchoPrHdr
- Echo1ms:
- mul k64000 ; make interval close to 1 ms
- EchoPrHdr:
- div k54925
- mov EchoInterval,ax
- mov dx,offset MsgEchoHead
- call DosPr$
-
- EchoLoop:
- call Something2Do ; process other things
-
- test GenFlags,NO_ERR_YET+CONT_ON_ERR ; want to stop on sequence errs?
- jz EchoEnd0
-
- call AnyKey ; first key stops sending
- jz EchoNoKey
- EchoEnd0:
- jmp EchoEnd
- EchoNoKey:
- call Something2Do ; called to slow down client
-
- call HardwareTicks
- mov es,EchoBufSeg
- mov di,es:[bx].dPtrUdp
- mov es:[di].uUdpData,ax
- mov es:[di].uUdpData+2,dx
-
- call DblShrX
- mov dx,EchoNext
- cmp ax,dx ; time to send next echo pkt?
- js EchoLoop
-
- add dx,EchoInterval
- cmp dx,ax
- jns EchoSetNext
- mov dx,ax
- EchoSetNext:
- mov EchoNext,dx ; next send time
-
- mov dx,es:[di].uUdpData+2
- mov EchoTxTime,dx
-
- mov cx,EchoSize ; compute packet size
- inc cx
- cmp cx,EchoMaxSize
- jbe EchoNormSize
- mov cx,EchoMinSize
- EchoNormSize:
- mov EchoSize,cx
-
- mov di,cx ; IP data length
- shl di,1
- inc word ptr EchoSizeVec[di]
-
- mov ax,EchoTxLo ; increment send counters
- add ax,1
- mov EchoTxLo,ax
- adc EchoTxHi,0
- mov EchoFudge,1
-
- mov ds,EchoBufSeg
- assume ds:nothing
- mov di,[bx].dPtrUdp ; put sequence number
- mov [di].uUdpData+4,ax
- mov [bx].dPktLen,cx ; and IP data length
-
- test cs:GenFlags,UDP_ECHO
- jnz EchoUdp
- call SendIcmpPkt ; send icmp echo pkt
- EchoLoop8:
- mov ds,cs:MySegm
- assume ds:code_s
- jnz EchoErr ; any errors?
- EchoLoop9:
- mov EchoLastErr,cx
- jmp EchoLoop
-
- EchoUdp:
- call SendUdpPkt ; send udp echo pkt
- jmp short EchoLoop8
-
- EchoErr:
- cmp cx,EchoLastErr
- je EchoLoop9
-
- push cx
- xor ch,ch
- test cl,01 ; odd errs not allowed
- jnz EchoErrUndef
- cmp cl,SERRTABLEN
- jb EchoErrExist
- EchoErrUndef:
- mov cl,SERRTABLEN
- EchoErrExist:
- mov si,cx
- mov dx,MsgSerrTbl[si]
- call DosPr$
- pop cx
- mov ds,EchoBufSeg
- test ArgFlags,TERM_WAIT
- jnz EchoLoop9
-
- EchoEnd:
- mov ds,EchoBufSeg
- assume ds:nothing
- call BufRelease ; release send buffer
- push cs
- push cs
- pop ds
- assume ds:code_s
- pop es
-
- mov EchoFudge,0
- or ArgFlags,TERM_WAIT ; allow late packets to arrive
- ret
- EchoAwhile endp
-
-
-
- if DEBUG or TBLBUILD
- TstEqual proc near
- assume ds:nothing
- jne TstErr
- ret
- TstEqual endp
- endif ; DEBUG or TBLBUILD
-
- if DEBUG
-
- TstBufLinks proc near
- assume ds:nothing
- ja TstErr
- mov si,di
- inc cx
- TstLinkLoop:
- if DEBUG ge 6
- .386
- push di
- push eax
- push cx
-
- cmp di,offset FreeBufs
- je BufChkEnd
- ifdef SMALLBUFS
- cmp di,offset FreeSmal
- je BufChkEnd
- endif ; SMALLBUFS
- push ax
- mov cx,(dHwDst-dPtrIp)/4
- if DEBUG ge 8
- mov cx,((dHwDst-dPtrIp)+(BUFSIZESML-DESCRLEN))/4
- mov ax,es:[di].dHomeList
- cmp ax,offset FreeBufs
- jne BufChkSml
- mov cx,((dHwDst-dPtrIp)+(BUFSIZE-DESCRLEN))/4
- BufChkSml:
- endif ; DEBUG ge 8
- lea di,[di].dPtrPhys
- mov eax,0aaaaaaaah ; contents changed?
- scasw
- repe scasd
- pop ax
- call TstEqual
- BufChkEnd:
- pop cx
- pop eax
- pop di
-
- mov bp,bx
- mov ax,dx
- mov bx,di
- mov dx,es
- .8086
- endif ; DEBUG ge 6
- les di,es:[di].dNext
- lds si,[si].dPrev
- loop TstLinkLoop
-
- cmp si,di
- jne TstErr
- mov cx,ds
- cmp cx,cs:MySegm
- jne TstErr
- ret
- TstBufLinks endp
-
- endif ; DEBUG
-
- TstErr:
- call Terminate
-
-
-
- ;************************************************************************
- ;* EchoDisplay
- ;************************************************************************
-
-
- EchoDisplay proc near
- assume ds:code_s
- if DEBUG or TBLBUILD
- mov al,'s'-'0'
- cmp word ptr StackLow,0 ; stack overflowed?
- call TstEqual
- endif ; DEBUG or TBLBUILD
-
- if DEBUG
- mov al,'t'-'0'
- cmp word ptr phd_dioa,0 ; stack overflowed?
- call TstEqual
-
- mov al,'i'-'0'
- test GenFlags,DBGINTERR ; any interrupt debug errs?
- call TstEqual
-
- mov cx,MyNbufs ; any buffers damaged?
- mov bx,offset BufStart
- mov al,'u'-'0'
- BufTestLoop:
- cmp [bx].dHomeList,offset FreeBufs
- call TstEqual
- add bx,MyBufSize
- loop BufTestLoop
-
- push cs
- pop es
- mov di,offset FreeBufs
- cli
- mov cx,[di].lBufsAvail
- cmp cx,MaxAvail
- call TstBufLinks
- cmp di,offset FreeBufs
- call TstEqual
- sti
-
- ifdef SMALLBUFS
- mov bx,offset BufStart+NBUFS*BUFSIZE
- mov cx,NBUFSMALL
- mov al,'v'-'0'
- TstSmlLoop:
- cmp [bx].dHomeList,offset FreeSmal
- call TstEqual
- add bx,BUFSIZESML
- loop TstSmlLoop
-
- cli
- mov di,offset FreeSmal
- mov cx,[di].lBufsAvail
- cmp cx,NBUFSMALL
- call TstBufLinks
- cmp di,offset FreeSmal
- call TstEqual
- sti
- endif ; SMALLBUFS
- endif ; DEBUG
-
- if TBLBUILD
- cmp EchoTarget,0 ; are we pinging?
- jne EchoDispYes
- test ArgFlags,MAKE_TABLE
- jz EchoDispYes
- call TblDisplay ; -no, must be tbl building
- ret
-
- EchoDispYes: ; -yes, we are pinging
- endif ; TBLBUILD
- test GenFlags,ECHO_DISPL
- jz EchoDispRet
-
- mov cx,SavedTicks
- shr cx,1
- shr cx,1
- mov ax,EchoLastDispl
- shr ax,1
- shr ax,1
- cmp ax,cx ; time to update display?
- jne EchoDispNow
- EchoDispRet:
- ret
-
- EchoDispNow:
- cli
- mov dx,EchoAvgSum
- mov ax,EchoAvgSum+2
- mov cx,EchoRxHi
- mov bx,EchoRxLo
- sti
- call AdjTo16Bits
- jz EchoSkipAvg ; avoid div by zero
-
- div bx
- if DEBUG ge 2
- mov ax,MinAvail ; Show min available bufs
- endif ; DEBUG ge 2
- mov EchoAvg,ax ; average delay
- EchoSkipAvg:
-
- cmp EchoTarget,0
- jne $+5
- jmp EchoDspDiscard
-
- mov dx,EchoTxHi ; compute difference tx - rx
- mov ax,EchoTxLo
- sub ax,EchoFudge ; subtract one if just
- sbb dx,0 ; sent a pkt
- push ax
- push dx
- cli
- sub ax,EchoRxLo
- sbb dx,EchoRxHi
- sti
- jns EchoDifPos ; use abs(tx-rx)
- call NegDxAx
- EchoDifPos:
- mov EchoDifHi,dx
- mov EchoDifLo,ax
-
- and GenFlags,not PING_DELAY
- mov si,EchoMax ; convert ms delay to ticks
- or si,si
- jnz EchoGotMax
- mov si,2000
- EchoGotMax:
- add si,500
- mov cl,5 ; with a margin
- shr si,cl
- push si ; and save it
-
- mov cx,EchoTxTime
- add cx,si
- add si,EchoRxTime
- cmp cx,SavedTicks ; did we stop a while ago?
- js EchoDispLoss ; - yes, use diff
-
- cmp si,EchoTxTime ; received anything lately?
- jns EchoUseLoss ; - yes
-
- and GenFlags,not (NO_ERR_YET+NO_DROP_YET) ; - no, he
- jmp short EchoDispLoss ; probably died
- EchoUseLoss:
- mov ax,word ptr EchoErLosLo ; use loss cntr
- mov dx,word ptr EchoErLosHi
- or GenFlags,PING_DELAY+NO_DROP_YET
- EchoDispLoss:
- mov cl,2 ; compute packet loss
- call DblShl ; multiply by 100
- mov si,dx
- mov bx,ax
- mov cl,3
- call DblShl
- add bx,ax
- adc si,dx
- shl ax,1
- rcl dx,1
- add ax,bx
- adc dx,si
-
- pop si
- pop cx
- pop bx
-
- call AdjTo16Bits
- jz EchoSkipLoss ; avoid div by zero
-
- div bx
- mov EchoLoss,ax
-
- mov ax,dx ; fractional loss
- mul k10000
- div bx
- mov EchoLoss+2,ax
- EchoSkipLoss:
- shr si,1
- add si,EchoErTmpTime
- cmp si,SavedTicks
- jns EchoDspTmp
- cli
- mov ax,word ptr EchoErTmp ; make temp err permanent
- add word ptr EchoErLosLo,ax
- xor ax,ax
- adc word ptr EchoErLosHi,ax
- mov word ptr EchoErTmp,ax
- sti
- EchoDspTmp:
-
- EchoDspDiscard:
- push cs ; edit echo values
- pop es
-
- mov di,offset MsgEcho-1
- mov si,offset EchoTxHi
- mov PutNumFiller,' '
- mov PutMinDigits,9
- mov cx,3
- call PutBigNums ; tx and rx and diff
-
- mov PutMinDigits,6
- inc di
- mov cx,5
- EchoDispLoop:
- push cx
- mov cl,1
- call PutNums ; delays and loss
- pop cx
- loop EchoDispLoop
-
- inc di
- mov cl,1
- mov PutMinDigits,4
- call PutNumsF0 ; .0000%
-
- call HardwareTicks
- push dx
- push si
-
- dec EchoLoadCnt ; update load every 2:nd time
- jnz EchoLoad1st
-
- mov EchoLoadCnt,2
- mov bx,ax
- mov cx,dx
- sub ax,EchoLoadTime+2
- sbb dx,EchoLoadTime
- mov EchoLoadTime+2,bx
- mov EchoLoadTime,cx
- js EchoLoad1st ; avoid overflow
-
- div kTimerScale
- mov bx,ax
- cli
- mov ax,EchoLoad+2
- mov dx,EchoLoad
- mov EchoLoad+2,0
- mov EchoLoad,0
- sti
- mov cl,3
- call DblShl
- div bx
- add di,3
- inc PutMinDigits
- call PutNumFb ; load kb/s
- EchoLoad1st:
- pop dx ; compute elapsed time
- pop ax
- cmp dx,EchoLastHi
- jae EchoLastGrows
-
- mov bx,EchoLastDispl
- mov cx,EchoLastHi
- sub EchoStart+2,bx
- sbb EchoStart,cx
- EchoLastGrows:
- mov EchoLastDispl,ax
- mov EchoLastHi,dx
- sub ax,EchoStart+2
- sbb dx,EchoStart
- mov cl,4 ; divide # of ticks by 18.2
- call DblShr
- mov EchoElapsed+2,ax
- mov EchoElapsed,dx
- mov cl,3
- call DblShr
- sub EchoElapsed+2,ax
- sbb EchoElapsed,dx
- mov cl,5
- call DblShr
- add ax,EchoElapsed+2
- adc dx,EchoElapsed
- mov PutNumFiller,' '
- mov PutMinDigits,8
- mov di,offset MsgEchoTime
- call PutBigNum ; elapsed time
- if DEBUG
- mov dx,280h+10h ; assume WD card at IO 280h
- xor ax,ax
- xor cx,cx
- cli
- out dx,al ; set page 0
- call IoDelay
- add dx,0eh
- in al,dx ; readnadclear bad CRC ctr
- add cx,ax
- inc dx
- in al,dx ; readandclear lost frames ctr
- sti
- add cx,ax
- add EchoDrop,cx ; add out of bufs ctr
- endif ; DEBUG
- mov ax,EchoDrop
- if DEBUG eq 0
- or ax,ax
- jz EchoNoDrops
- endif ; DEBUG eq 0
- mov di,offset MsgEcho+18 ; place before diff
- mov PutMinDigits,1
- call PutNum ; show dropped packets
- mov byte ptr [di],' '
- EchoNoDrops:
- xor si,si
- cmp word ptr EchoErRepLo,si ; any repeated pkts?
- jz EchoDispNoRep
- inc si
- EchoDispNoRep:
- test GenFlags,NO_DROP_YET
- jz EchoDispDrop
- mov dx,word ptr EchoErLosLo ; any lost packet events?
- or dx,word ptr EchoErTmp
- jz EchoDispNoLoss
- EchoDispDrop:
- lodsw ; add si,2
- EchoDispNoLoss:
- cmp word ptr EchoErSeqLo,0 ; any out of sequence?
- jz EchoDispInSeq
- lodsw ; add si,4
- lodsw
- EchoDispInSeq:
- mov al,EchoErrChar[si]
- mov MsgEchoSeqEr,al ; put rep/seq/lost char
-
- if 1
- test ArgFlags,AVOID_HDWR
- jnz EchoDspDos
-
- test GenFlags,GOT_DSP_ROW
- jnz EchoDspGotRow
-
- mov ah,15 ; get screen mode
- int 10h ; call video BIOS
- cmp al,7 ; is it mono?
- mov dx,0b000h
- jz K1 ; yes
- mov dh,0b8h ; no, set for color
- K1:
- mov EchoDispPar,dx
-
- mov ah,03h
- xor bx,bx
- int 10h ; get current row
- mov al,160
- mul dh
- mov EchoDspRow,ax
- or GenFlags,GOT_DSP_ROW
- EchoDspGotRow:
- mov di,EchoDspRow
- push es
- mov es,EchoDispPar
- mov si,offset MsgEcho
- mov cx,MsgEchoLen
- mov ax,es:[di]
- EchoDspL1:
- lodsb ; display echo values
- stosw
- loop EchoDspL1
-
- pop es
- jmp short EchoDspRet
- EchoDspDos:
- endif
- mov dx,offset MsgEcho ; display echo values
- call DosPr$
- EchoDspRet:
- ret
-
- EchoDispPar dw 0b800h
- EchoDspRow dw (25-1)*160
- EchoDisplay endp
-
-
- ; seq lost rep
- EchoErrChar db ' ' ; 0 0 0 space
- db 0eh ; 0 0 1 double music note
- db '.' ; 0 1 0 dot
- db ':' ; 0 1 1 colon (double dot)
- db "'" ; 1 0 0 apostrophe
- db '"' ; 1 0 1 quote (double apostrophe)
- db '!' ; 1 1 0 exclamation mark
- db 13h ; 1 1 1 double exclamation mark
-
-
-
- ;************************************************************************
- ;* AdjTo16Bits
- ;************************************************************************
-
- Adjust:
- shr dx,1 ; shift 32 bits right
- rcr ax,1
- shr cx,1
- rcr bx,1
- AdjTo16Bits:
- or cx,cx ; fits in 16 bits?
- jnz Adjust
- or dx,dx
- jnz Adjust
- or bx,bx ; avoid div by zero
- ret
-
-
-
- ;************************************************************************
- ;* DblShrX
- ;************************************************************************
-
- DblShrX proc near
- mov cl,7
- test ArgFlags,MICRO_100
- jnz DblShr
- DblShr10:
- mov cl,10
- DblShr:
- xor ch,ch
- DblShrNext:
- shr dx,1 ; shift 32 bits right
- rcr ax,1
- loop DblShrNext
- ret
- DblShrX endp
-
-
-
- ;************************************************************************
- ;* DblShl
- ;************************************************************************
-
- DblShl proc near
- xor ch,ch
- DblShlNext:
- shl ax,1 ; shift 32 bits left
- rcl dx,1
- loop DblShlNext
- ret
- DblShl endp
-
-
-
- ;************************************************************************
- ;* EchoCalc
- ;************************************************************************
-
- even
- kTimerScale dw TimerResolution
-
- EchoCalc proc near
- assume ds:nothing
- mov si,[bx].dPktLen ; update error size table
-
- mov cx,ds ; save ds in cx until return
- mov es,cx
- mov ds,cs:MySegm
- assume ds:code_s
-
- shl si,1
- dec word ptr EchoSizeVec[si]
-
- add EchoRxLo,1 ; increment receive counters
- adc EchoRxHi,0
- mov EchoFudge,0
-
- mov ax,EchoSeqRx
- inc ax
- cmp ax,es:[di].uUdpData+4 ; packet in sequence?
- jne EchoCalcChkSeq
- EchoCalcInSeq:
- mov EchoSeqRx,ax
- EchoCalcDelay:
- call HardwareTicks ; compute delay
- mov EchoRxTime,dx
- sub ax,es:[di].uUdpData
- sbb dx,es:[di].uUdpData+2
- js EchoCalcRet
- div kTimerScale
- mov EchoThis,ax ; delay for this packet
-
- add EchoAvgSum+2,ax
- adc EchoAvgSum,0
-
- cmp ax,EchoMin
- jb EchoSetMin
- EchoChkMax:
- cmp ax,EchoMax
- ja EchoSetMax
- EchoCalcRet:
- ret
-
- EchoSetMin:
- mov EchoMin,ax ; minimum delay
- jmp short EchoChkMax
- EchoSetMax:
- mov EchoMax,ax ; maximum delay
- ret
-
- EchoCalcNonSeq:
- and GenFlags,not NO_ERR_YET
- jmp short EchoCalcDelay
-
- EchoCalcChkSeq:
- js EchoCalcDrop ; missing packet(s)?
-
- dec ax
- cmp ax,es:[di].uUdpData+4 ; repeat of latest packet?
- je EchoCalcRepeat
-
- add word ptr EchoErSeqLo,1 ; inc out of sequence cntr
- adc word ptr EchoErSeqHi,0
-
- mov dx,word ptr EchoErTmp
- dec dx
- js EchoLostMain ; use tmp or main counter?
- mov word ptr EchoErTmp,dx
- jmp short EchoCalcNonSeq
- EchoLostMain:
- sub word ptr EchoErLosLo,1 ; after all: wasn't lost
- sbb word ptr EchoErLosHi,0
- jmp short EchoCalcNonSeq
- EchoCalcRepeat:
- add word ptr EchoErRepLo,1 ; inc repeated pkts cntr
- adc word ptr EchoErRepHi,0
- jmp short EchoCalcNonSeq
- EchoCalcDrop:
- mov dx,es:[di].uUdpData+4
- mov EchoSeqRx,dx
- sub dx,ax
- mov ax,word ptr EchoErTmp
- or ax,ax ; old or new occurance?
- jnz EchoDropMore
- mov si,SavedTicks
- mov EchoErTmpTime,si ; -new, initialize timer
- EchoDropMore:
- add ax,dx
- mov word ptr EchoErTmp,ax ; add to temporary drops
- jmp EchoCalcNonSeq
- EchoCalc endp
-
-
-
- ;========================================================================
- ; endinclude
-