;* * * * * * * * * * * * * * * version 2.7 * * * * * * * * * * * * * * * ; [29c] Clear FCB prior to opening or creating a file. ; [29b] Add TAKE command file processing. ; RonB, 04/08/84 ;* * * * * * * * * * * * * * * version 2.6 * * * * * * * * * * * * * * * ; [24a] Add terminal session logging ; RonB, 03/15/84 ; * * * * * * * * * * * * * * * version 2.4 * * * * * * * * * * * * * * * ; [20e] Add regular console status check, in addition to direct I/O check. ; RonB,03/02/84 ; [19c] Give "bdos" mnemonic for vector 224. ; * * * * * * * * * * * * * * * version 2.1 * * * * * * * * * * * * * * * ; [7] Do tab expansion and suppress nulls while in telnet mode. ; RonB,12/24/83 ; * * * * * * * * * * * * * * * version 2.0 * * * * * * * * * * * * * * * ; BDOS command codes bdos equ 224 reset EQU 00H conin EQU 01H conout EQU 02H rdrin EQU 03H punout EQU 04H lstout EQU 05H dconio EQU 06H gtiob EQU 07H prstr EQU 09H consta EQU 0BH opnfil EQU 0FH clsfil EQU 10H sfirst EQU 11H snext EQU 12H delf EQU 13H readf EQU 14H writef EQU 15H makef EQU 16H readr EQU 21H writer EQU 22H cflsz EQU 23H dmaset EQU 1AH dmabas EQU 33H DSEG $ ;[29b] begin ; TAKE command file processing data area. tkfcb db 0,'KERMIT INI',0,0,0,0 ;FCB with default name rb 19 tkbuf rb 80h ;Input buffer tkptr dw 0 ;Buffer pointer tkflg db 1 ;Initially enable file input CSEG $ ;Resume coding segment. tkst: cmp tkptr, 0 ;Is file open yet? jne tkst1 call tkopn tkst1: mov bx, tkptr ;Do we need a new record? cmp bx, offset tkbuf+80h jb tkst2 call tkread mov bx, tkptr tkst2: cmp byte ptr [bx], 1Ah ;Are we at end of file? je tkst3 jmp rskp ;If not, say we have a character. tkst3: call tkcls ; otherwise end the file jmp r tkin: call tkst ;If no file input, jmp bin ; get it from the console. mov bx, tkptr mov al, [bx] ;Get character from command file record. inc tkptr cmp al, lf ;Ignore in file je tkin push ax mov dl, al ;Echo it to the display. call bout pop ax ret tkopn: lea dx, tkfcb ;Open the command file call fcbzer ;zero fcb trailer mov cl, opnfil int bdos inc al jz tkopn1 mov tkptr, offset tkbuf+80h ;If success, show we need a read jmps tkopn2 tkopn1: mov tkptr, offset tkbuf ; otherwise, load buffer with EOF mov tkbuf, 1Ah tkopn2: ret tkread: lea dx, tkbuf ;Set dma to our location. call setdma lea dx, tkfcb call sinr ;Read a record. cmp al, 0 je tkrd1 mov tkbuf, 1Ah ;If failure, load buffer with EOF. tkrd1: mov tkptr, offset tkbuf ;Reinitialize buffer pointer. call inidma ;Reset dma to normal. ret tkcls: lea dx, tkfcb ;Close command file. call closf mov tkflg, 0 ;Turn off file input flag. ret ;[29b] end tmsgcr: call tmsg ;Print the string call tcrlf ;Print a CRLF. ret tcrmsg: push dx ;Don't trash our string. call tcrlf ;Print a CRLF. pop dx ;Restore our string. call tmsg ;Print the string ret tcmsgc: push dx ;Don't trash our string. call tcrlf ;Print a CRLF. pop dx ;Restore our string. call tmsg ;Print the string call tcrlf ;Print a CRLF. ret tcrlf: lea dx, crlf ;Get a CRLF. call tmsg ;Print it. ret tmsg: push bx ;Don't clobber my ACs. mov cl, prstr ;Ask BDOS for string printing. int bdos ;What a way to call the BDOS. pop bx ret tfile: mov bx, dx ;Print filename in [dx]'s FCB ;[24a] begin mov dl, [bx] ;If explicit drive number, display it. cmp dl, 0 je tfil1 add dl, 'A'-1 push bx call bout mov dl, ':' call bout pop bx tfil1: mov cx, 11 ;Now display 11 chars of filename tfil2: push cx cmp cx, 3 ;With period before file type jne tfil3 push bx mov dl, '.' call bout pop bx tfil3: inc bx mov dl, [bx] cmp dl, ' ' ;Don't include spaces je tfil4 push bx call bout pop bx tfil4: pop cx loop tfil2 ret ;[24a] end bout: mov cl, conout ;Ask BDOS for character printing. int bdos ret bin: cmp tkflg, 0 ;Check for command file input. ;[29b] begin je bin1 jmp tkin ;[29b] end bin1: mov cl, conin ;Get a char from the console. int bdos ret binst: cmp tkflg, 0 ;Check for command file input. ;[29b] begin je binst1 jmp tkst ;[29b] end binst1: mov cl, consta ;Console input status check ;[20e] begin int bdos or al, al ;Result 0 if no character ready jz bins2 jmp rskp ;Return SKIP if character ready bins2: ret ;[20e] end dbout: cmp dl, 0 ;Skip null fillers. je dbout3 call logchr ;Log the character if necessary ;[24a] call dotab ;Do any necessary tab expansion. jmp r ; No more chars to output. dbout2: mov cl, dconio ;Put a char to the console. int bdos dbout3: ret dbin: push dx mov cl, dconio ;Get a char from the console without mov dl, 0FFH ; interference. int bdos pop dx ret dbinst: push dx mov cl, dconio ;Check the console's input status. mov dl, 0FEH int bdos pop dx or al, al ;Result 0 if no character ready ;[20e] begin jz dbins2 jmp rskp ;Return SKIP if character ready dbins2: ret ;[20e] end ;Log the terminal output character logchr: cmp logfil, 0 ;Only log if file is open ;[24a] begin je logch9 mov bx, bufpnt ;Store the character in the buffer. mov [bx], dl inc bx cmp bx, offset dma+80h ;Have we filled a buffer? jb logch1 push dx ;If so, write it to file. lea dx, lfcb call soutr pop dx lea bx, dma logch1: mov bufpnt, bx logch9: ret ;Return to output routine ;[24a] end ;Halt this program. haltf: mov cl, reset ;End this program. int bdos ret ;One never knows! ; Get the first file in a wild card search. gtjfn: call fcbzer ;clear the fcb trailer ;[29c] mov cl, sfirst int bdos ret ; Get the next file in a wild card search. gnjfn: mov cl, snext int bdos ret ; Close the file pointed to by the FCB in DX. closf: mov cl, clsfil int bdos ret ; Open the file pointed to by the FCB in DX. openf: cmp dmaflg, 0 ;Has the DMA been set up? jnz openf2 call inidma ;No, so set it up. openf2: call fcbzer ;clear the fcb trailer ;[29c] mov cl, opnfil int bdos ret ; Create the file pointed to by the FCB in DX. create: cmp dmaflg, 0 ;Has the DMA been set up? jnz creat2 call inidma ;No, so set it up. creat2: call fcbzer ;clear the fcb trailer ;[29c] mov cl, makef int bdos ret inidma: push dx lea dx, dma call setdma pop dx mov dmaflg, 0FFH ;Say we've mapped the DMA. ret fcbzer: push bx ;Clear the end of the FCB ;[29c] begin push cx ; prior to opening or creating a file. mov bx, dx add bx, 12 mov ch, 0 mov cl, 23 fcbz1: mov [bx], ch inc bx loop fcbz1 pop cx pop bx ret ;[29c] end ; Write a record to the file pointed to by the FCB in DX. soutr: mov cl, writef int bdos ret ; Read a record from the file pointed to by the FCB in DX. sinr: mov cl, readf int bdos ret ; Delete the file pointed to by the FCB in DX. delete: mov cl, delf int bdos ret ; Sets the DMA to the offset pointed to in DX and the base in DS. setdma: mov cl, dmaset int bdos mov dx, ds mov cl, dmabas int bdos ret ; Do random access read, write, or file size checks, FCB is in dx rinr: mov cl, readr int bdos ret routr: mov cl, writer int bdos ret sizef: mov cl, cflsz int bdos ret ; Jumping to this location is like retskp. It assumes the instruction ; after the call is a jmp addr. rskp: pop bp add bp, 3 push bp ret ; Jumping here is the same as a ret. r: ret