greyelf@wpi.wpi.edu (Michael J Pender) (02/13/90)
I've written a binary program that runs under Prodos 8. I want to be able to have the binary section of the program report if an error occurs, rather than crashing the system when it runs out of memory. How does one instruct Prodos that an error has occurred, and to send an error code back to the currently executing basic program? --- Michael J Pender Jr Box 1942 c/o W.P.I. W.O.S. is not dead. greyelf@wpi.bitnet 100 Institute Rd. ...its time to get started, greyelf@wpi.wpi.edu Worcester, Ma 01609 there is much to be done. If my next computer isn't a IIgs, it won't be an apple... Me.
cs225af@ux1.cso.uiuc.edu (02/13/90)
If you just need to send an error back to an Applesoft BASIC program, to be trapped by an ONERR GOTO routine: LDX #err JMP $D412 will do the trick. It calls the routine Applesoft uses to generate its own errors. Set the error code to whatever you want, and your ONERR GOTO can check for it w/ PEEK (222). Also: JMP $DD76 generates a ?TYPE MISMATCH ERROR JMP $DEC9 generates a ?SYNTAX ERROR all this may not be too clean, but under Applesoft it works like a charm. If this isn't what you were asking, just ignore all the above. =) -- rubio
mattd@Apple.COM (Matt Deatherage) (02/19/90)
In article <15800070@ux1.cso.uiuc.edu> cs225af@ux1.cso.uiuc.edu writes: > > >If you just need to send an error back to an Applesoft BASIC program, to >be trapped by an ONERR GOTO routine: > >LDX #err >JMP $D412 > >will do the trick. It calls the routine Applesoft uses to generate its own >errors. Set the error code to whatever you want, and your ONERR GOTO >can check for it w/ PEEK (222). Also: > >JMP $DD76 generates a ?TYPE MISMATCH ERROR >JMP $DEC9 generates a ?SYNTAX ERROR > >all this may not be too clean, but under Applesoft it works like a charm. >If this isn't what you were asking, just ignore all the above. =) > >-- rubio Jumping to internal AppleSoft entry points is still not the world's best idea, no matter how unlikely they are to change. It's even a worse idea when dealing with ProDOS, because AppleSoft in ROM doesn't know how to handle MLI error codes. There are three routines you should consider. All are entered through BASIC.SYSTEM's global page at $BE00. BADCALL converts MLI error codes into BASIC.SYSTEM error codes (the ones ONERR GOTO routines expect). It takes the MLI error code in the A register and returns the BASIC.SYSTEM error code in A. Save other registers if you need them, just in case. The entry point, according to the P8 Technical Reference Manual (where all this is discussed) is $BE8B. ERROUT is vectored through $BE09. It takes an error code in the Accumulator, and sends it to an ONERR GOTO routine if one exists or otherwise prints the appropriate BASIC.SYSTEM error message (or AppleSoft message, I guess). PRINTERR is vectored through $BE0C. It takes an error code in the A register and prints the appropriate error message; it does not call ONERR GOTO routines if they exist. -- ============================================================================ Matt Deatherage, Apple Computer, Inc. | "The opinions represented here are Developer Technical Support, Apple II | not necessarily those of Apple Group. Personal mail only, please. | Computer, Inc. Remember that." ============================================================================