6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 12:58 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Tue Jun 05, 2012 3:34 pm 
Offline
User avatar

Joined: Mon Apr 02, 2012 8:34 pm
Posts: 9
Location: Ottawa, Ontario, Canada
Is anyone familiar with how to save and load EhBASIC programs? It's not clear to me what range of memory needs to be saved and restored.

I'm working on integrating the CFFA1 flash memory card with EhBASIC on Apple 1/Replica 1 systems. It's further complicated by the fact that the CFFA1 firmware uses a lot of locations in page zero that are also used by EhBASIC so they need to be correctly saved and restored.

Any pointers would be appreciated.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 05, 2012 3:55 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
I did this on my SBC's. If you download this zip file:

http://sbc.rictor.org/download/sbc2os.zip

And open the os_src.zip file, there is a basldsv.asm file.

The psave routine provided the start and end address that was used to allow the xmodem file transfer to save the file. This was done from the command line.

the pload routine assumes that the basic file was loaded, starting at the smem address. It then scans the entire program until it finds the end. it then updates EHBASIC's pointers and jumps into the LAB_1319 whre it does some house keeping and returns to the input mode.

Using these two routines, you can interface any file storage system to EHBASIC.

Hope that gets you started.

Daryl


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 05, 2012 4:04 pm 
Offline
User avatar

Joined: Mon Apr 02, 2012 8:34 pm
Posts: 9
Location: Ottawa, Ontario, Canada
Thanks, I'll take a look at that.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 05, 2012 6:42 pm 
Offline

Joined: Fri Aug 30, 2002 2:05 pm
Posts: 347
Location: UK
If you want to save the program as binary you should save (Smeml) to (Svarl)-1.

If you want to save the program as ASCII you should redirect the character output vector to write to your filesystem and then call LIST. Doing this can also allow you to specify line numbers or ranges as with LIST. The output vector should be restored and the file closed when LIST returns or an error is encountered.

To load a binary program start loading it at (Smeml) and set (Svarl) to the last address + 1 then call LAB_1477 to clear the variables and reset the execution pointer. An easy way to do the first part is by copying (Smeml) to (Svarl) and using (Svarl) as a post incremented save pointer. If there is a chance that the program has been relocated it's probably a good idea to rebuild the line pointer chain.

To load an ASCII program redirect the character input vector to read from your filesystem and return to the main interpreter loop. The input vector should be restored and the file closed when the file end is reached or an error is encountered.

I prefer ASCII format as it's far more portable, easier to manipulate and can include direct commands and comment lines that aren't saved to memory.

Lee.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 05, 2012 7:04 pm 
Offline
User avatar

Joined: Mon Apr 02, 2012 8:34 pm
Posts: 9
Location: Ottawa, Ontario, Canada
Thanks, this will be helpful too.

I was also thinking about using ASCII format, and may pursue that, but the CFFA1 APIs don't directly support reading and writing text files, so that would take a little more effort.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 06, 2012 12:57 pm 
Offline
User avatar

Joined: Mon Apr 02, 2012 8:34 pm
Posts: 9
Location: Ottawa, Ontario, Canada
I've got it working. Thanks again.

Is there an easy way to support a filename in the LOAD and save COMMANDs, and get access to that from my code? Right now I am prompting the user for it.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 06, 2012 5:10 pm 
Offline

Joined: Fri Aug 30, 2002 2:05 pm
Posts: 347
Location: UK
Quote:
Is there an easy way to support a filename in the LOAD and save COMMANDs

Call the evaluate following expression routine, LAB_EVEZ, and look for a string by testing if the data type flag, Dtypef, is negative. If it is the string descriptor is on the descriptor stack so don't forget to pop it off there by calling LAB_22B6 once you're done with it.

Lee.


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 23, 2021 3:01 pm 
Offline

Joined: Mon May 25, 2015 1:12 pm
Posts: 92
I just thought I'd pop by to say thank you for this post and Daryl for his code here. I didn't realise I'd be needing to update any pointers upon loading BASIC code until things went sideways :oops: but once again, it's the brains trust to the rescue. :D


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 16 guests


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: