[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Please help with BinSCII



Jeff Blakeney writes ...
> 
> On Wed, 28 Jun 2000 09:20:51 -0500, Rubywand <rubywand@swbell.net>
> wrote:
> 
 ....
> 
> >     Neither the POKE 216,0 (ONERR terminate) nor the CALL -3288 stack
> >cleanup are necessary here. The POKE 216,0 illustrates good practice; but,
> >the CALL -3288 is excessively pedantic in a short program with no subs.
> 
> The stack cleanup for subroutines in an Applesoft program is done with
> the POP command.  If you do a GOSUB, Applesoft puts the return address
> on the stack so that when you use the RETURN command it will know
> where to continue running the program.  POP removes that information
> from the stack.
> 
> When an ONERR GOTO statement is executed it puts information on the
> stack so that Applesoft will know where to go back to if you use the
> RESUME command.  If you don't do the CALL -3288, that info doesn't
> come off the stack so your program will end with a stack imbalance.
> This can cause your system to crash for no apparent reason some time
> in the future unless you reboot your machine after having run your
> program.
> 
> I just tested this and every time you run a program where an ONERR
> GOTO gets executed, the stack pointer is moved by two bytes.  You NEED
> to either put the CALL -3288 in your program to clean up the stack or
> you need to tell users to reboot the system or have your program do it
> automatically when the program finishes to avoid possible problems.
>
 ....

     It sounds like you are saying that, after running a program using an
ONERR GOTO without doing corresponding stack cleanup CALLs, you will end up
at the BASIC prompt with top-of-stack being positioned lower than usual. How
did you determine that this happens?

 ....


> 100 ONERR GOTO 210
> 110 D$ = CHR$(4)
> 120 PRINT D$;"OPEN BINSCII.EXE"
> 130 PRINT D$;"OPEN BINSCIIX"
> 140 PRINT D$;"READ BINSCII.EXE"
> 150 LC$ = C$:GET C$
> 160 IF C$ = CHR$(10) AND LC$ = CHR$(13) THEN 150
> 170 PRINT D$;"WRITE BINSCIIX"
> 180 IF C$ = CHR$(10) THEN PRINT CHR$(13);: GOTO 140
> 190 PRINT C$;
> 200 GOTO 140
> 210 POKE 216,0: CALL -3288
> 220 PRINT D$;"CLOSE"
> 230 END
> 
 ....
> 
> I'm pretty sure this version will work okay.  :-)
>
 ....

     Looks like it should.

     A mod which would improve speed is to accumulate the chars in a string,
say S$, and do a PRINT to BINSCIIX (of S$) only when at end of line.



Rubywand