Jump to content

Photo

Basic++, Os++ and a couple of updates

Basic Atari++ EmulationBasic Os Emulation

3 replies to this topic

#1 thorfdbg OFFLINE  

thorfdbg

    Dragonstomper

  • 729 posts

Posted Sat Mar 18, 2017 7:36 AM

Hi folks,

 

here's a small update to the Atari++ emulator in the form of a new operating system and (two) new basic interpreters. A new compiled version of the emulator itself with the new versions build in will follow:

 

Attached File  basic++.zip   53.41KB   44 downloads

 

I'm providing it here so you can play with it until I find the time to rebild the emulator itself.

 

The operating system fixes one rather nasty bug in the editor handler that would have overwritten some memory when disabling the cursor (ough). That's the Os++ ROM dump in the ZIP file above. It's a 16K ROM for the XL machine.

 

Basic++ is present in two versions, each of which assembled in three variants. The variant without a file extension is a ROM dump, to be used for the emulator. Then there are two self-loading binaries per version. The versions without "a0" in the file name load into the lower memory region and keep the traditional cart space starting at $a000 free. This minimizes the RAM footprint, but causes some compatibility issues with Basic files that expect the ROM at $a000. This is what the "_a0" versions are for. They require about 1K additional memory, but run in the traditional cartridge area. Clearly, the ROM-dump is also for this area, but does not require additional RAM.

 

So what's new?

 

In release 1.07, I streamlined the interpreter a little bit further, especially "READ" got a little bit faster and shorter, providing a small advantage over the previous revision.

 

Release 1.08 is quite experimental, and I'm not sure whether I will keep the changes - so I let you try. The advantage is that it eliminiates one of the "hot spots" of Atari basic, namely the line number lookup. This was a linear search through a list, with a minor optimization to start from the current line if the target line number is larger than the current line. In 1.08, I'm trying the same trick as in Turbo Basic where I keep a "hash list" of lines of 128 entries, one entry per 256 possible line numbers. This makes GOTO and GOSUB quite noticably faster. Whether this is a substantial improvement depends on the program. Programs with many GOSUBs or GOTOs like the ABC basic compiler profit a lot. Linear programs or programs with FOR-NEXT loops do not profit (FOR-NEXT is already optimized).

 

Unfortunately, the hash list requires 256 bytes additional RAM, and more ROM space, so the title had to go.

 

Hence, please try and let me know how it goes.

 

Greetings, Thomas



#2 777ismyname OFFLINE  

777ismyname

    Star Raider

  • 51 posts

Posted Sat Mar 18, 2017 9:39 AM

Thank you, thorfdbg!



#3 JamesD OFFLINE  

JamesD

    Quadrunner

  • 7,216 posts

Posted Sat Mar 18, 2017 9:47 AM

Hi folks,

...

Release 1.08 is quite experimental, and I'm not sure whether I will keep the changes - so I let you try. The advantage is that it eliminiates one of the "hot spots" of Atari basic, namely the line number lookup. This was a linear search through a list, with a minor optimization to start from the current line if the target line number is larger than the current line. In 1.08, I'm trying the same trick as in Turbo Basic where I keep a "hash list" of lines of 128 entries, one entry per 256 possible line numbers. This makes GOTO and GOSUB quite noticably faster. Whether this is a substantial improvement depends on the program. Programs with many GOSUBs or GOTOs like the ABC basic compiler profit a lot. Linear programs or programs with FOR-NEXT loops do not profit (FOR-NEXT is already optimized).

 

Unfortunately, the hash list requires 256 bytes additional RAM, and more ROM space, so the title had to go.

 

Hence, please try and let me know how it goes.

 

Greetings, Thomas

I thought about using an LFU line number cache to speed up another interpreter.
I'm not sure it would be as fast as a hash but it doesn't require as much RAM to work.
 



#4 thorfdbg OFFLINE  

thorfdbg

    Dragonstomper

  • Topic Starter
  • 729 posts

Posted Thu Apr 20, 2017 1:09 PM

Hi folks,

 

two new updates:. Attached File  basic++1_08.zip   96.4KB   18 downloadsAttached File  basic++1_08f.zip   97.02KB   16 downloads

 

The first is the 1.08 "regular" version. I still found a chance to streamline the string copy/string assignment and hence shape off a couple of bytes. This allowed to include again a (albeit shortened) title in the 1.08F version. This is the somewhat more experimental version that speeds up GOTO and GOSUB statements by using a line number hash table.

 

The trick is exactly the same as in TurboBasic: The basic interpreter reserves additional 256 bytes (here between the variable table and the execution stack) and places in the hash table entry n the address of the lowest line number larger or equal to 256*n. This minimizes the search time for GOTO, GOSUB, RESTORE and READ.

 

It usually does not make that much of a difference as FOR-NEXT already keeps absolute addresses in addition to line numbers, and GOSUB also pushes the line address in addition to the line number on the stack, so even the regular 1.08 version is faster than Atari Basic.

 

As far as the speedups are concerned, the only additional thing TurboBasic has are unrolled and optimized replacement functions of the math pack. There is not enough room in the original Os, so Os++ only optimizes some of them, though no changes there this time.

 

1.08F still requires some testing, I haven't found any bugs so far.

                                                                                                                    
 







Also tagged with one or more of these keywords: Basic, Atari++, EmulationBasic, Os, Emulation

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users