I've just converted a utility from BASIC to 6502 assembly language and it runs fine except for one thing: if I *RUN it instead of *LOADing it then CALLing the code, it produces a Syntax Error when it exits.
I'm sure there's something I'm supposed to do before I return to BASIC or is my use of zero page addresses &70-&75 making BASIC unhappy?
Syntax Error after *RUN
Re: Syntax Error after *RUN
There should be no practical difference David and using &70-&75 is fine. I suspect you're doing something subtly wrong in your code such as, are you perhaps (example only) mistakenly using &0700 onwards (instead of &0070) which tends to be the keyboard input buffer? I think you are leaving some residual character(s) somewhere like that such that when you *RUN and return, BASIC subsequently tries to parse the debris.
- Rich Talbot-Watkins
- Posts: 1719
- Joined: Thu Jan 13, 2005 5:20 pm
- Location: Palma, Mallorca
- Contact:
Re: Syntax Error after *RUN
Is it on the Electron? Something to do with this perhaps?
Re: Syntax Error after *RUN
Ha! Your memory is way better than mine Rich! 

Re: Syntax Error after *RUN
I was thinking about the other thread because this program also uses OSFILE and I'd forgotten that it modifies the file block, so that was another problem-within-a-problem. But it looks like the same issue with loading from TAPE or ROM immediately after a reset. Loading another file first sidesteps the problem. Thanks for the reminder! 

- Rich Talbot-Watkins
- Posts: 1719
- Joined: Thu Jan 13, 2005 5:20 pm
- Location: Palma, Mallorca
- Contact:
Re: Syntax Error after *RUN
Still not really clear what this problem is, or whether it's an Electron only thing or not. But I've never ever been bitten by it myself!
Re: Syntax Error after *RUN
FWIW it may have something to do with a bug in *RUN under CFS/RFS.
In BBC OS 1.20 and Electron OS 1.00 after *RUN loads the file it tries to update the OSFILE block with the length of the file, except that *RUN did not set the address (stored at &C8) of the OSFILE block. If !&C8 points into the code image some four bytes of it may be corrupted. Try:
which has *RUN safely copy the computed file length over itself. (Credit to John Kortink for finding this bug.)
In BBC OS 1.20 and Electron OS 1.00 after *RUN loads the file it tries to update the OSFILE block with the length of the file, except that *RUN did not set the address (stored at &C8) of the OSFILE block. If !&C8 points into the code image some four bytes of it may be corrupted. Try:
Code: Select all
*TAPE
!&C8=&C2
*RUN
Re: Syntax Error after *RUN
Thanks for the tip, regregex, and welcome back!