6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 5:48 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: CBM/PET BASIC
PostPosted: Wed Jan 02, 2008 3:53 pm 
Offline

Joined: Sun Aug 24, 2003 7:17 pm
Posts: 111
A rather detailed memory map of the CBM8032/PET ROM can be found in:

http://www.zimmers.net/anonftp/pub/cbm/ ... t/d/petdis

But what about RAM usage? RAM for BASIC use starts at $0400. Is there somewhere a good/detailed description of how BASIC uses RAM and especially where in RAM the different pointers to "START/END of code" and "START/END of variables" are situated.

I have developped a utility to move data back and forward between a PC and an 8032 using the User Port (Between PET ram and a PC ASCII-HEX file on harddisk) and I would like to use this interface to store BASIC programs on the PC harddisk. I.e. to do what the PET system does when the "load" and "save" commands for casset tape storage are typed! A rather tricky "hacking" deep into the CBM software!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Jan 02, 2008 5:13 pm 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
The zero-page pointer TXTTAB points to the start of the token area. For the Commodore 64, this is $0801, for example. BASIC 2.0 seems to put TXTTAB at location $002B.

Start of BASIC variables is pointed to by the VARTAB ($002D) pointer.

Start of Arrays is pointed to by the ARYTAB ($002F) pointer.

The END of arrays is pointed to by the STREND ($0031) pointer. Judging by the pointer's name, it also looks like the START of string space as well.

FRETOP is the last pointer at $0033, which is the end of the string space.

MEMSIZ ($0037) is the largest address usable by BASIC. In the case of the Commodore 64, this value is $A000.

Although these are for BASIC 2.0 on the Commodore 64, I doubt that their locations would change that much. If they do change, I'm sure they'll be kept adjacent, so some peeking around with a debugger ought to show patterns that suggest the proper base address for this "structure" of pointers.

Hope this helps.

SOURCE: http://www.ludd.luth.se/~watchman/fairl ... -memo.html


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Jan 04, 2008 1:39 pm 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 1043
Location: near Heidelberg, Germany
On the ROMs page of my petindex site (http://www.6502.org/users/andre/petindex/roms.html) you find links to the disassemblies of the PET ROMs as well as a memory map for the BASIC4.

The BASIC stores the text and variables in separate sections. First is the basic text, then come the basic variables as an array, then the basic arrays.
The strings on the other hand are stored from the end of the available memory down. When the string area reaches the array area a string garbage collection is done.

Code:
 TXTTAB   0028-0029   40-41   Pointer: Start of BASIC   Text
 VARTAB   002A-002B   42-43   Pointer: Start of BASIC   Variables
 ARYTAB   002C-002D   44-45   Pointer: Start of BASIC Arrays
 STREND   002E-002F   46-47   Pointer End of BASIC Arrays (+1)
 FRETOP   0030-0031   48-49   Pointer: Bottom of String Storage
 FRESPC   0032-0033   50-51   Utility String Pointer
 MEMSIZ   0034-0035   52-53   Pointer: Highest Address Used by BASIC


BTW: In this (German) article http://www.heise.de/newsticker/meldung/61292/ about Microsoft's birthday there is a link to a scan of a document describing the original MS Basic storage layout, by Bill Gates. You will recognize what you see :)

Concerning your "Loading" or "Saving" PET programs on the PC. BASIC only stores the basic text, i.e. TXTTAB-VARTAB. All variables are created on runtime.

After loading the BASIC recalculates the line links between the basic lines ("pointer to next line" in B.Gates description). At least it does for the C64, not sure about the PET.

Not sure what exactly you want to achieve.

André


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Jan 06, 2008 4:01 am 
Offline

Joined: Sat Jan 04, 2003 10:03 pm
Posts: 1706
fachat wrote:
BTW: In this (German) article http://www.heise.de/newsticker/meldung/61292/ about Microsoft's birthday there is a link to a scan of a document describing the original MS Basic storage layout, by Bill Gates. You will recognize what you see :)


Fascinating! Thanks for the link.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 20 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:  
cron