davidbrierley@lynx.northeastern.edu (10/04/89)
The _Applesoft BASIC Programmer's Reference Manual_ says on page 15: You can use the reset vector to make the program continue as if nothing had happened [after pres- sing reset], branch to some other portion of the program, or do whatever you choose...see your computer's reference manual for details. Could anyone tell me how to deactivate the reset key (i.e. causing the program to resume when it is interrupted by reset) and to cause a branch to another part of a program when reset is pressed. I am particularly interested in techniques that do these things by using POKEs or short ML routines. Thank you in advance. David R. Brierley davidbrierley@lynx.northeastern.edu
stephens@latcs1.oz (Philip J. Stephens) (10/04/89)
In article <memo.170411@lynx.northeastern.edu>, davidbrierley@lynx.northeastern.edu writes: > > Could anyone tell me how to deactivate the reset key (i.e. > causing the program to resume when it is interrupted by reset) and > to cause a branch to another part of a program when reset is pressed. > I am particularly interested in techniques that do these things by > using POKEs or short ML routines. Thank you in advance. > > David R. Brierley > davidbrierley@lynx.northeastern.edu The reset key can never be "deactivated". It always causes a jump to a machine language program whose address is stored in $3F2 & $3F3. When you press RESET during the running of an Applesoft program, you will be interrupting the execution of the current statement. Hence the best you could do is to write a ML routine (called when RESET is hit) to re-run the program starting at the statement that was interrupted. However, there are many, many addresses in zero page ($0000 to $00FF) that Applesoft requires to run a program. If any of these locations loses its integrity due to RESET terminating the executing of a statement halfway through, then chances are high that the program will crash some time after resuming. The best you could do is restart the program from the very beginning, forcing Applesoft to re-initialise the critial zero page addresses. The same problem applies to jumping to another line in the program. Someone else may prove me wrong, but I believe that the statement made in the Applesoft BASIC reference manual is _WRONG_. You cannot achieve what it says you can do without possibly crashing the Applesoft interpretor. [As an aside, the only foolproof technique would be if on a RESET the address of the program counter in the 6502 was preserved on the stack. You could then jump back to the next instruction in the Applesoft interpretor, and all would be fine. However, the 6502 does no such thing on receiving a reset signal, so this is just a dream.] +-----------------------------------------------+ | Philip J. Stephens | | Computer Science III, LaTrobe Uni., Melbourne | | ACSnet: stephens@latcs1.oz | +-----------------------------------------------+
greyelf@wpi.wpi.edu (Michael J Pender) (10/07/89)
In article <6483@latcs1.oz> stephens@latcs1.oz (Philip J. Stephens) writes: >In article <memo.170411@lynx.northeastern.edu>, davidbrierley@lynx.northeastern.edu writes: >> >> Could anyone tell me how to deactivate the reset key (i.e. >> causing the program to resume when it is interrupted by reset) and >> to cause a branch to another part of a program when reset is pressed. >> >> David R. Brierley >> davidbrierley@lynx.northeastern.edu > >Applesoft BASIC reference manual is _WRONG_. You cannot achieve what it says >you can do without possibly crashing the Applesoft interpretor. > >+-----------------------------------------------+ >| Philip J. Stephens | >| Computer Science III, LaTrobe Uni., Melbourne | >| ACSnet: stephens@latcs1.oz | >+-----------------------------------------------+ *ahem* I beg to differ. Under prodos the reset key will make its jump to a machine language routine, yes, but an article in a past episode of Nibble showed a way to have the machine generate an Applesoft error code, and return to the BASIC interpreter. If a person had set error trapping, ie. used an ONERR GOTO statement, they can redirect the control where they will. I suppose I should go and try to dig the article up now... --- Michael J Pender Jr Box 1942 c/o W.P.I. I wrote SHELL and Daemon, greyelf@wpi.bitnet 100 Institute Rd. send bug reports, suggestions, greyelf@wpi.wpi.edu Worcester, Ma 01609 checks to me.
cc@xroads.UUCP (Dan McGuirk) (10/07/89)
In article <4561@wpi.wpi.edu> greyelf@wpi.wpi.edu (Michael J. Pender) writes: >In article <6483@latcs1.oz> stephens@latcs1.oz (Philip J. Stephens) writes: > >>Applesoft BASIC reference manual is _WRONG_. You cannot achieve what it >>says you can do without possibly crashing the Applesoft interpretor. > >*ahem* I beg to differ. Under prodos the reset key will make its >jump to a machine language routine, yes, but an article in a past >episode of Nibble showed a way to have the machine generate an >Applesoft error code, and return to the BASIC interpreter. Yes, of course you can do that. I believe that Philip Stephens even mentioned that in his article. But, if you read the rest of the article, what he was saying that you CAN'T do is resume execution of the program from the same place where it left off after a reset. It is possible to start the program over, or have it abort with an error, but never for it to resume in the same place.. -- \ / C r o s s r o a d s C o m m u n i c a t i o n s /\ (602) 941-2005 300|1200 Baud 24 hrs/day / \ hplabs!hp-sdd!crash!xroads!cc
jearls@polyslo.CalPoly.EDU ( Stupid ) (10/09/89)
cc@xroads.UUCP (Dan McGuirk) says: > >Yes, of course you can do that. I believe that Philip Stephens even >mentioned that in his article. But, if you read the rest of the article, >what he was saying that you CAN'T do is resume execution of the program from >the same place where it left off after a reset. It is possible to start the >program over, or have it abort with an error, but never for it to resume in >the same place.. How about creating an error then 'RESUME'ing from it? I admit, I've never gotten RESUME to work the way I wanted it to in an actual error condition but this might work... >-- >\ / C r o s s r o a d s C o m m u n i c a t i o n s > /\ (602) 941-2005 300|1200 Baud 24 hrs/day >/ \ hplabs!hp-sdd!crash!xroads!cc - John -- _______________________________________________________________________________ Stupid@Idiots.Anonymous.Com | There's an explanation for everything. Tis a pity jearls@polyslo.CalPoly.EDU | that many of those explanations make no sense. earlsj@AFAL-EDWARDS.AF.MIL | - The Teachings of Ebenezum, volume LXIX
dlyons@Apple.COM (David Lyons) (10/09/89)
In article <848@xroads.UUCP> cc@xroads.UUCP (Dan McGuirk) writes: >[...] >Yes, of course you can do that. I believe that Philip Stephens even >mentioned that in his article. But, if you read the rest of the article, >what he was saying that you CAN'T do is resume execution of the program from >the same place where it left off after a reset. It is possible to start the >program over, or have it abort with an error, but never for it to resume in >the same place.. Starting the Applesoft over with the equivalent of "RUN" from a reset-trapping routine will almost always work (because RUN wipes out the variable table, which could have been in an unusable state because an operation on it was interrupted). If ProDOS was in the middle of doing something when Reset was hit, you could still easily toast yourself. -- --Dave Lyons, Apple Computer, Inc. | DAL Systems AppleLink--Apple Edition: DAVE.LYONS | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.