Quick Start Notes for the SOFT6502 Trainer/Simulator
----------------------------------------------------

This is not a commercial product with production quality code or
extensive documentation, so if you want to try it, be prepared to
work with sketchy details.

There is a help system which explains the features of the display, so
refer to it when in doubt.

To get started, note that the simulator display resembles a simgle board
6502 computer, similar to a KIM-1. There is a keypad for entering data
and executing commands, a readout for monitoring the contents of memory,
and LEDs for the controlling the input port and displaying the state of
the output port.

Before running through some simple operations, it is worth noting that
6502 code and data files can be loaded and saved through the Windows
file system. Also, many of the keypad functions can be executed from
the computer keyboard. See the help file for additional features.

Example 1.

This example is a bare-bones first project for getting familiar
with the simulator.

Make sure the Address entry mode is in effect. Clicking the "AD"
button on the keypad will place the keypad in Address entry mode.
Alternatively, just click on the address readout. When Address
entry mode is active, the label over the address readout is
highlighted. In this mode, clicking the hex keys on the keypad will
change the address.

Clicking the "RS" key will reset the CPU so that the default starting
address 0200 (hex) is displayed. The contents of this address are
displayed on the data readout.

Now click the "DA" key to activate Data entry mode. The label over
the data readout will now be highlighted. On the hex keypad,
click "A" and then "9". The data display shows "A9". Click the "+"
key to store the "A9" at address "0200" and advance to next address.
Now click "2", then "3" and then "+". These operations collectively
have placed the 6502 instruction "A9 23" or LDA #23 in memory.
When executed, this instruction loads the number 23 (hex) into the
accumulator (a-register).

Click the "RS" key to reset the computer and click "GO". The simulator
will execute the instruction and halt at the next instruction -- "00"
is a break (BRK).

Examining the CPU register display reveals that the 'a' register now
contains "23".

Example 2.

Reset the CPU, set to Data entry mode, and enter the following:

  KEY PRESS         COMMENT 
    A9 (+)          Load accumulator...
    55 (+)          ... with 55
    8D (+)          Store accumulator...
    01 (+)          ... to the output
    80 (+)          port at 8001
    
Reset, and click "GO". Now the hex number 55 is displayed on the
output port LEDs.

Example 3.

From now on, pressing the (+) key will be assumed after each
data entry so it will not be indicated as it was above.

Reset the CPU. Set to Data entry mode, and enter:

  KEY PRESS         COMMENT
    AD              Load accumulator... 
    00              ... from the input
    80              port at 8000
    8D              Store accumulator...
    01              ... to the output
    80              port at 8001

Before running this code, click on some of the input port LEDs.
They toggle when you click them showing the state of port bits.
Now reset the CPU and click "GO". The pattern of LEDs you clicked
on the input port now appear on the output port.

Although clicking the hex keypad buttons to operate the simulator
is the best way to learn to use it in the spirit of single board
computers, it is actually much easier to use the computer keyboard,
where possible. You can enter data or addresses from the keyboard
by typing the appropriate keys, and can use the <Enter> key in
place of the hex keypad (+) key. See the help files for additional
information.

Example 4.

This example illustrates the use of single-step mode. Enter the
following code:

  KEY PRESS         COMMENT
    D8              Clear decimal mode
    A9              Load accumulator...
    01              ...with 1
    85              Store 1...
    F0              ...in Zero Page F0
    A2              Load x-reg...
    04              ...with 4
    E6              increment F0
    F0
    E6              increment F0
    F0
    65              add to acumulator...
    F0              ...contents of F0
    CA              decrement x-reg...
    D0              ...and branch back
    F9              if it is not zero

Click the "SST" key or press "T" to place the simulator in single-step
mode. These actions toggle the mode from 'run' to 'single-step'. If
the "SST" is not green, click again.

Now repeatedly click the "GO" key or press "G" while observing the
contents of the a-register "AR" on the register display. You can
confirm that adding consecutive odd numbers (which are created in
F0) will generate a series of squares (in the a-register). Four
loops will be executed, so if you just run the program rather than
single-stepping, on completion the square of 5 will be in the
accumulator (remember we started with the square of 1).

Files.

Several files have been included with the simulator. These files
demonstrate some of the its capabilities. They can be edited with
any ASCII text editor. You can also create your own programs with
a text editor or key them in from the simulator and save the
memory sections you coded to files for later reuse.

The file format, designated by *.h6x, is best explained from
the following example:

0200 A9 55
0202 8D 01 80

where the 1st 4 hex digits on each line specify the current address,
and that address is followed with from 1 to 16 code bytes consisting
of 2 hex digits each. This format is primitive, but it is easy
to understand, edit and create files which are acceptable to the
simulator.

File 1.

From the simulator file menu, click 'Load' and locate the file:

        lights.h6x

This file loads at 0200 (hex) and cycles the LEDs on the output
port. Just click the "GO" key, or type "G" on the computer keyboard,
to run it. The lights may flash too quickly to observe, in spite of
the delay built into the code. You may want to modify the code to
insert a longer delay.

File 2.

Load

    sqroot.h6x

This program will quickly compute 40 digits of the square root of
any integer from 1 to 19. It gets the number to operate on from
the input port, so just click LEDs to set the number you want.
For example, click the lowest green LED (port bit 0) and the third
LED (port bit 2) to set the number: 00000101 = 5.

Reset the CPU so the starting address displayed is 0200 and click
"GO". Now scroll the memory display to place address 0368 at the
top line. You will see the square root of 5 accurate to 40 digits,
starting at 036A.

This implementation is limited to integers from 1 to 19, but the
algorithm used will work with any positive, real number.


