jchan@kim.Berkeley.EDU (Jeffery Chan) (10/20/86)
][ Is there anyone out there who can explain what's happening on my ][e? Here's the contents of foo1. 800:20 8E FD JSR $FD8E {CROUT} 803:20 1B FD JSR $FD1B {KEYIN} 806:60 RTS Here's the contents of foo2. 800:20 1B FD JSR $FD1B {KEYIN} 803:60 RTS I've bsaved both files under 3.3 DOS (I think this could be the cause of the problem) and I BRUN both programs (from applesoft). The program foo2 returns to the "]" prompt after pressing a key while foo1 just hangs there after I press a key. Both programs returns when I call them from applesoft and monitor (with CALL 2048 or 800G). One last note-- on the screen the programs looks like this: The "x" is the location where the prompt for the KEYIN appears: ]BRUN foo1 x {And the program hangs} ]BRUN foo2x ] {etc.} PLEASE *MAIL* REPLIES TO ME. This is in caps because the last time I said this some one went ahead and posted their answer anyways. I think this sounds appropriate: Chisholm's Third Law (a corollary): If you explain so clearly that nobody can misunderstood, somebody will. Jeff Chan jchan@kim.Berkeley.EDU Imangine this: Jan Hammer doing the incidential music for "Dr. Who".
dr@ski.UUCP (David Robins) (10/20/86)
In article <> jchan@kim.Berkeley.EDU.UUCP (Jeffery Chan) writes: >Is there anyone out there who can explain what's happening on my ][e? > >Here's the contents of foo1. >800:20 8E FD JSR $FD8E {CROUT} >803:20 1B FD JSR $FD1B {KEYIN} >806:60 RTS > >Here's the contents of foo2. >800:20 1B FD JSR $FD1B {KEYIN} >803:60 RTS > >I've bsaved both files under 3.3 DOS (I think this could >be the cause of the problem) and I BRUN both programs (from applesoft). >The program foo2 returns to the "]" prompt after pressing a key while >foo1 just hangs there after I press a key. > >Both programs returns when I call them from applesoft and monitor >(with CALL 2048 or 800G). > >One last note-- on the screen the programs looks like this: >The "x" is the location where the prompt for the KEYIN appears: > >]BRUN foo1 >x >{And the program hangs} > > >]BRUN foo2x >] >{etc.} . . > Jeff Chan > jchan@kim.Berkeley.EDU For an answer, I refer to the excellent "Apple Assembly Lines" newsletter. Starting in Jan, '86, there have been 4 articles about DOS 3.3 and BRUN. To paraphase the articles by Bob Sander-Cederlof, the problem is that DOS calls your program with a JMP, but htere is stilll a return address on the stack. BRUN installs the DOS I/O hooks in the input ans output vectors. When these hooks are installed, any character input or output will enter DOS first. Since we are still, in effect, inside DOS (because of the BRUN), we get into a loop. "If your program tries to do any character I/O through calls to $FDED (COUT) or $FD0C (RDKEY), any you start your program by BRUNning it from inside an Applesoft program, you will get DOS into a loop." Ending such a program with a JMP $3D0 (warm entry) would get you back into the Applesoft prompt ]. However, he says the best way is to BLOAD the program, and CALL it, which will not hang. (BLOAD foo1, and CALL 2048 (($800)). The August '86 issue had another way around the BRUN problem. Since the CALL statement must know the location of the BLOAD, it is less convenient than the BRUN command. Someone pointed out that you can BLOAD the program, and CALL 41876. This call is in the DOS BRUN processor, and works without having to specify the location of the BLOAD. Finally, in Sept. '86, Louis Pitz wrote a short assembly program that can issue DOS commands and not hang up. At the ned, it detects the presence or absence of the Applesoft prompt, and issues one of two returns appropriate to the situation, so it returns properly. -Dave -- ==================================================================== David Robins, M.D. Smith-Kettlewell Eye Research Foundation (previously known as: Smith-Kettlewell Institute of Visual Sciences) 2232 Webster St; San Francisco CA 94115 415/561-1705 (voice) {ihnp4,qantel,dual}!ptsfa!ski!dr The opinions expressed herein do not reflect the opinion of the Institute!