Monday, April 30, 2012
ZOOP
I wanted to write a BASIC game or two for the Replica 1. Here is a little one I put together this evening.
This program enhances BASIC to make it a much more user-friendly and pleasant environment to work in -- or maybe not :-)
Seriously, just run it and try it. Looking at the source code first will spoil the fun.
Provided is a Woz Mon binary as well as source code. Either can be loaded but the binary may be easier to load.
It was inspired by a program called ZOOP in the book 101 BASIC Computer Games by David H. Ahl.
Saturday, April 28, 2012
2KSA is Running on the Replica 1
The 2K Symbolic Assembler (2KSA) is now running on the Replica 1! Only a few changes were needed -- implementing the appropriate I/O routines and relocating it from $0200 to $0300 to avoid a conflict with the Woz Monitor input buffer.
I haven't tested it exhaustively but it seems to work fine.
The same source can be conditionally assembled for either the KIM-1 or Apple1 / Replica 1. I've made available two download files for the KIM-1 (linked at the two addresses mentioned in the original document). I haven't tested them as I don't have a KIM-1 system but I confirmed that that code matched the binary dump in the original documentation.
I've also made a Replica 1 download file available.
I'm hoping to make a few enhancements to the code.
All files can be obtained from here.
Thursday, April 26, 2012
Porting 2KSA to the Replica 1
2KSA is a symbolic assembler written in 1979 by Robert Denison. A PDF document with source code and description is available here.
Cover Page of 2KSA Manual |
It was primarily written for KIM-1 systems.
It is a somewhat primitive assembler by today's standards but amazingly it is only about 2 kilobytes in size, written in assembler, allowing it to run resident on very small systems like the KIM-1. It is also well documented mostly portable. It is able to assemble itself.
I thought it would be fun to try to port it to the Replica 1. The first task is to enter the source code. The PDF file is all images, and while I have found some text versions of the document they are OCRed and are incomplete and have errors.
I am in the process of entering the code and getting it to assemble using cc65 to produce the same binary code as the dumps in the documentation. KIM-1 users may find this useful so I will make the original KIM-1 version available.
The next step will be to port it to the Replica 1 which should only involve replacing the I/O routines and some addresses. If it works well I may make some enhancements, like extending the error messages from the current one character messages.
So far I have found a few errors in the document but I can resolve them by looking at the memory dumps.
The source code can be found here.
Sunday, April 22, 2012
C Programming Tutorial with cc65 on the Replica 1
The cc65 cross-development tools include a C compiler. This allows you to write code for 6502 systems in a high level language. I'll present here a little tutorial on how to get C programs compiled and running on the Replica 1.
Where assembly language is fast, compact and efficient, but hard to program and BASIC is easy program but much slower, C provides an alternative that has most of the speed of assembly language while being easier to program.
To use it, you need to build the tools and cross-compile your code on a desktop system and then download it to your target system, i.e. a Replica 1. The documentation is quite good. See the cc65.org web site for information or check the on-line html documents when it is installed (typically at /usr/local/share/doc/cc65/index.html on a Linux system).
You'll want to get my patched version of cc65 that supports the Replica 1 from here.
For this tutorial I assume you are on a Linux system but it should work much the same way on a Windows or Mac OS X desktop.
I assume you now have the cc65 tools built and installed. Let's build and run a simple example C program (note that the source code for the examples I discuss can all be found here).
Let's start with the standard simple "hello world" program. Here is the listing for it (I'll refer to the file as hello1.c)
#include <stdio.h>
int main (void)
{
printf("\nHELLO, WORLD!\n");
return 0;
}
This is standard and the same as can be found in a book on C except maybe for only using upper case characters. The Replica 1 supports output in lower case but some other Apple 1 and compatible systems do not, so I will only use upper case in these examples.
To compile it we can use the "cl65" program. In the simplest case we can just do:
cl65 hello1.c
which will produce a binary file hello1.
Typically we want to get a little fancier and specify some additional options. I typically use:
cl65 -O -l -vm -m hello1.map -t replica1 hello1.c
Where the options specified the following:
-O -> optimize the code
-l -> produce a listing (.lst) file
-vm -> produce a detailed map file
-m -> specify the map file name
-t -> compile for Replica 1 (default is to compile for a Commodore 64).
Now to get the code onto the Replica 1 we want a Woz monitor binary format file. The bintomon program can do this. This program is included in my cc65 patches but you will need to compile and run it. You'll find it in the source under /util/apple1. You need to compile it for your desktop system and you probably want to install it in a standard location as well. Commands like this will do the trick on a Linux system:
cd util/apple1
gcc -o bintomon bintomon.c
sudo cp bintomon /usr/local/bin
To generate the Woz monitor version of our compiled hello1 program we can run:
bintomon -v -f hello1 >hello1.mon
and see the output:
Load address: $0280
Run address: $0280
Length: $0A07 (2567 bytes)
Last address: $0C87
With compiled C programs the start address and program length are stored in the binary and bintomon can use these when generating the min file. Note that it does not work this way for assembly programs, you need to specify the load address unless it is the default 0x280.
Now load the monitor file into your Replica 1 machine using a serial terminal program. I use minicom on Linux. I also use high speed serial mod which speeds up the loading process greatly.
After loading the program will run and you should see output like this:
HELLO, WORLD!
Getting this first program running is usually the hardest step. Congratulations if you were successful.
Now for a little more complex program, let's try hello2.c, the listing for which is below. It uses some Apple 1 specific routines from apple1.h, specifically keypressed() and readkey().
The program illustrates some math by outputting a table of numbers and their squares and cubes. It also shows the length in bytes of the various C data types. Then it gets and displays a key press.
#include <stdio.h>
#include <stdlib.h>
#include <apple1.h>
int main (void)
{
int i = 0;
short x = 1;
char c = 2;
long l = 3;
for (i = 0; i < 10; i++) {
printf("%d %d %d\n", i, i*i, i*i*i);
}
printf("SIZEOF(CHAR) = %d\n",sizeof(char));
printf("SIZEOF(SHORT) = %d\n",sizeof(short));
printf("SIZEOF(INT) = %d\n",sizeof(int));
printf("SIZEOF(LONG) = %d\n",sizeof(long));
printf("PRESS A KEY TO CONTINUE\n");
while (!keypressed())
;
i = readkey();
printf("KEY WAS: %c\n", i);
return 0;
}
When run, the output looks like:
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
SIZEOF(CHAR) = 1
SIZEOF(SHORT) = 2
SIZEOF(INT) = 2
SIZEOF(LONG) = 4
PRESS A KEY TO CONTINUE
KEY WAS: A
Note that all these examples as well as a Makefile for building them is provided on the site at github.
Included there are a couple of other examples. The file nqueens.c is a little program I write years ago for solving a chess program called the "N Queens Problem". The program sieve.c calculates prime numbers. Both of these are very CPU-intensive programs and will give you an idea of how fast code runs on a Replica 1 versus a modern desktop system.
Feel free to try building and running the examples and perhaps modifying them. Some other things to try:
- Look at the generated assembly code (.lst file) for the programs and trying to understand it.
- Compare the code generated with and without the -O (optimize) option.
- Find or write some more small C programs and get them running on the Replica 1.
In summary. cc65 is a full C compiler that supports almost all language features except for floating point math. I've used it for writing a reasonably large adventure program, about 880 lines of source code. The code was much easier to write than in assembly, and more pleasant to write in than BASIC.
I was also able to compile and test it on a desktop system before running it on the Replica 1.
Saturday, April 21, 2012
Latest CC65 Patches for Replica 1
There have been various patches for the cc65 assembler / compiler tools to support Apple 1 and Replica 1 systems but I haven't seen any patches for the latest release. I took patches for 2.12 (thanks to Jeremy Rand for these) and got them working with 2.13.3. The patches can be found here.
I am hoping to get these patches applied back to the original source at cc65.org so future releases will support Apple 1 / Replica 1 systems out of the box.
I am hoping to get these patches applied back to the original source at cc65.org so future releases will support Apple 1 / Replica 1 systems out of the box.
Labels:
Apple 1,
assembler,
C compiler,
CC65,
Replica 1
Enhanced 6502 BASIC 2.22 for the Replica 1
In an earlier blog post I mentioned Enhanced 6502 BASIC by Lee Davison. This is a very powerful and extensive version of BASIC. A version of it was ported to the Replica 1. This was version 1.10 back in 2005. I couldn't find a port of the most recent version 2.22, so I spent an evening and got it running on the Replica 1. All that is really needed to port it is to implement the routines for character input and output. I also had to adjust the start and end memory locations. I also made a few changes so it would compile with the cc65 assembler.
You can get my port from here. As well as source there is a prebuilt Woz monitor binary you can use that runs from RAM. BASIC resides starting at address $5000 so you have about 20K of space available for programs if you accept the default and just press Enter when prompted for "Memory size?".
There are some known limitations: IRQ and NMI handling is not implemented because the vectors are in the Woz monitor ROM and cannot be changed. The SAVE and LOAD commands do nothing. I haven't done much testing so there could be bugs.
When I get my 16K EEPROM board running I'll try linking it in EEPROM instead of RAM and then all 32K RAM will be available for BASIC programs.
Startup Screen |
There are some known limitations: IRQ and NMI handling is not implemented because the vectors are in the Woz monitor ROM and cannot be changed. The SAVE and LOAD commands do nothing. I haven't done much testing so there could be bugs.
A Small Program Running |
Thursday, April 19, 2012
16K Memory Card Update
The protoboard arrived today. It is the Vector Plugbord model 4112-4. It fits the Replica 1 slot nicely. It is quite large and could be cut in size for this project but I may use the space for additional circuitry later.
I'm still waiting on some of the other parts.
I did some investgation into the EEPROM write timing. It takes worst case 1 msec to write (at least for the datasheet for the chip vendor I looked at). So for example, my JMON monitor program's fill and copy commands will write data too fast to EEPROM. Uploading a file to the Woz monitor over the serial port is fine. I'll investigate a way to put optional delays into JMON's commands for the slower EEPROM in case I need to move data around.
I don't yet have a RAM chip to confirm if the design works with RAM as well as EEPROM.
I had a request to create binaries (Woz monitor files) for some of my code, specifically the adventure game and and OSI BASIC. These are now on github for anyone who wants them and doesn't have the development tools to build them from source.
Wednesday, April 18, 2012
Replica 1 16K Memory Card
I've started a little hardware project to build an expansion board for the Replica 1. It's a simple memory expansion card that can hold one or two 8K RAM, EEPROM, or EPROM chips. The two chips are addressed at $8000-$9FFF and $A000-$BFFF. This can conflict with devices on some other cards like the EEPROM on the Multi I/O board if you have it installed at the same time (You would need a slot expander to do that). This is about all the space there is available for addressing beyond what is on the Replica 1 board. There will be a write enable jumper for each chip so you can disable writing (which only really makes sense for EEPROMs). Basically, it uses Vince Briel's one-chip EEPROM circuit documented here and used on the Multi I/O board, with suitable address decoding (my implementation takes 2 chips).
It's a simple board but it will allow me, for example, to put programs larger than 8K (like Microsoft BASIC or my adventure game) in EEPROM or to have up to a total of 48K of contiguous RAM available. There will be room on the board for more circuitry later, if needed.
Prototype on Breadboard |
So far I have prototyped the circuit on a breadboard. I didn't hook up all the data and address lines and only used one EEPROM. I've confirmed that it can read and write. I used the gschem schematic capture software, more just to make a nice printed schematic than for any other reason. I did several rough designs earlier on paper.
I ordered the remaining parts I needed, most notably a Vectorbord proto board. I got most parts from Unicorn Electronics. I bought the protoboard from Digikey as shipping was the most reasonable of several vendors.
There are several Vectorbords from Vector Electronics that fit the Replica 1 slot. Note that the protoboard sold by Achatz Electronics will not work on the Replica 1 as it uses a different connector.
I will post another installment reporting on my progress when I start assembling the real board. I'll also include the schematic.
If I get really ambitious I might lay out a circuit board. This would probably only be feasible if I made a few boards. Anyone interested in a board like this either as a bare board, kit of parts, or assembled? If so, drop me a line.
Labels:
6502,
Apple 1,
EEPROM,
memory expansion,
Replica 1
Sunday, April 8, 2012
Microsoft BASIC for the Replica 1
At this site 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 to build it.
If you want a more complete version of Apple BASIC, see Applesoft Lite.
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 here. To get OSI BASIC running on the Replica 1, extract the source code, apply the
patch REPLICA1-PATCHES-FOR-OSI.patch, and build it, e.g. on a Linux system:
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.
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. Upload the file tmp/osi.mon to the Replica 1. Then start it (e.g. "BD0DR"). You will see the following:
MEMORY SIZE?
TERMINAL WIDTH? 40
31999 BYTES FREE
OSI 6502 BASIC VERSION 1.0 REV 3.2
COPYRIGHT 1977 BY MICROSOFT CO.
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 width.
There is a well-known Easter egg in Microsoft BASIC which varies 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:
MEMORY SIZE? A
WRITTEN BY RICHARD W. WEILAND.
MEMORY SIZE?
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.
BASROM: start = $6000, size = $2000, fill = no, file = %O;
Change the line in make.sh that runs bintomon to specify the start address of 0x6000. When running in RAM, don't let if default to use 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):
- 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 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 9 digit precision version by changing the file defines_osi.s to comment out the line "CONFIG_SMALL := 1". It no longer fits in 8K so you need to link it a lower address, e.g. $5000 if using RAM.
The OSI version of MS BASIC has a nasty bug with garbage collection of strings not working correctly. If you use arrays of strings 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 point sine function is below. It calculates points on a sine curve to be used in my experiment 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 precision is the following:
SAMPLE VALUE ROUNDED
0 7.5 8
1 10.3701 10
2 12.8033 13
3 14.4291 14
4 15 15
5 14.4291 14
6 12.8033 13
7 10.3701 10
8 7.5 8
9 4.62988 5
10 2.1967 2
11 .570904 1
12 0 0
13 .570902 1
14 2.1967 2
15 4.62987 5
And the output for 9 digit floating point is:
SAMPLE VALUE ROUNDED
0 7.5 8
1 10.3701257 10
2 12.8033009 13
3 14.4290965 14
4 15 15
5 14.4290965 14
6 12.8033009 13
7 10.3701258 10
8 7.50000003 8
9 4.62987429 5
10 2.19669917 2
11 .570903519 1
12 1.11758709E-08 0
13 .57090348 1
14 2.1966991 2
15 4.62987421 5
With more effort you could port the other versions of MS BASIC to the Replica 1, including Applesoft. I may do this in future.
Saturday, April 7, 2012
Converting 45RPM Records to MP3 Format
We have a number of records, mostly 45 RPM singles. Some were bought for our Seeburg Jukebox which holds 80 records. Some my wife owned and has kept since she was young.
I wanted to convert them to computer format. Earlier this year I looked at USB turntables and bought a Denon DP-200USB. It was an average priced unit, with some cheaper and some more expensive. It supports 33-1/3 and 45 RPM and 7 and 12 inch record sizes (both set independently, so you can play 33-1/3 RPM 7 inch records, for example).
A nice feature is that the turntable records directly to a USB key, so doesn't need a computer connection or any particular software to transfer records to MP3 format.
USB Turntable Converting 45s to MP3 Files |
It came with some Windows-based software but I decided to do all my work under Linux, which is my normal desktop environment (usually Ubuntu Linux running the KDE desktop).
After converting the files to MP3 format, they need some editing on the computer. I used the Audacity program to do this. Typically what is needed is to remove any extra silence at the beginning and end of the recording. A few records, such as children's stories, may continue the same material on both sides, and for these it is ideal to combine both sides into a single MP3 file.
Here are screen shots of Audacity before and after editing a track to remove extra silence.
Editing Raw MP3 File with Audacity |
After Removing Extra Silence |
There are effects in Audacity that can be used to change the sound, but I didn't use any of them. If a record skips it is even possible to edit it out, but it is a little tedious. The most useful effect would be a filter to remove pops and scratches but I haven't found an automated filter that is particularly good at this.
The final step is to add MP3 tags to identify the song and artist. I tried the software that came with the turntable that can do this using the Gracenote service. I didn't have much luck with it, it was unable to identify most tracks, probably because their song database is mostly made from CD tracks and not 45s.
I ended up adding the tags manually from within the Amarok music player. The TrackID program on my Android cell phone was able to identify most tracks, along with the odd Google search using some of the song lyrics.
Audacity MP3 Tags Dialog |
I copied just over 200 45 RPM records, mostly just the A sides. I have a total of just over 2000 tracks in my music collection, all of which came from records or CDs that I own. What is amazing is that these can all be easily stored on one tiny 16GB USB key, below:
A Tiny USB Key |
I typically have this in my Car's music player, which can play MP3 files on a USB key.
USB Key in Car Audio System |
Thursday, April 5, 2012
Nostalgic Musing on CPUs
The first processor I learned was the 6502 on an Ohio Scientific Superboard computer. My main resource for learning was the book Programming a Microcomputer: 6502 by Caxton Foster, which was written for the KIM-1 computer but was pretty generic. I wrote a disassembler, a simple assembler, and some games. Later I got an Apple //e and did some more 6502 programming with it, along with BASIC, and Pascal.
Ohio Scientific Superboard |
I used a 6800 in university and at a summer job at the university working on an embedded data acquisition system. The graduate student writing the code had no source code, he just typed in the bytes and burned them into an EEPROM! I adapted my disassembler in BASIC from the 6502 to the 6800 to disassemble the EEPROMs and make a hardcopy of the code.
At school I also used a 6800 cross-assembler on a minicomputer for labs on a small KIM-1 like single board computer. I remember it had a minor bug - it assembled the NOP instruction wrong! In a CS course I did a little assembler programming on a mainframe that had 60 bit words - I believe it was a CDC Cyber.
When I started working in the mid 80's I worked on developing equipment for manufacturing testing. It was all custom and used Motorola processors. It started with the 6800 but mostly used 6809 for new development by that time. The 6809 was a big improvement over the 6800 having more registers and addressing modes. You had 16-bit registers and could write position independent code. It could even do an 8-bit multiply! I spent many hours programming EEPROMs or waiting for them to be erased under an ultra violet light so I could test my latest version of code.
Then the 68000 came out and it was an embarrassment of riches to have 16 32-bit registers and a MOVE instruction that could move from anywhere to anywhere. It ran at a blazing 8MHz! I didn't actually do much assembler programming on the 68000 because by then we were mostly using higher level languages like C and Pascal (and a language called Concurrent Euclid that you probably haven't heard of).
I still have a soft spot in my heart for the 6502 as all the programming I did on it was done for fun. It was the first processor I learned, and it has an elegant simplicity to it.
Actually, I wasn't entirely correct when I said I first learned the 6502. Some time when I was under 10 years old my father introduced me to the CARDIAC computer: CARDboard Illustrative Aid to Computation. The short book and cardboard model was a hypothetical processor that taught how processors work at the fundamental level. It was a simple CPU with 10 instructions and the student used the cardboard model to execute instructions in a program himself. Copies of the booklet and computer are available on the Internet. Even the original cardboard CARDIAC is still available.
Cardiac Computer |
Accompanying Booklet |
I remember at the time I found it hard to resolve the wide gap between this explanation of a computer with what I saw in the media, such as the robot in Lost In Space or computer on Star Trek. I was also given a book called The How And Why Wonder Book Of Robots And Electronic Brains that probably set some unrealistic expectations about computers too.
On my to do list is to write a simulator for the CARDIAC, probably graphical in C++ using the Qt toolkit.
Wednesday, April 4, 2012
Lemonade Stand Ported to the Replica 1
I was thinking of some old BASIC games and my wife mentioned one she always liked: Lemonade Stand. I looked for a port to the Apple 1 / Replica 1 but couldn't find one. There are lots of versions of it around, including some that run in a web browser.
After some digging around I found a version for the Mac that included the original Apple ][ version from 1979 as comments in it's source code. The comments in the BASIC code say that the original program was written by Bob Jamison of the Minnesota educational computing consortium and modified for the Apple ][ by Charlie Kellner in February 1979.
I extracted the original source code from the Mac version and removed anything to do with POKEs, graphics, etc. that was not supported on the Replica 1. After an hour or two I had it up and running.
It needs Applesoft Lite (not the Apple Integer BASIC built into the Replica 1) because it uses a lot of floating point calculations. I suppose it could be ported to the Integer BASIC with some effort. If you want to try it, the code is here.
Below is a transcript of a sample run of the game. It supports multiple players and let's you play until you quit or go bankrupt.
HI! WELCOME TO LEMONSVILLE, CALIFORNIA!
IN THIS SMALL TOWN, YOU ARE IN CHARGE OF
RUNNING YOUR OWN LEMONADE STAND. YOU CAN
COMPETE WITH AS MANY OTHER PEOPLE AS YOU
WISH, BUT HOW MUCH PROFIT YOU MAKE IS UP
TO YOU (THE OTHER STANDS' SALES WILL NOT
AFFECT YOUR BUSINESS IN ANY WAY). IF YOU
MAKE THE MOST MONEY, YOU'RE THE WINNER!!
ARE YOU STARTING A NEW GAME? (YES OR NO)
TYPE YOUR ANSWER AND HIT RETURN ==> Y Y
HOW MANY PEOPLE WILL BE PLAYING ==> 1
TO MANAGE YOUR LEMONADE STAND, YOU WILL
NEED TO MAKE THESE DECISIONS EVERY DAY:
1. HOW MANY GLASSES OF LEMONADE TO MAKE (ONLY ONE BATCH IS MADE EACH MORNING)
2. HOW MANY ADVERTISING SIGNS TO MAKE (THE SIGNS COST FIFTEEN CENTS EACH)
3. WHAT PRICE TO CHARGE FOR EACH GLASS
YOU WILL BEGIN WITH $2.00 CASH (ASSETS).
BECAUSE YOUR MOTHER GAVE YOU SOME SUGAR,
YOUR COST TO MAKE LEMONADE IS TWO CENTS
A GLASS (THIS MAY CHANGE IN THE FUTURE).
PRESS SPACE TO CONTINUE, ESC TO END...
YOUR EXPENSES ARE THE SUM OF THE COST OF
THE LEMONADE AND THE COST OF THE SIGNS.
YOUR PROFITS ARE THE DIFFERENCE BETWEEN
THE INCOME FROM SALES AND YOUR EXPENSES.
THE NUMBER OF GLASSES YOU SELL EACH DAY
DEPENDS ON THE PRICE YOU CHARGE, AND ON
THE NUMBER OF ADVERTISING SIGNS YOU USE.
KEEP TRACK OF YOUR ASSETS, BECAUSE YOU
CAN'T SPEND MORE MONEY THAN YOU HAVE!
PRESS SPACE TO CONTINUE, ESC TO END...
LEMONSVILLE WEATHER REPORT:
SUNNY
PRESS SPACE TO CONTINUE, ESC TO END...
ON DAY 1, THE COST OF LEMONADE IS $.02
LEMONADE STAND 1 ASSETS: $2.00
HOW MANY GLASSES OF LEMONADE DO YOU
WISH TO MAKE ?30
HOW MANY ADVERTISING SIGNS (15 CENTS
EACH) DO YOU WANT TO MAKE ?1
WHAT PRICE (IN CENTS) DO YOU WISH TO
CHARGE FOR LEMONADE ?25
WOULD YOU LIKE TO CHANGE ANYTHING?N
** LEMONSVILLE DAILY FINANCIAL REPORT **
DAY 1 STAND 1
6 GLASSES SOLD
$.25 PER GLASS, INCOME $1.50
30 GLASSES MADE
1 SIGNS MADE, EXPENSES $.75
PROFIT: $.75
ASSETS: $2.75
PRESS SPACE TO CONTINUE, ESC TO END...
LEMONSVILLE WEATHER REPORT:
SUNNY
PRESS SPACE TO CONTINUE, ESC TO END...
ON DAY 2, THE COST OF LEMONADE IS $.02
LEMONADE STAND 1 ASSETS: $2.75
HOW MANY GLASSES OF LEMONADE DO YOU
WISH TO MAKE ?20
HOW MANY ADVERTISING SIGNS (15 CENTS
EACH) DO YOU WANT TO MAKE ?1
WHAT PRICE (IN CENTS) DO YOU WISH TO
CHARGE FOR LEMONADE ?14
WOULD YOU LIKE TO CHANGE ANYTHING?N
** LEMONSVILLE DAILY FINANCIAL REPORT **
DAY 2 STAND 1
20 GLASSES SOLD
$.14 PER GLASS, INCOME $2.80
20 GLASSES MADE
1 SIGNS MADE, EXPENSES $.55
PROFIT: $2.25
ASSETS: $5.00
PRESS SPACE TO CONTINUE, ESC TO END...
LEMONSVILLE WEATHER REPORT:
SUNNY
PRESS SPACE TO CONTINUE, ESC TO END...
WOULD YOU LIKE TO PLAY AGAIN?N
Sunday, April 1, 2012
Source code now on github.com
Just quick note that the source code for my various 6502 programs can now be found here on github.com.
Some 6502 Assemblers and Simulators
In this posting I'll list some cross-compilers and related tools for the 6502 processor. Some of these I have used, others I have come across but don't have personal experience with.
CC65 is a comprehensive suite of 6502 assembler, linker, C compiler, and related tools. I've used it heavily and found it to be excellent. The C compiler is almost fully ANSI C compliant and generates surprisingly good code considering the limitations of the 6502 processor.
SB-Assembler is a cross-assembler for a number of processors including the 6502. A new version 3 is in development that will run on Windows, MacOS, and Linux.
Virtual 6502 is a browser-based 6502 assembler, simulator, and disassembler. You can enter code, assemble it, and paste into simulator and run it.
Soft6502 is a 6502 simulator which has a graphical interface that resembles a single board computers such as the KIM-1. It runs on Windows.
Here is a 6502/65C02 macro assembler, simulator, and debugger which runs on Windows. Krusader was written using it.
Xa is a portable cross-assembler for the 6502, 65C02, and 65816 processors.
At this site is Aart Bik's 65xx cross-assembler designed for the Commodore 64 but applicable to other 65xx-based computers. It runs on Windows, MacOS, and Linux.
POM 1 is an Apple 1 emulator written in Java.
A very extensive list of tools for the 6502 can be found at this link. The site also has a huge collection of useful information on the 6502 processor.
Subscribe to:
Posts (Atom)