Loading ...
Sorry, an error occurred while loading the content.

Re: How does Altair basic 3.2 and 4.0 store programs in memory

Expand Messages
  • corey986
    Mike, You seem to be enjoying the research. If you want to do 4.0 4k, then I think you ve covered just about all the versions needed. I m actually quite
    Message 1 of 12 , Jul 16, 2013
    • 0 Attachment
      Mike,

      You seem to be enjoying the research. If you want to do 4.0 4k, then I think you've covered just about all the versions needed. I'm actually quite amazed no one has done this in the past. This way you could load/save programs using a hacked modem or cassette interface or in my case a paper tape on a different port than your terminal (well 8k solved that issue with cload and csave, but still...).

      Cheers,
      Corey

      --- In altaircomputerclub@yahoogroups.com, "deramp5113" <deramp5113@...> wrote:
      >
      > Corey,
      >
      > The following information is specific to 4K BASIC v3.2:
      >
      > Location 0165h contains a pointer to the start of the program in memory. Location 0167h contains a pointer to the start of variable storage in memory. Variable storage always starts immediately after the last program byte, so 0167h can be used as a pointer to the end of the program + 1.
      >
      > To save a program, I send three sync bytes (I used D2h because that's what CSAVE used) followed by the two byte length of the program to be saved where: length = (0167h) - (0165h). I then transmit the program bytes. After all bytes have been sent, the code jumps to address zero which returns to BASIC which then displays "OK"
      >
      > To load a program, I wait for the three sync bytes in a row, read the two length bytes, then read the program bytes into memory starting at the address specified in 0165h. After the program is loaded, I write the address of the last program byte + 1 into 0167h, then jump to address zero.
      >
      > 4K BASIC v4.0 is different. I'll dig into that more if you want to support both versions.
      >
      > Mike
      >
      >
      > --- In altaircomputerclub@yahoogroups.com, corey986 <no_reply@> wrote:
      > >
      > >
      > >
      > >
      > >
      > > Mike,
      > >
      > > You beat me too it. I was traveling yesterday. So you simply save the whole ram space or did you figure out how to determine where the program starts and then only "save" until you see three consecutive NULLs.
      > >
      > > As for your code, please email it to me I'd like to take a look, I was thinking of using the sense switches for the port/card type so that you can either save/load to a PC on serial or to the punch on PIO.
      > >
      > > Cheers,
      > > Corey986
      > >
      > > --- In altaircomputerclub@yahoogroups.com, "deramp5113" <deramp5113@> wrote:
      > > >
      > > > Well, I couldn't leave this alone -- it sounded like too much fun to code up! I stuck two short routines in PROM, one to save a BASIC program amd one to load a BASIC program (4K v3.2). The direct memory image is saved and restored with the two routines. After the load or save completes, the routines jump to zero which puts you right back in BASIC with an "OK" prompt. Works great at 9600 baud with no delays.
      > > >
      > > > Mike
      > > >
      > > > --- In altaircomputerclub@yahoogroups.com, "deramp5113" <deramp5113@> wrote:
      > > > >
      > > > > Corey,
      > > > >
      > > > > I think I have this figured out for 4K BASIC 3.2. If you want, I could write a "program load" and "program save" routine at some easy to enter EPROM addresses (let me know what addresses you want). Also, let me know what port type/address the paper tape reader is connected to. Or, I can tell you what I think will work and you can write the code if you'd rather!
      > > > >
      > > > > Mike
      > > > >
      > > > >
      > > > > --- In altaircomputerclub@yahoogroups.com, corey986 <no_reply@> wrote:
      > > > > >
      > > > > > I am trying to figure out the best way to save and load programs from paper tape.
      > > > > >
      > > > > > I know I could redirect a list command to the punch and modifying the number of nulls at the end of a line when read in a paper tape, but was thinking the best way is to simply backup the area of memory that stores the program and reload the area using a binary loader. This would prevent issues of basic not being able to keep up with my high speed reader.
      > > > > >
      > > > > > Where can I figure out where basic is storing the program for each version/size of basic and how long is that area. Also is basic storing symbols or the actually "text" code?
      > > > > >
      > > > > > Thanks,
      > > > > > Corey
      > > > > >
      > > > >
      > > >
      > >
      >
    • deramp5113
      A stand alone routine to save/load for 4K v3.2 is not difficult. A stand alone routine save/load for 4K v4.0 is not difficult. However, this means choosing the
      Message 2 of 12 , Jul 17, 2013
      • 0 Attachment
        A stand alone routine to save/load for 4K v3.2 is not difficult. A stand alone routine save/load for 4K v4.0 is not difficult. However, this means choosing the proper save/load routine from PROM (3.2 or 4.0) and also keeping separate versions of every program for v3.2 and v4.0. Not a great solution.

        Unless v4.0 added or changed keyword code assignments, then a single routine to automatically handle all combinations is possible. However, it becomes a more complicated program.

        The program must first determine if it is running under 3.2 or 4.0. Second, the save routine would need to modify the linked-list address chain to be relative addresses instead of fixed addresses as the program is written to the save device. Conversely, when the program is read back in, the relative linked list must be restored to a fixed address linked list as the program is read back into memory. Finally, the program has to handle the slight difference in the way the first line in a program is stored for 3.2 vs 4.0.

        Mike




        --- In altaircomputerclub@yahoogroups.com, "deramp5113" <deramp5113@...> wrote:
        >
        > Corey,
        >
        > I think I have this figured out for 4K BASIC 3.2. If you want, I could write a "program load" and "program save" routine at some easy to enter EPROM addresses (let me know what addresses you want). Also, let me know what port type/address the paper tape reader is connected to. Or, I can tell you what I think will work and you can write the code if you'd rather!
        >
        > Mike
        >
        >
        > --- In altaircomputerclub@yahoogroups.com, corey986 <no_reply@> wrote:
        > >
        > > I am trying to figure out the best way to save and load programs from paper tape.
        > >
        > > I know I could redirect a list command to the punch and modifying the number of nulls at the end of a line when read in a paper tape, but was thinking the best way is to simply backup the area of memory that stores the program and reload the area using a binary loader. This would prevent issues of basic not being able to keep up with my high speed reader.
        > >
        > > Where can I figure out where basic is storing the program for each version/size of basic and how long is that area. Also is basic storing symbols or the actually "text" code?
        > >
        > > Thanks,
        > > Corey
        > >
        >
      • deramp5113
        Corey (or anyone else who cares!), I ve written a robust version of a program you can run from EPROM to save/load programs from 4K BASIC v3.2 or v4.0 in binary
        Message 3 of 12 , Jul 19, 2013
        • 0 Attachment
          Corey (or anyone else who cares!),

          I've written a robust version of a program you can run from EPROM to save/load programs from 4K BASIC v3.2 or v4.0 in binary format. BASIC can keep up with program loads at a full 9600 baud (960cps) without delays. After a load or save is performed, BASIC is given back control and its "OK" prompt is displayed.

          The same routine is run for either 3.2 or 4.0 -- the program figures out which version of BASIC is in memory. The program also figures out whether you want to do a save or a restore based on whether there is a program in memory (do a save), or no program in memory (do a load).

          During a save, the program converts all absolute addresses into relative addresses so that absolute addresses can be regenerated when loading the program. This is necessary since the starting address of a program is not the same between v3.2 and v4.0, and even within the same BASIC version, the program load address can change based on how you answer the "Want SIN" initialization questions.

          Mike




          --- In altaircomputerclub@yahoogroups.com, "deramp5113" <deramp5113@...> wrote:
          >
          > A stand alone routine to save/load for 4K v3.2 is not difficult. A stand alone routine save/load for 4K v4.0 is not difficult. However, this means choosing the proper save/load routine from PROM (3.2 or 4.0) and also keeping separate versions of every program for v3.2 and v4.0. Not a great solution.
          >
          > Unless v4.0 added or changed keyword code assignments, then a single routine to automatically handle all combinations is possible. However, it becomes a more complicated program.
          >
          > The program must first determine if it is running under 3.2 or 4.0. Second, the save routine would need to modify the linked-list address chain to be relative addresses instead of fixed addresses as the program is written to the save device. Conversely, when the program is read back in, the relative linked list must be restored to a fixed address linked list as the program is read back into memory. Finally, the program has to handle the slight difference in the way the first line in a program is stored for 3.2 vs 4.0.
          >
          > Mike
          >
          >
          >
          >
          > --- In altaircomputerclub@yahoogroups.com, "deramp5113" <deramp5113@> wrote:
          > >
          > > Corey,
          > >
          > > I think I have this figured out for 4K BASIC 3.2. If you want, I could write a "program load" and "program save" routine at some easy to enter EPROM addresses (let me know what addresses you want). Also, let me know what port type/address the paper tape reader is connected to. Or, I can tell you what I think will work and you can write the code if you'd rather!
          > >
          > > Mike
          > >
          > >
          > > --- In altaircomputerclub@yahoogroups.com, corey986 <no_reply@> wrote:
          > > >
          > > > I am trying to figure out the best way to save and load programs from paper tape.
          > > >
          > > > I know I could redirect a list command to the punch and modifying the number of nulls at the end of a line when read in a paper tape, but was thinking the best way is to simply backup the area of memory that stores the program and reload the area using a binary loader. This would prevent issues of basic not being able to keep up with my high speed reader.
          > > >
          > > > Where can I figure out where basic is storing the program for each version/size of basic and how long is that area. Also is basic storing symbols or the actually "text" code?
          > > >
          > > > Thanks,
          > > > Corey
          > > >
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.