Path: utzoo!mnetor!uunet!husc6!ut-sally!nather From: nather@ut-sally.UUCP (Ed Nather) Newsgroups: comp.sys.ibm.pc Subject: Re: "abort, retry, or ignore?" : help needed Message-ID: <10423@ut-sally.UUCP> Date: 21 Feb 88 20:42:05 GMT References: <2358@chalmers.UUCP> Organization: U. Texas CS Dept., Austin, Texas Lines: 105 In article <2358@chalmers.UUCP>, johnsson@chalmers.UUCP (Thomas Johnsson) writes: > I'm in dire need of some help from the PCDOS expertise out there ... > > When issuing a read or a write to a diskette station or the printer > and the output unit in question is not ready (e.g. the diskette > station has its gate open, or the the power to the printer is off), > one get the message on the screen > > device not ready: abort, retry, or ignore? > > Now I would like to disable this, and simply let the read or write > operation return with an error indication. (I'm using the DOS file > handle operations, if that's of any help.) > > Had any one out there in netland succeded in this? > Help would be greatly appreciated! > Well, you can do it, but it isn't easy. What you must do is to write a "critcal error handler" in assembly code that intercepts the interrupt generated by the error, and returns control to the calling program. I wrote one that is dead simple -- it just moves the error status information to locations available to the main program, and then exits. For this to work, though, you must change the interrupt vectors so they point to your routine and not DOS's when you start up your program(s), and restore them when you exit. Here's the code I use: --------------------------------------------------------------------- EXTRN _errax:word, _errdi:word, _dskerr:word crit1 dw ? ; save orig int vectors here crit2 dw ? ;code to intercept critical error vectors push es . . . mov ax,es:90h ; int 24h - critical error mov crit1,ax mov ax,es:92h mov crit2,ax lea ax,crerr ; point to critical error handler mov es:90h,ax mov ax,_TEXT ; code segment set by C compiler mov es:92h,ax . . . pop es . . . ; code to uninstall the intercept push es . . . mov ax,crit1 ; remove crit error intercept mov es:90h,ax mov ax,crit2 mov es:92h,ax . . . pop es ; the interrupt service routine crerr PROC FAR ; disk error handler push ds push ax mov ax,DGROUP ; to get at variables mov ds,ax pop ax mov _errax,ax ; save causes mov _errdi,di mov _dskerr,1 mov al,20h ; end-of-interrupt to 8259 out 20h,al mov al,0 pop ds iret crerr endp --------------------------------------------------------------------- The error information is in the AX register and the DI register in a weird format described in the IBM PC Tech Reference manual, and is also listed in Norton's book for programming the IBM PC. These are just saved (and a flag is set) so the C program can take whatever action it wishes. It must define the variables (same name sans the underscore) as globals. It's ugly, but it works. It was also much too much trouble to do such a simple thing. -- Ed Nather Astronomy Dept, U of Texas @ Austin {allegra,ihnp4}!{noao,ut-sally}!utastro!nather nather@astro.AS.UTEXAS.EDU