Jump to content
Larry

Some BASIC/Compiler Comparisons

Recommended Posts

I recently completed a significant revision to a series of BASIC programs that I have used to parse a time/date-ordered (very long) text file each month to produce an alphabetical list of movie titles. I end up with a lot less information, but it is in a format that I can quickly use to see if there are some movies I'm interested in watching that month.

 

With my revision, I ended up with just one BASIC program for several different interpreters and compilers. So comparisons are inevitable. Running this program, I ended up with the following times and program sizes -- and also a major question about the Turbo Basic Compiler. First, the times:

 

Atari BASIC...24:35 execution (13 DD sectors)

Basic XE...12:14 (no string arrays used)

TBXL....9:27

ABC Compiler...6:xx (Integer -- no seconds available)...27 DD sectors

TBXL Compiler...4:42...12 DD Sectors + 43 for THE runtime

MMG Basic Compiler... 3:xx (Integer -- no seconds available...27 DD sectors (runtime library appended)

 

Most of these times and program sizes (compiler versions) seem pretty logical. I was initially a bit surprised that the MMG compiler version was a bit quicker than the TBXL compiled version, but since TBXL provides floating point, that is likely a big part of the difference.

 

But that leads to a question. I have always heard that the TBXL compiler produces "machine code." Is that really true? Watching the compilers work, it leads me to question it. First, the TBXL compiler is incredibly fast, and *makes only one pass.* Second, the size of the runtime seems very large for a machine code compiler. Compare it to the MMG which does a 3-pass assembly of the source program, and has a very small runtime of (IIRC) typically about a thousand bytes -- similar to the ACTION! runtime. Maybe it's a hybrid of some type?

 

Anyone have some input? Maybe read the original German article or has some other insight?

 

-LARRY

  • Like 1

Share this post


Link to post
Share on other sites

I am pretty sure the TBXL compiler produces what is known as p-code, and then the supplied runtime utilizes it.

Share this post


Link to post
Share on other sites
MMG Basic Compiler... 3:xx (Integer -- no seconds available...27 DD sectors (runtime library appended)

I didn't know that this compiler added a runtime library. I thought it was only the ABC compiler that added a runtime.

Share this post


Link to post
Share on other sites

Ideally a compiler would generate a runtime containing only what's needed by each program with it packed and relocated.

 

A large or constant size runtime would be indication that it's not the case.

 

I've not really played about with compilers on/for Atari though, so can't much comment on what optimisations and innovations are out there.

 

For your timing purposes with integer-based languages, you could probably use the OS RTClock variables (dec. 20, 19, 18). Just plug zeroes in at the start, read them at the end and do the maths taking into consideration any limitations the integer maths imposes.

Share this post


Link to post
Share on other sites

Perhaps I should just say "Library" in the case of MMG. But it is equivalent to the library used by Action! As Rybags says, a "smart" compiler just uses what is needed from the pre-written routines available. Essentially macros, I'd say. All three of these compilers have some interesting features. The TBXL Compiler is by far the fastest in actually compiling a Basic program -- about like the Action! compiler. I would also say that it is the most flexible -- it will compile most programs without a lot of changes. ABC and MMG do very well, but you have to be mindful of their requirements. If you write a Basic program with those requirements in mind, no problem. If you pick up a pre-written program from someone else, then you will likely have to make quite a few changes to it in order to get a successful compile. MMG is unique in that it provides an optional assembly language file of your Basic program. That assembly file is occasionally quite useful.

 

@Rybags -- yes, that's how I get the times. But as written, I "do the math" and print the minutes and seconds. I need to print out the "jiffies" as-is.

 

-Larry

Share this post


Link to post
Share on other sites

I am pretty sure the TBXL compiler produces what is known as p-code, and then the supplied runtime utilizes it.

 

No, the TBXL compiler really creates machine code. However, in almost all cases, this machine code is just a sequence of "LDA/STA" with "JSR" that go into the runtime library. So it really *is* machine code, though in a sense a pretty high-level one.

Share this post


Link to post
Share on other sites

It's very much an indirect threaded approach, similar to early FORTH implementations. Action does this to some extent as well, with the standard functions.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...