; ------------- i/o primitives - receive --------------- ; ; Receive a character - timeout time is in 'B' in seconds. ; recv: push d; Save 'DE' regs. recv1: call clkspd mov e,a recv2: mvi d,86; about .1 sec recv3: call mdinst; Input from modem ready jnz recv4; Yes, get the char dcr d; Count down for timeout jnz recv3; not 0.1 sec dcr e jnz recv2; not 1.0 sec dcr b; More seconds? jnz recv1; Yes, wait ; " " ; Test for the presence of carrier - if none, go to 'CARCK' and ; continue testing for specified time. If carrier returns, continue. ; If it does not return, exit. call mdcarck; Is carrier still on? cz carck; If not, test for 15 seconds ; " " ; Modem timed out receiving - but carrier is still on. pop d; Restore 'DE' stc; Carry shows timeout ret ; ; Get character from modem. Update Chksum and CRC. recv4: call mdinp; Get data pop d push psw; Save char call updcrc; Calculate CRC add c; Add to checksum mov c,a; Save checksum pop psw; Restore the char ora a; Carry off: no error ret ; ; Common carrier test for receive and send. If carrier returns ; within TIMOUT seconds, normal program execution continues. ; Else, it will abort to CP/M via EXIT. ; carck: mvi e,timout*10 carck1: call delay; Kill .1 secs call mdcarck; Is carrier still on? rnz; return if carrier on dcr e jnz carck1; not timed out, continue testing ; " " ; Report to local console mvi a,1; Print local only sta remoff call ilprt; Report loss of carrier db cr,lf,'++ Carrier lost ++',cr,lf,0 lda optsav; Get option cpi 'R' cz delfile; Receive, Delete the file we started jmp exit; From CARCK back to CP/M prompt ; ; Delay to let all incoming stop for one second ; wait1: mvi b,1; For 1-sec call recv; See if any chars still coming in jnc wait1; Not quiet yet ret; If none for 1-sec, all done ; ; Catches anything on the modem input and ignores, ; so can wait for what we expect to receive ; a,f catch: call mdinst; Check modem status for any input rz; If none, all checked call mdinp; Else get the garbage character jmp catch; Keep going until none remaining ; ; -------------- i/o primitives - send ----------------- ; ; Send a character to the modem ; send: push psw; Save char call updcrc; Calculate CRC add c; Calculate checksum mov c,a; Save cksum send1: call mdoutst jnz send3; transmitter ready push d; else check carrier call mdcarck; Is carrier still on? cz carck; If not, check for abort pop d; returns if carrier re-appears jmp send1; Else, wait for xmit ready send3: pop psw; Modem is ready jmp mdoutp; So send it ; ; --------------- end i/o primitives ------------ ;