It is currently Mon Oct 20, 2014 4:48 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Jan 27, 2012 1:04 pm 
Offline
 Profile

Joined: Fri Nov 07, 2008 2:28 pm
Posts: 65
Hi,

I'm trying to load and save files using OSFILE (Incidentally is it $FFDD or $FFCE? - I'm using the former at the moment) but when an error occurs like "file not found" or "disk write protected" it will print the error message to the screen and crash my program - it prints "Bad Program" on the screen as well.

These are valid errors but if they occur I'd like to handle them myself and my program to keep control.

Any suggestions?

Thanks

PJ

P.S. The same thing happens using OSCLI.


Top
 
PostPosted: Fri Jan 27, 2012 1:37 pm 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 7:02 pm
Posts: 273
Trap BRKV (&202-203).


Top
 
PostPosted: Fri Jan 27, 2012 10:12 pm 
Offline
User avatar
 Profile

Joined: Mon Jan 07, 2008 6:46 pm
Posts: 380
Location: Málaga, Spain
Just to expand on that, the Beeb OS doesn't expect to resume the code which follows BRK instructions, so your BRK handler should end by JMPing to a fixed location afterwards, in the same spirit as ON ERROR GOTO in BASIC.

To avoid bad stack shenanigans, I'd suggest that the best trick is to remember the current stack pointer (TSX / STX storedsp), point the BRKV at your own handler (remembering its old contents) and call OSFILE.

Your BRK handler should print the error message (addresses &FD/&FE point at the error number followed by the zero-terminated error message), then exit by restoring the stack pointer you saved earlier and jumping to your error recovery code.


Top
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron