Apple BASIC Compiler

8 replies [Last post]
Offline
Joined: Jul 5 2007
Posts: 4

Hello,

I just joined here today (and just built an Apple1 Replica1 in this weekend, 4 days ago).

I have a question about the BASIC. Is there any compiler for Apple BASIC? If not, I will consider creating it...

Thank you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Offline
Joined: Mar 20 2005
Posts: 77
Forgive me if I don't understand...

... But the Replica 1 already has BASIC (as it existed on the Apple 1) at E000R. It also has a reportably nice machine language compiler. Detail are available on the manual CD Rom Vince included with you kit.

.... Or do I owe you an apology?

Offline
Joined: Jun 23 2005
Posts: 48
It has a BASIC interpreter, n

It has a BASIC interpreter, not a compiler. I presume this is what he means.

mmphosis's picture
Offline
Joined: Aug 18 2005
Posts: 316
re: Apple BASIC Compiler

> Is there any compiler for Apple BASIC?

I don't know.

In your "consideration" of creating an Apple BASIC Compiler, if one does not already exist, I have questions...

What language will you use to create the Apple BASIC Compiler? Will you use Apple BASIC to create the compiler? Once the Apple BASIC Compiler is created will you compile the compiler using the Apple BASIC Compiler? And, then will you then recompile the original compiler using the compiled compiler? And, what type of code will the code generator generate? Will there be a "runtime" included with the executable? Will the executable objects be larger than the original tokenized programs interpreted by Apple BASIC? Will the code be any faster? Will the code appear to run any faster given that the character output on an Apple-1 is usually limited to 60 characters per second?

Offline
Joined: Jul 5 2007
Posts: 4
Exactly

Thank you, Kallikak.

Yes, what I want to make is compiler. You can create any BASIC code with the ordinally Apple BASIC, debug it by interpreter, and finally compile it. The compiled code runs 100 times faster than the interpreter except for video output.
The premitive version has been written in PHP (as a web apprecation) and compiles PRINT, END, and RETURN statements so far. After completing this web app version, I will convert it to Apple BASIC version (I mean BASIC compiler written in BASIC). don't know how many months I need this...

Offline
Joined: Jul 5 2007
Posts: 4
Re: re: Apple BASIC Compiler

mmphosis wrote:

What language will you use to create the Apple BASIC Compiler? Will you use Apple BASIC to create the compiler? Once the Apple BASIC Compiler is created will you compile the compiler using the Apple BASIC Compiler? And, then will you then recompile the original compiler using the compiled compiler? And, what type of code will the code generator generate? Will there be a "runtime" included with the executable? Will the executable objects be larger than the original tokenized programs interpreted by Apple BASIC? Will the code be any faster? Will the code appear to run any faster given that the character output on an Apple-1 is usually limited to 60 characters per second?

The compiler can be written in BASIC, and at the first time it can compile itself by BASIC interpreter. So, probably one hour will be required for the first compile. But, once the compiler itself will be compiled, it compile another code faster. (But I will use PHP in the beginning, because it's very hard to use Apple BASIC for such large programs.)

I won't probably use any runtime for the created code.

The executable objects will be probably larger than the source code, but 100 times faster than interpreter, I think.

Unfortunatelly, the speed for outputing characters cannot be faster. There is no way to change the speed by software. You need to change the hardware to do this.

mmphosis's picture
Offline
Joined: Aug 18 2005
Posts: 316
PHP, PusH processor status "P" register

You are welcome, Goddard. Wink

I appliciate you making a web apprecation such as this.

Offline
Joined: Jul 5 2007
Posts: 4
Demo site

Well, it may be difficult to imagine how the web application compiler works. I just created a demo site of web application version of BASIC compiler. Note that it now just works for PRINT "XXXXX", and RETURN statements. Please use RETURN instead of END if you want to go back to BASIC after executing it.

Use Pom1.1 (thanks Verhill and Ken!), enter "E000R" and make following BASIC program:

10 PRINT "HELLO WORLD!"
20 RETURN

Then save the memory from 0000 to 0FFF as text file, go to:

http://kandk.cafe.coocan.jp/blog/apple1/compiler/

and upload the saved text file. You will get the memory dump containg compiled code. Return to Pom1.1 and load the compiled code, then execute the machine code by entering "CALL 4096". You will see "HELLO WORLD!". I guess we can do the same thing by Replica1 using serial interface.