PAGE 64,132 ; ; CAPTURE filespec ; ; Captures all printer output to memory buffer until the buffer ; is full or a '^Z' is recieved. The contents of the buffer is ; then written to filespec and a system reset is performed. I ; use this to copy debug output to disk for later perusal and ; editing. i.e. dis-assemblies of .com files ; ; Please note that the reason for the system reset is that I have ; not found any other way to keep from hanging the system after ; the file is written. If anyone knows how please let me hear ; about it. For those of you who might be interested I have tried ; saving and restoring the original INT 17H address and the DTA ; all with no luck. Hope this helps someone out there. ; ; Ted Reuss c/o South Texas Software, Inc. ; 4544 Post Oak Place, Suite 176 ; Houston, TX 77027 ; (713) 877-8205 ; page ;INCLUDE SYSCOM.INC ;DOS equates ifndef list .xlist else SUBTTL PC-DOS FUNCTION CODES & MACRO DEFS PAGE endif ; PC-DOS INTERRUPT 21H FUNCTION CODES ; .xcref @PTERM EQU 0 ;Program terminate @KEYINE EQU 1 ;kydb input with echo @CHROUT EQU 2 ;display output @AUXIN EQU 3 ;serial input @AUXOUT EQU 4 ;serial output @LPTOUT EQU 5 ;printer output @DCONIO EQU 6 ;direct console i/o @DCONIN EQU 7 ;direct kybd input w/o echo @KEYIN EQU 8 ;kybd input w/o echo @STROUT EQU 9 ;print string @BKEYIN EQU 10 ;buffered kybd input @KEYSTA EQU 11 ;check keyboard status @CKEYIN EQU 12 ;clr kybd bufr & invoke input @DRESET EQU 13 ;disk reset @SELDSK EQU 14 ;select disk @OPENF EQU 15 ;open file @CLOSF EQU 16 ;close file @SRCH1 EQU 17 ;search for first dir entry @SRCH2 EQU 18 ;search for next dir entry @DLTEF EQU 19 ;delete file @RDSEQ EQU 20 ;sequential read @WRSEQ EQU 21 ;sequential write @CRTEF EQU 22 ;create file @RENMF EQU 23 ;rename file @GETDSK EQU 25 ;get default disk drive @SETDTA EQU 26 ;set disk transfer addr @FATADR EQU 27 ;get FAT of default drive ;undocumented feature @FATAD2 EQU 28 ;get FAT of drive in DL @RDRND EQU 33 ;random read @WRRND EQU 34 ;random write @SIZEF EQU 35 ;get file size @SETRND EQU 36 ;set random record field @SETINT EQU 37 ;set interrupt vector @BLDPS EQU 38 ;create new program segment @RDBLK EQU 39 ;read block random @WRBLK EQU 40 ;write block random @PARSEF EQU 41 ;parse filename @GETDTE EQU 42 ;get system date @SETDTE EQU 43 ;set system date @GETTME EQU 44 ;get system time @SETTME EQU 45 ;set system time @VERIFY EQU 46 ;set/reset verify switch DOSCALL MACRO FUNC,PARM1 F_C = FUNC IFNB IF F_C EQ 2 OR (F_C GE 4 AND F_C LE 6) OR F_C EQ 14 OR F_C EQ 46 MOV DL,PARM1 ELSE MOV DX,OFFSET PARM1 ENDIF ENDIF MOV AH,FUNC INT 21H ENDM .cref ifndef list .list endif ; BUFSIZ EQU 2048 ;buffer size CR EQU 0DH ;carriage return LF EQU 0AH ;linefeed EOF EQU 1AH ;end of file FCB EQU DS:005CH ;DOS file control blk ; CAPTURE SEGMENT PUBLIC 'CODE' ASSUME CS:CAPTURE,DS:CAPTURE,ES:NOTHING ORG 100H ;use EXE2BIN -> .com file START: CLI JMP INIT BUFLEN DW BUFSIZ ;buffer length BUFPTR DW OFFSET BUFFER ;ptr to next open byte DONE DB 0 ;set when done reset label dword ;see page A-5 dw 0E05BH ;TECHNICAL REF. dw 0F000H ; MANUAL INT_17 LABEL NEAR ;PRINTER INTERRUPT STI ;interrupts back on CMP CS:DONE,1 ;file closed? JZ L0005 ; yes, exit OR AH,AH ;char available? JZ L0010 ; yes, put in buf L0005: JMP L0035 ;return to caller L0010: PUSH AX PUSH BX PUSH CX PUSH DX MOV BX,CS:BUFPTR ;fetch buffer pointer MOV CS:[BX],AL ;put char. in buffer INC BX ;bump pointer MOV BYTE PTR CS:[BX],EOF ;mark eof always MOV CS:BUFPTR,BX ;save pointer CMP AL,'Z' ; eof? JNZ L0015 ; nope CMP BYTE PTR CS:[BX-2],'^' ; for sure? JZ L0020 ;yes, write buffer L0015: SUB BX,OFFSET BUFFER-1 CMP BX,CS:BUFLEN ;buffer full? JB L0030 ;no, return L0020: INC CS:DONE ;set complete flag PUSH DS ;establish data MOV AX,CS ;segment addr MOV DS,AX ;for I/O DOSCALL @SETDTA,BUFFER ;set DTA MOV CX,BUFPTR ;compute # bytes SUB CX,OFFSET BUFFER-1 ; to write DOSCALL @WRBLK,FCB ;write buffer DOSCALL @CLOSF,FCB ;close file ; call reset ;reset system ; L0030: POP DX POP CX POP BX POP AX L0035: MOV AH,0 ;return to caller IRET BUFFER EQU THIS BYTE ; SUBTTL INITIALIZATION SECTION PAGE ; ; Note that this section of code ; is overlayed by the buffer ; ERRMSG1 DB 'Invalid filespec.',CR,LF,'$' INIT: XOR AX,AX ;put a zero on stack PUSH AX ;for return to DOS DOSCALL @CRTEF,FCB ;create & open file INC AL JNZ IN10 ;if open ok DOSCALL @STROUT,ERRMSG1 ;else print errmsg RET ;return to DOS IN10: MOV WORD PTR FCB+14,1 ;set record length DOSCALL @SETRND,FCB MOV DX,OFFSET INT_17 MOV AL,17H ;reset interrupt 17h DOSCALL @SETINT ;address to INT_17 MOV DX,OFFSET BUFFER ADD DX,BUFLEN INT 27H ;return to DOS without ; ;releasing memory CAPTURE ENDS END START Press  INT 27H ;return to DO