Permalink
Browse files

Update to match blog posting.

  • Loading branch information...
1 parent f44eaec commit a900f211bd1ff1cad70d2b4b3f323f0d6bb03293 @jefftranter committed Apr 9, 2012
Showing with 76 additions and 64 deletions.
  1. +76 −64 asm/msbasic/NOTES.txt
View
@@ -1,59 +1,54 @@
-At [http://www.pagetable.com/?p=46 there is source code that can
-generate the first eight known versions of Microsoft BASIC for the
-6502. It was generated by disassembling the ROMs, organizing and
-commenting the code, and figuring out the differences between the
-various versions.
+At http://www.pagetable.com/?p=46 is source code that can generate
+the first eight known versions of Microsoft BASIC for the 6502. It was
+generated by disassembling the ROMs, organizing and commenting the
+code, and figuring out the differences between the various versions.
-I made some patches so I can run it on a Replica 1. You need the
-assembler from the CC65 tools http://www.cc65.org/ to build it.
+I made some patches so I can run it on a Replica 1. You need the CC65
+assembler from http://www.cc65.org to build it.
-If you want a more complete version of Apple BASIC, see Applesoft Lite
-at http://cowgod.org/replica1/applesoft/
+If you want a more complete version of Apple BASIC, see Applesoft
+Lite, http://cowgod.org/replica1/applesoft/
I chose to use Ohio Scientific (OSI) BASIC since it has the fewest
external dependencies. It also happens to be the BASIC I used on my
first computer.
All the code is at
-https://github.com/jefftranter/6502/tree/master/asm/msbasic. To get
+http://github.com/jefftranter/6502/tree/master/asm/msbasic . To get
OSI BASIC running on the Replica 1, extract the source code, apply the
-patch REPLICA1-PATCHES-FOR-OSI.patch, and build it.
+patch REPLICA1-PATCHES-FOR-OSI.patch, and build it, e.g. on a Linux
+system:
-e.g.
-
-mkdir msbasic
-cd msbasic
-unzip ../msbasic.zip
-patch -p1 < ../REPLICA1-PATCHES-FOR-OSI.patch
-./make.sh
+ mkdir msbasic
+ cd msbasic
+ unzip ../msbasic.zip
+ patch -p1 <../REPLICA1-PATCHES-FOR-OSI.patch
+ ./make.sh
The patch defaults to linking at address $A000, the address of an
-EEPROM on the Replica 1 Multi I/O board. It builds the "small"
-version of BASIC which fits in the 8K EEPROM.
+EEPROM on the Replica 1 Multi I/O board. It builds the "small" version
+of BASIC which fits in the 8K EEPROM.
The start address is $BD0D which is determined by looking at
msbasic.lst and seeing that the address of COLD_START is $0007 from
the start of the INIT section, and adding it to the address of the
INIT section in osi.map, which is $BD06 ($BD06 + $0007 = $BD0D).
To use the patched make.sh file to generate the Woz monitor file to
-download to the Replica 1 you'll need my bintomon program available
-from https://github.com/jefftranter/6502/tree/master/util/bintomon
-
-Upload the file tmp/osi.mon to the Replica 1. Then start it
+download to the Replica 1 you'll need my bintomon program at
+http://github.com/jefftranter/6502/tree/master/util/bintomon . Upload
+the file tmp/osi.mon to the Replica 1. Then start it
(e.g. "BD0DR"). You will see the following:
-<pre>
-MEMORY SIZE?
-TERMINAL WIDTH? 40
+ MEMORY SIZE?
+ TERMINAL WIDTH? 40
- 31999 BYTES FREE
+ 31999 BYTES FREE
-OSI 6502 BASIC VERSION 1.0 REV 3.2
-COPYRIGHT 1977 BY MICROSOFT CO.
+ OSI 6502 BASIC VERSION 1.0 REV 3.2
+ COPYRIGHT 1977 BY MICROSOFT CO.
-OK
-</pre>
+ OK
In the above I hit <Enter> in response to the memory size prompt,
which will use all available memory. I entered 40 for the terminal
@@ -64,15 +59,11 @@ slightly across versions. In the OSI version if you enter "A" in
response to the memory size question it will display the author of the
code:
-<pre>
-MEMORY SIZE? A
-
-WRITTEN BY RICHARD W. WEILAND.
+ MEMORY SIZE? A
+ WRITTEN BY RICHARD W. WEILAND.
+ MEMORY SIZE?
-MEMORY SIZE?
-</pre>
-
-If you don't have an EEPROM and Multi I/O board, you can run MS Basic
+If you don't have an EEPROM and Multi I/O board, you can run MS BASIC
out of RAM. Change the file osi.cfg so that the line specifying the
start address of the ROM is, say, $6000 instead of $A00 for the
EEPROM, e.g.
@@ -85,16 +76,37 @@ all memory or it will overwrite itself. In this example you can use
24000 to leave room for the 8K of BASIC at the top of memory. You
should have about 23K of memory available for BASIC programs.
-To port it to the Replica 1 I made the following changes (for details, see the patch):
+To port it to the Replica 1, I made the following changes (for
+details, see the patch):
+
+- The MONRDKEY routine to read from the keyboard was pointed to the
+ Woz mon location $FFEB.
+
+- The routines MONRDKEY (read key from keyboard) and LOAD and SAVE
+ were implemented in the file osi_extra.s. LOAD and SAVE are no-ops
+ and do nothing,
-- the MONRDKEY routine to read from the keyboard was pointed to the Woz mon location $FFEB
-- the routines MONRDKEY (read key from keyboard) and LOAD and SAVE were implemented in the file osi_extra.s
-- extra.s needed to include osi_extra.s when building for OSI
-- the version of CC68K U used did not recognize the C-style comments, so I had to remove them from some source file
-- I patched the build script make.sh to only build the OSI version and to call the bintomon program to generate the Woz mon download file
-- I also added options to make.sh to generate an assembler listing file and link map file
-- the osi.cfg file was modified for the size of EEPROM
-- the file osi_iscntc.s has code to check for the Control-C key being pressed. This was modified to work with the Replica 1. Control-C interrupts a running program. On the Replica 1 it works with a keyboard through the serial port but I found it did not work with a PS/2 keyboard because the Propeller code does not seem to pass this keyboard code to the Replica 1.
+- The file extra.s needed to include osi_extra.s when building for
+ OSI.
+
+- The version of CC68K I used did not recognize the C-style comments,
+ so I had to remove them from some source files.
+
+- I patched the build script make.sh to only build the OSI version and
+ to call the bintomon program to generate the Woz mon download file.
+
+- I also added options to make.sh to generate an assembler listing
+ file and link map file so you can determine the right start
+ addresses.
+
+- The osi.cfg file was modified for the size of EEPROM.
+
+- The file osi_iscntc.s has code to check for the Control-C key being
+ pressed. This was modified to work with the Replica 1. Control-C
+ interrupts a running program. On the Replica 1 it works with a
+ keyboard through the serial port but I found it did not work with a
+ PS/2 keyboard because the Propeller code does not seem to pass this
+ key code to the Replica 1.
This version is the "small" version of BASIC which fits in 8K and
supports 6 digit precision for floating point math. You can build the
@@ -108,23 +120,24 @@ eventually your program would try to free up space by garbage
collecting old strings and lock up the machine. This was fixed in
later versions of BASIC.
-A sample program which illustrates the floating sine function is
+A sample program which illustrates the floating point sine function is
below. It calculates points on a sine curve to be used in my
-experiment with using the 6522 VIA as a digital to analog converter
-http://jefftranter.blogspot.ca/2012/03/6522-via-experiment-6.html. Here
-is the program:
-
- 10 REM CALCULATE DATA POINTS FOR SINE WAVE
- 20 PI = 3.14159265
- 30 PRINT "SAMPLE VALUE ROUNDED"
- 40 FOR S = 0 TO 15
- 50 V = 7.5*SIN(2*PI * S/16) + 15/2
- 60 PRINT S;V;INT(V+0.5)
- 70 NEXT S
- 80 END
+experiment
+(http://jefftranter.blogspot.ca/2012/03/6522-via-experiment-6.html)
+using the 6522 VIA as a digital to analog converter. Here is the
+program:
+
+ 10 REM CALCULATE DATA POINTS FOR SINE WAVE
+ 20 PI = 3.14159265
+ 30 PRINT "SAMPLE VALUE ROUNDED"
+ 40 FOR S = 0 TO 15
+ 50 V = 7.5*SIN(2*PI * S/16) + 15/2
+ 60 PRINT S;V;INT(V+0.5)
+ 70 NEXT S
+ 80 END
The output for the "small" version of BASIC with 6 digit floating
-point is the following:
+point precision is the following:
SAMPLE VALUE ROUNDED
0 7.5 8
@@ -166,4 +179,3 @@ SAMPLE VALUE ROUNDED
With more effort you could port the other versions of MS BASIC to the
Replica 1, including Applesoft. I may do this in future.
-

0 comments on commit a900f21

Please sign in to comment.