Atari 850 interface: 6507 + 2 6532

Though this site is not about home computer systems, but about small SBC’s, it is nevertheless interesting to look at the Atari 850 system.
Atari produced the 850 Interface Module to provide access to devices complying with two important interface standards of the time, RS-232-C serial and Centronics parallel.
Four serial interfaces, one parallel interface in self contained case, with its own power supply. Connected to the Atari via the standard SIO cable.

When you look into the system you discover it is actually a simple microprocessor system. The heart is a 6507 CPU, the serial and parallel lines are built with two 6532 IC’s, a ROM with the software.
Serial interfaces and the 6532? This means bit banging.
So this fits well in the theme of small SBCs!

I show you here the circuit diagram, operator, service and technical manual and the sources/binaries of the ROM.

Circuit diagram
Atari 850 interface Module Operator Manual
Atari 850 interface Module Technical Manual
Atari 850 interface Module Service Manual
Sources and binaries of the 850 ROM
Parts list page 1, 2

While the Atari's SIO and controller ports did not conform to established
industry standards, Atari produced the 850 Interface Module to provide access
to devices complying with two important interface standards of the time,
RS-232-C serial and Centronics parallel.

RS-232-C Serial Interface
-------------------------
The Electronic Industries Association (EIA) introduced the RS-232 standard,
entitled "Interface Between Data Terminal Equipment (DTE) and Data Circuit-
Terminating Equipment (DCE) Employing Serial Binary Data Interchange," in 1960
in an effort to standardize the interface between DTE (usually a terminal or a
computer emulating a terminal) and DCE (usually a modem).  Although emphasis
then was placed on interfacing between a modem unit and DTE, other
applications for the standard gained popularity.  Early versions of the EIA
232 standard included RS-232 (1960), RS-232-A (1963), and RS-232-B (1965).
From 1969-1987, including most of the time of the 8-bit Atari, the standard
was formally known as EIA RS-232-C.  Revisions since then have included EIA-
232-D (1987), EIA/TIA-232-E (1991), and the current version from the
Telecommunications Industry Association, EIA/TIA-232-F (1997), known as of
2011 as TIA-232-F.  Especially in the 1980s, 232 was widely adopted for low-
cost serial connections between the DTE and peripherals such as an external
modem, mouse, plotter, printer, scanner, digitizer, track ball, and myriad
others.  In more recent years TIA-232-F has essentially been supplanted by
USB.  In keeping with the context of the time period, this FAQ will normally
refer to the 232 standard as RS-232-C.  

The Atari 850 interface connects to the SIO port on the Atari computer and
provides the system with:

- Four serial interface ports (RS-232-C)
- One 8-bit parallel output interface port (Centronics)

Serial interface port key features:
- The 850 functions as RS-232-C Data Terminal Equipment (DTE).
- RS-232-C Circuits (signaling lines):
                 (Send / Out)  | (Receive / In)
       Port 1:   XMT, DTR, RTS | RCV, DSR, CTS, CRX
       Port 2:   XMT, DTR      | RCV, DSR
       Port 3:   XMT, DTR      | RCV, DSR
       Port 4:   XMT           | RCV
- Port 4 primarily serves as a 20 mA current loop interface, supporting
  20 mA current loop peripherals such as a teletype machine.
- Baud rates:
    45.5 bit/s*, 50 bit/s*, 56.875 bit/s*, 75 bit/s**, 110 bit/s, 134.5 bit/s,
    150 bit/s, 300 bit/s, 600 bit/s, 1200 bit/s, 1800 bit/s, 2400 bit/s, 
    4800 bit/s, 9600 bit/s
  * These baud rates are useful for communications with Baudot teletypes, for
    RTTY (radioteletype) applications.  They are more commonly referred to as
    60, 67, and 75 words per minute.
 ** This baud rate is sometimes used for ASCII communications, and may also
    be used for 5-bit Baudot RTTY.  The latter is commonly referred to as
    100 words per minute.

The Atari Operating System does not include a resident device handler for the
serial ports of the 850, but the 850 contains an R: handler, supporting
devices R1: through R4:, in its ROM.  
   - Bootstrap without disk drive-- With no powered disk drive #1 present, the
     R: handler loads from the ROM of a powered 850 into computer RAM on 
     system startup.  (The 850 masquerades as disk drive #1, responding to the
     Atari OS attempt to boot from disk.)  An extended beep is emitted through
     the computer's audio signal as the handler is loaded.
   - Bootstrap with disk drive-- The R: handler can be loaded from the
     850 ROM as part of a Disk Boot.  (Atari DOS 2.0S, DOS 3, DOS 2.5, and 
     DOS XE include provisions for this.)
   - The R: handler can be loaded from the 850 ROM by software after system 
     boot.
Many alternatives to the 850 ROM R: handler have been developed.  Please see a
separate section of this FAQ list regarding R: and T: device handlers for the
850 for more details.

The Atari Operating System's resident P: Printer device handler supports the
parallel output interface port of the 850.
- 400/800 OS: Responds to P: and ignores any device number
    XL OS: Responds to P:, P1:, and P2:

PINOUTS
=======
Serial Interface Port 1 (DE-9 Socket - female):
                1. DTR Data Terminal Ready (Out)
                2. CRX Carrier Detect      (In)
  5         1   3. XMT Send Data           (Out)
   o o o o o    4. RCV Receive Data        (In)
    o o o o     5. Signal Ground
   9       6    6. DSR Data Set Ready      (In)
                7. RTS Request to Send     (Out)
                8. CTS Clear to Send       (In)

Serial Interface Port 2 (DE-9 Socket - female):
  5         1   1. DTR Data Terminal Ready (Out)
   o o o o o    3. XMT Send Data           (Out)
    o o o o     4. RCV Receive Data        (In)
   9       6    5. Signal Ground
                6. DSR Data Set Ready      (In)

Serial Interface Port 3 (DE-9 Socket - female):
  5         1   1. DTR Data Terminal Ready (Out)
   o o o o o    3. XMT Send Data           (Out)
    o o o o     4. RCV Receive Data        (In)
   9       6    5. Signal Ground
                6. DSR Data Set Ready      (In)

Serial Interface Port 4 (DE-9 Socket - female):
                        / 20 mA Current Loop Operation
                1. +10V / TXD+ Send Data +
  5         1   3. XMT  / TXD- Send Data - (Out)
   o o o o o    4. RCV    Receive Data     (In) --+  A 20 mA current loop
    o o o o     5. Ground                         |  device must tie together
   9       6    7. +10V / RXD+ Receive Data +   --+  pins 4 and 7.
                9. -8V  / RXD- Receive Data -

Parallel Interface Port (DA-15 Socket - female):
                     1. /Data Strobe
                     2. Data bit 0
                     3. Data bit 1
 8               1   4. Data bit 2
  o o o o o o o o    5. Data bit 3
   o o o o o o o     6. Data bit 4
  15            9    7. Data bit 5
                     8. Data bit 6
                     9. Data Pins Pull-Up (+5V)--+ A device that cannot hold
                     11. Signal Ground           | /Fault high may instead tie
                     12. /Fault (high required)--+ together pins 12 and 9.
                     13. Busy
                     15. Data bit 7

Prototype 850 units are in an all-black brushed steel case, but production
units are in a beige plastic case matching the 400/800 computers.

Front of unit (left-to-right):
 - Power In jack
 - On power indicator light
 - Power Off / On switch
 - Two I/O Connectors (Atari SIO)
Right side of unit:
 - Parallel Interface port
Rear of unit (left-to-right):
 - Four Serial Interface ports, 4 - 3 - 2 - 1

850 internals:
 - 6507 MPU (MOS Technology MCS6507 or equivalent), C010745
 - 6532 PIA.  Two of: 
    - MOS Technology 6532 RAM-I/O-Timer (RIOT) or equivalent, C010750
 - 4KiB X 8 Bit ROM, C012099

Manuals:
- Atari 850 Interface Module Operator's Manual C015953 Rev. 1 1980
  (preliminary version shipped with earlier/most 850 units; 102 pages)
- Atari 850 Interface Module Operator's Manual C017651 REV. B 1982 (15 pages)
- Atari 850 Interface Module Technical Manual C017652 REV. B 1982 (106 pages)
- Atari 850 Interface Module Field Service Manual
   - CS 400/800-S004-B 4/81
   - FD100036 April, 1981

Power: Used with an external 9 volt AC transformer power supply rated for at
least 17 watts: Atari CA014748 or equivalent.

The 850 was designed by R. Scott Scheiman at Atari, 

The 850 was alo sold as bareboard with a parts list


KIM-1 emulators

A page describing known (to me) KIM-1 emulators.

No one is yet prefect., the combination of my KIM Simulator and the KIM-1 emulator in Javscript comes close.

KIM-1 emulators

A list of KIM-1 emulators/simulators
To be included in this list, the emulator should run the original KIM-1 ROM’s. I prefer to see source code, which all do except Kimplement. If I can not run it, it is not on this list (I know of an Apple iPhone  and a Palm Pilot version) .

My favorites are of course my own KIM Simulator (for TTY programs) and the KIM-1 emulator in JavaScript (for LED display programs).

Troublemakers in KIM-1 emulation are due to the bit banging nature of the KIM-1 system:

  • Serial I/O.
    Since the KIM-1 uses bit banging to do serial I/O this is hard to emulate. Therefore most emulators patch the ROM at the GETCH and OUTCH locations to send and receive a character, including the hardware echo of GETCH
  • The automatic baudrate detection, also a bit banging routine, is patched out since it has no meaning with patched serial I/O routines and makes the emulator hang at boot.
  • Break detection.
    Most KIM-1 programs, like MS-Basic, break/stop detection by a BIT at location $1740. This of course does not work on patched serial I/O, so a patch at location 1740 is required.
  • The finer details of the serial interface, like PB0, PB5, PB7 and PB7 are often not implemented, so the hardware echo can not be prevented.
  • Tape I/O, $1800, $1873, is often replaced by some form of dumping /loading memory with the start and stop and ID of the original routine with a binary file or omitted
  • LED displays.
    Also bit banging. By calling the SCANDS routine, repeated at a fast rate, the LED segments are switched on and off. The data, six nibbles interpreted as a hex number, per LED display comes from $F9, $FA, $FB, for a total of six digits. A bit complicated (see the information below) and hard to emulate without flickering.
    A solution is to patch the SCANDS routine and displaying the hex without the switching off of segments. This works fine for the KIM-1 ROM itself and many programs that call SCANDS to light the LEDs. If the program (many First Book of KIM games e.g.) does bypass SCANDS and go directly to the hardware, it will fail.

Below is a list of, known to me, KIM-1 emulators/simulators. Details below the table.

——————— ————- ————- —————— ——–
Name, website Platform Serial I/O LED display Tape
——————— ————- ————- —————— ——–
KIM-1 Simulator Windows, Linux, MacOS terminal builtin SCANDS emulation None
——————— ————- ————- —————— ——–
Linux terminal KIM-1 Emulator Linux CLI CLI SCANDS emulation Yes
——————— ————- ————- —————— ——–
KIM-1 emulator in JavaScript Web browser No Hardware emulation None
——————— ————- ————- —————— ——–
The Incredible KIMplement C64 Yes Yes ?
——————— ————- ————- —————— ——–
KIM UNO ARDUINO, ESP32, Windows, Linux Yes Yes Yes
——————— ————- ————- —————— ——–
VKIM PALM OS (And HTML 5 browser, see VKIM Yes Yes Yes
——————— ————- ————- —————— ——–

KIM-1 Simulator

My own attempt to KIM-1 emulation. The goal is more to test and study 6502 software for the KIM-1 than cycle exact LED display KIM-1 emulation.
A GUI application. The LED display is simulated by patched SCANDS, so hex digits only, no LED games.
Serial TTY is fully supported including echo suppress and Break detection via the built-in glass teletype console.
Debugging mode allows full access tot the innards of the 6502 or 65C02, the KIM-1. memory view, single/multiple step, run to breakpoint, instruction logging,, cycle counter, disassembly.
Loading and saving to many common formats like MOS papertape, Intel Hex, Motorola S record, binary, hex.
Both RRIOTs, a 6850 ACIA, a LE/switch to the free RRIOT port, RAM to E000, a utility ROM at F000. Runs all known TTY programs.
Things not working yet: LED displays via hardware RRIOT ports (without flickering!), timers in RRIOTs, timed execution to 1 MHz, tape emulation (including the Micro ADE tape motor control support).

Linux KIM-1 emulator

A command line KIM-1 emulator, running on Linux. Runs fine on Raspberry Pi OS.

Simulates LED display with characters displayed at the terminal. Every key entered results in a new line with the LED display. Also supports TTY mode, be it limited to the maximum of 5K RAM in lower memory.
A good attempt to stay close to the bit banging nature of the keyboard entry routine. Limits speed to 1 MHz.

The Incredible KIMplement

A KIM-1 emulator running on a Commodore 64. Which means it will be slow, since 1 MHz 6510 running an emulated 6502, you get the picture. I did test run/Kimplement a long time ago in an C64 emuatator,  The Incredible KIMplement is a KIM-1 emulator for the Commodore 64 (yes, this is not a joke — see the screenshot to the right). It is a true, partial emulation of the original KIM-1 hardware featuring:

  • Powered by “6o6” — a full software NMOS 6502 emulation (documented opcodes only, sorry) with all addressing modes, simulated ROM, and simulated memory-mapped I/O
  • LED and keypad emulation via partial RIOT emulation
  • TTY emulation (ASR-33 subset) via partial RIOT emulation
  • SST emulation
  • 4K RAM expander card
  • KIM-4 emulation with 8K RAM expander card (thus total address space 16K)
  • Revision E ROMs built-in, so you don’t have to find a pirated set download them from your own KIM

KIM UNO

The KIM Uno, designed and produced and sold by Oscar Vermeulen, is a very simple “open-source hardware” project that started out as a replica of the classic 1976 KIM-1 computer. Later, Apple-1 compatibility and a 6502 programmable calculator mode were added, plus a built-in ‘early 6502 software gems’ collection.
It costs about $10 in commonly available parts (board & parts without case or power supply), but provides a faithful KIM-1 ‘experience’. An Arduino Pro Mini mounted on the back contains all the logic and memory.

I have two versions: the ‘original’ and the later redesigned version, Software-wise the same, with on the top of the PCB room for power connector (GND, +5V or a 9V battery) and a slide switch. , I use them with an USB cable (the blue one of this page) for power and the serial interface provided.

The software already works on the blue pill STM32 or an ESP32, with manual cabling to the keyboard/display and I expect a new version of the PCB for the ESP32.

The software for the serial interface (you really need a good serial terminal emulator, like Minicom or Tera Term) can be used on any Arduino Uno. After power on  it delivers a simulation of the LED display or the real KIM TTY teletype interface (a bit broken in the current version).

All well described on the pages of Oscar and well worth the money for a ‘6502 SBC’ experience or a Cosmac 1802 with a small LCD.

KIM-1 emulator in JavaScript

By Code Monkey King, web browser based, run it here.

Emulates the keypad/LED display part only. Hardware emulation of LED display. Emulates KIM-1 LED display very well!
Some handy tools like 6502 assembler, paper tape format converter and hexdump generator
No TTY, limited RAM.
Code on github

KIM-1 hardware information relevant to emulation

RAM ROM I/O
OVERVIEW OF KIM-1 MEMORY MAP fully extended (A-K connected!)
0000-1400 RAM
1600-1700 free, can be RAM or I/O or ROM
1700-173F I/O and timer of 6530-003
1700 Port A,
1701 DDR Port A
1702 Port B,
1703 DDR Port B
1704- timer
1740-177F I/O and timer of 6530-002, used by  LED/Keyboard/tape
1740 Port A,
1741 DDR Port A
1742 Port B,
1743 DDR Port B
1744- timer
1780-17BF RAM from 6530-003  , free for user applications
17C0-17FF RAM from 6530-002  , free for user except 0x17E7-0x17FF
1800-1BFF ROM003
1C00-1FFF ROM002
emulator  mirrors last 6 bytes of ROM 002 to FFFB-FFFF:
2000 - DFFF RAM in simulator
F000-       ROM in simulator for patching KIM-1 ROM serial I/O and keypad
FFFA, FFFB - NMI Vector  copy of KIM-1 ROM ROM002
FFFC, FFFD - RST Vector  copy of KIM-1 ROM ROM002
FFFE, FFFF - IRQ Vector  copy of KIM-1 ROM ROM002
| ADDRESS |      AREA      | LABEL |              FUNCTION               |
|         |                |       |                                     |
|  00EF   |                | PCL   | Program Counter - Low Order Byte    |
|  00F0   |                | PGH   | Program Counter - High Order Byte   |
|  00F1   |     Machine    | P     | Status Register                     |
|  00F2   |     Register   | SF    | Stack Pointer                       |
|         |     Storage    |       |                                     |
|  00F3   |     Buffer     | A     | Accumulator                         |
|  00F4   |                | Y     | Y-Index Register                    |
|  00F5   |                | X     | X-Index Register                    |
|  1700   |                | PAD   | 6530-003 A Data Register            |
|  1701   |   Application  | PADD  | 6530-003 A Data Direction Register  |
|  1702   |        I/O     | PBD   | 6530-003 B Data Register            |
|  1703   |                | PBDD  | 6530-003 B Data Direction Register  |
|  1704   |                |       | 6530-003 Interval Timer             |
|         | Interval Timer |       |   (See Section 1.6 of               |
|         |                |       |    Hardware Manual)                 |
|  170F   |                |       |                                     |
|  17F5   |                | SAL   | Starting Address - Low Order Byte   |
|  17F6   |   Audio Tape   | SAH   | Starting Address - High Order Byte  |
|  17F7   |   Load & Dump  | EAL   | Ending Address - Low Order Byte     |
|  17F8   |                | EAH   | Ending Address - High Order Byte    |
|  17F9   |                | ID    | File Identification Number          |
|  l7FA   |                | NMIL  | NMI Vector - Low Order Byte         |
|  l7FB   |                | NMIH  | NMI Vector - High Order Byte        |
|  l7FC   |   Interrupt    | RSTL  | RST Vector - Low Order Byte         |
|         |    Vectors     |       |                                     |
|  17FD   |                | RSTH  | RST Vector - High Order Byte        |
|  l7FE   |                | IRQL  | IRQ Vector - Low Order Byte         |
|  17FF   |                | IRQH  | IRQ Vector - High Order Byte        |
|  1800   |                | DUMPT | Start Address - Audio Tape Dump     |
|         |  Audio Tape    |       |                                     |
|  1873   |                | LOADT | Start Address - Audio Tape Load     |
|  1C00   | STOP Key + SST |       | Start Address for NMI using KIM     |
|         |                |       | "Save Nachine" Routine (Load in     |
|         |                |       | 17FA & 17FB)                        |
|  17F7   |   Paper Tape   | EAL   | Ending Address - Low Order Byte     |
|  17F8   |    Dump (Q)    | EAH   | Ending Address - High Order Byte    |
KIM-1 hardware
PA SAD, SADD
PB SBD  SBDD
PB0 TTY data out (can block  hardware TTY echo)
PB1 - PB4 outputs led select via 74145 6 leds O4 -O9 on/off, keypad O0-O3
PB5 TTY/audio control (block/allow inputs)
can block TTY input and audio input
PB7 audio in/out
PA0-6 keypad + LED segments
PA7 TTY data in
74145
PB1 - PB4 to ABCD inputs
Outputs
O4 to O9 LED on U18 to U23
O0 to O3 to key rows 
PB   PB1 PB2 PB3 PB4                   													  
A   B   C   D 
00-01   0   0   0   0  00 O0 keyrow 0      
02-03   1   0   0   0  01 O1        1     
04-05   0   1   0   0  02 O2        2 
06-07   1   1   0   0  03 O3        3
08-09   0   0   1   0  O4 LED enable U18
0A-0B   1   0   1   0  O5            U19
0C-0D   0   1   1   0  O6            U20
0E-OF   1   1   1   0  O7            U21
10-11   0   0   0   1  O8            U22
12-13   1   0   0   1  o9            U23		
Inits
750  1E8C  A2 00     INIT1   LDX   #$00      
751  1E8E  8E 41 17          STX   PADD      FOR SIGMA USE SADD	
PAx is input
752  1E91  A2 3F             LDX   #$3F
753  1E93  8E 43 17          STX   PBDD      FOR SIGMA USE SBDD
3F = 00111111
PB0 - PB5 output, PB7 input
754  1E96  A2 07             LDX   #$07      ENABLE DATA IN
755  1E98  8E 42 17          STX   SBD       OUTPUT
PB0 = 1 high TTY, stopbit
PB1 -PB2 high (keypad?)
PB5 low ; allow input
PB7 low : audio quiet
Print OUTSP
toggle PB0 via read SBD, AND $FE, OR $01 and write SBD, end with 1 
** SUB TO DETERMINE IF KEY IS DEPRESSED OR 
;          CONDITION OF SSW KEY NOT DEPRESSED OR
805                  ;          TTY MODE  A=0
806                  ;          KEY DEPRESSED OR KB MODE  A NOT ZERO
807  1EFE  A0 03     AK      LDY   #$03      3 ROWS
808  1F00  A2 01             LDX   #$01      DIGIT 0
809  1F02  A9 FF     ONEKEY  LDA   #$FF
810  1F04  8E 42 17  AK1     STX   SBD       OUTPUT DIGIT
via 74145 Start with digit 0, continue with next row 
811  1F07  E8                INX             GET NEXT DIGIT
812  1F08  E8                INX 
813  1F09  2D 40 17          AND   SAD       INPUT SEGMENTS
and key pressed to A	
814  1F0C  88                DEY 
815  1F0D  D0 F5             BNE   AK1
816  1F0F  A0 07             LDY   #$07
817  1F11  8C 42 17          STY   SBD
back to INITS state
818  1F14  09 80             ORA   #$80
819  1F16  49 FF             EOR   #$FF
set high bit and inverse all
A=0 no key
820  1F18  60                RTS 
822  1F19  A0 00     SCAND   LDY   #$00      GET DATA                      1F19
823  1F1B  B1 FA             LDA   (POINTL),Y  SPECIFIED BY POINT
824  1F1D  85 F9             STA   INH       SET UP DISPLAY BUFFER
825  1F1F  A9 7F             LDA   #$7F      CHANGE SEG
826  1F21  8D 41 17          STA   PADD      TO OUTPUT
PA0 - PA6 output
827  1F24  A2 09             LDX   #$09      INIT DIGIT NUMBER start with U18
828  1F26  A0 03             LDY   #$03      OUTPUT 3 BYTES 6 hex numbers
829  1F28  B9 F8 00  SCAND1  LDA   INL,Y     GET BYTE
830  1F2B  4A                LSR   A         GET MSD high byte
831  1F2C  4A                LSR   A
832  1F2D  4A                LSR   A
833  1F2E  4A                LSR   A
834  1F2F  20 48 1F          JSR   CONVD     OUTPUT CHAR
835  1F32  B9 F8 00          LDA   INL,Y     GET BYTE AGAIN
836  1F35  29 0F             AND   #$0F      GET LSD low byte
837  1F37  20 48 1F          JSR   CONVD     OUTPUT CHAR
838  1F3A  88                DEY             SET UP FOR NEXT BYTE
839  1F3B  D0 EB             BNE   SCAND1
840  1F3D  8E 42 17          STX   SBD       ALL DIGITS OFF 
X = 0?
841  1F40  A9 00             LDA   #$00      CHANGE SEGMENT
842  1F42  8D 41 17          STA   PADD      TO INPUTS
PA0-PA7 inputs
843  1F45  4C FE 1E          JMP   AK        GET ANY KEY
844                  ;       ** CONVERT AND DISPLAY HEX (USED BY SCAND ONLY)**
show character on LED 
845  1F48  84 FC     CONVD   STY   TEMP
846  1F4A  A8                TAY             SAVE Y
847  1F4B  B9 E7 1F          LDA   TABLE,Y   USE CHAR AS INDEX
848  1F4E  A0 00             LDY   #$00      LOOKUP CONVERSION
849  1F50  8C 40 17          STY   SAD       TURN OFF SEGMENTS
PA0-PA7 0 
850  1F53  8E 42 17          STX   SBD       OUTPUT DIGIT ENABLE
X = LED number U18-U23 decimal  to 74145
851  1F56  8D 40 17          STA   SAD       OUTPUT SEGMENTS
write segment from table to LED
852  1F59  A0 7F             LDY   #$7F      DELAY 500 CYCLES
853  1F5B  88        CONVD1  DEY   
854  1F5C  D0 FD             BNE   CONVD1
855  1F5E  E8                INX             GET NEXT DIGIT NUMBER
856  1F5F  E8                INX             ADD 2
857  1F60  A4 FC             LDY   TEMP      RESTORE Y
858  1F62  60                RTS
GETKEY > 15 ? no key
14 = PC
10 = addressmode
11 - Datamode
12 = step
13 = RUN
0 - F - hex digit
/* RIOT2 explanation: better emulation of LED display through simulated hardware rather than 2014's ROM patch
*  
*  The RIOT-002 chip is used to drive the LEDs, read the keypad, and control TTY and tape.
*  KIM Uno only emulates the LED driver and timer hardware; the keypad, TTY and tape are emulated on a higher abstraction level in the ROM
*  
*  On the real KIM-1, the keyboard columns are PA0-PA6 and the rows are selected through 
*                     the display  columns are PA0-PA6 and the segment led is decoded from PB 0000 1110
*                     teletype mode is detected when  = 1.
*                     teletype uses PB0, PB5, PA7
*  
*  1740 Data port A            Selects pattern to show on a segment LED (PA0-6) and TTY (PA7)
*  1741 Data Direction port A  Are the GPIO pins set to input or output?
*  1742 Data port B            Selects which of the 6 segment LEDs is lit up (PB1-3), 
*                              and also: PB0 (TTY), PB4 ???, PB5 (TTY/tape input?), PB 6(RIOT internal, ChipSelect), PB7 (tape output)
*  1743 Data direction port B  Are the GPIO pins set to input or output?
*/
void write1740(void)            // ======== PA pins - set the individual LED segments on or off
{
//riot2regs.ioPAD &= 0x7F;    // only the bits for the 7 LEDs in a segment LED
for (uint8_t ibit=0; ibit<7; ibit++) 
digitalWrite(kCols[ibit], (riot2regs.ioPAD & (1<<ibit))==0);       // set the bit, inverted through ==0
}
void write1741(void)            // ======== Data direction register for PA
{
for (uint8_t ibit=0; ibit<7; ibit++) 
if ( riot2regs.ioPADD & (1<<ibit) )
pinMode(kCols[ibit], OUTPUT);           // set pin to output
else
pinMode(kCols[ibit], INPUT);           // set pin to output
}
void write1742(void)            // ======== PB pins - set which of the 6 segment LEDs is lit up
{
uint8_t led = ((riot2regs.ioPBD - 9) >> 1) & 0b111; // identify the selected segment LED
for (uint8_t iLed=0;iLed<6;iLed++)       // set GPIO pins of all 6 KIM-1 LED segments
{ if (iLed==led)    
digitalWrite(ledSelect[iLed], HIGH); // power up this segment LED
else
digitalWrite(ledSelect[iLed], LOW);  // power down the other segment LEDs
}
}
void write1743(void)            // ======== Data direction register for PB
{
// TEMP: all LED pins are set to output; there's no functionality we need except that.
for (uint8_t iLed=0;iLed<6;iLed++)
pinMode(ledSelect[iLed], OUTPUT);  
}
} // end of C segment

Telefonbuch

Found in Hobbycomputer #1 (c) 1980 Herwig Feichtinger (of EMUF fame!) improved by Nils Andreas, a phonebook
In fact, it is a searchable text database. Full article here

The program is written, probably by hand, Herwig Feichtinger in the German magazine Hobbycomputer, Issue 1.

On the github page of Nils you can find source and executables.

Hobby Computer magazine

A German magazine, from Franzis Verlag. Sonderheft der ELO Funkschau Elektronik


Hobbycomputer 1

KIM-1 articles llike Telefonbuch. See also the page on Telefonbuch restauration.

 

 

 

 

 

 

Hobbycomputer 2

KIM-1 and more general 6502 articles.

 

 

 

 

 

 

Telefonbuch

Found in Hobbycomputer #1 (c) 1980 Herwig Feichtinger (of EMUF fame!) improved by Nils Andreas, a phonebook

On the github page of Nils you can find source and executables.

In fact, it is a searchable text database.

The program is written, probably by hand, Herwig Feichtinger in the German magazine Hobbycomputer, Issue 1. Available on archive.org.

I took the source as typed in by Nils, added the comments from the (see below) listing in the article and made sure it was binary compatible with the listing. There are some problems with the first entry in the database.

Source, listing, article, binary, papertape of original version of Telefonbuch

; Target assembler: TASM 
;*****************************
;* Telefonbuch               *
;* (c) 1979                  *
;* Herwig Feichtinger        *
;*****************************
; typed in and checked by Nils Andreas
; comments entered from German listing into source
; checked for being binary compatible with original listing in HobbyComputer 1 1979
;
; Note that getch in KIM-1 returns with Y = $FF, used in this program to save two bytes?
; Testcase for the KIM-1 Simulator, which now emulates this getch behaviour
;
; Hans Otten, 15 december 2021
; 
CR     =       $0d             ; carriage return
esc     =       $1b             ; escape
crlf    =       $1e2f           ; KIM-1 print cr 
getch   =       $1e5a           ; KIM-1 read char for tty
space   =       $1e9e           ; KIM-1 print space tty
outch   =       $1ea0           ; KIM-1 print car on tty
incpt   =       $1f63           ; increment pointer
;
; zeropage
;
savy    = $f9
tablep  = $fa                   ; pointer into table 
bufferp = $df                   ; buffer
table   = $0200                 ; table starts here
;
.org    $0000
;
start:   lda     #(table & $ff) ; low byte table address
sta     tablep
lda     #(table >> 8)  ; high byte table address 
sta     tablep + 1     ; 
ldx     #$17           ; 17 bytes clear
lda     #$00
buffer:  sta     bufferp,x      ; clear buffer
dex
bne     buffer
;         
read:    jsr     getch          ; get ascii character
cmp     #esc           ; escape? 
bne     chkend         ; no
iny                    ; yes, y = 0
chkfre:  jsr     incpt          ; increment table pointer 
lda     (tablep),y     ; query buffer
bne     chkfre         ; free space in buffer?
input:   jsr     getch          ; get ascii character
iny                    ; y=0
cmp     #esc           ; escape?
beq     start          ; yes, back to begin
sta     (tablep),y     ; no, store in table
jsr     incpt          ; increment table pointer
jmp     input          ; and again
chkend:  cmp     #CR            ; return?
beq     zzz            ; yes, line ready
sta     bufferp +1,x   ; no, store char in buffer
inx                    ; increment buffer index
cpx     #$15           ; is $15?
bne     read           ; next character
;
zzz:     nop                    
nop
;
newline: jsr     incpt          ; table after return
ldy     #$00           ; search for character
lda     (tablep),y     ; in table           
beq     printquest     ; 
cmp     #CR            ; found?
bne     newline        ; no, search again
found:   ldx     #$00           ; yes, compare character in table
compbuf: iny                    ; with character in buffer
lda     bufferp +1,x   ; no, compare table and buffer
beq     printline      ; show it
lda     (tablep),y
cmp     #CR            ; return?
beq     zzz
cmp     bufferp +1,x   ; next character
bne     found
inx
bne     compbuf
;         
nop
nop
;
printline:
jsr     crlf           ; new line
ldy     #$01
loadchar:
lda     (tablep),y     ; load character from table
beq     printquest     ; zero is ready
cmp     #CR            ; return?
beq     zzz            ; end of table entry
sty     savy           ; save Y
jsr     outch          ; and print character
ldy     savy
iny                    ; increment Y, next
bne     loadchar       ; load new character
printquest:
jsr     crlf           ; print return
lda     #'?'           ; print ?
jsr     outch          ; 
jsr     space          ; print space
jmp     start          ; return
;
.end

Here the pages where the program is described and the listing shown.

Update to the KIM-1 Simulator

Nils, a very enthousiast PAL-1 user discovered in an old German magazine, 1979, HobbyComputer 1, a small phonebook program for the KIM-1.
It is a command line utility, extremely small and quite clever. See the post about it here.

So he entered the code in assembler and did some tests on his PAL-1 (it worked) and in the KIM-1 Simulator, which was not working.
He found the ‘database’ corrupted.

Of course I had to look at it and see what was going on. It had to be something about using zeropage pointers into the database.
And it was. In the source an instruction appeared:

INY  ; Y = 0

followed by an indirect addressing, Y into the database and preceded by a call to getch, reading a character from the keyboard.
Y was not used in the program before, so in the Simulator it was uncertain what the value was.

GETCH is known to destroy the Y register, delivering the character in register A. How is unspecified.
In the KIM-1 Simulator the KIM-1 GETCH is patched to the ACIA routines of the emulated 6850 serial interface.
Those routines do not use Y, so it is left untouched.

So time to study the KIM-1 routines. In the delay a bit routine the Y register is filled with the final state of a counter, TIMH.
It looks like the decrement ends with the value $FF, when the BPL becomes false, the whole purpose of the use of Y seems to determine that end of the loop?

1ED4  AD F3 17  DELAY   LDA   CNTH30                           
1ED7  8D F4 17          STA   TIMH
1EDA  AD F2 17          LDA   CNTL30
1EDD  38        DE2     SEC   
1EDE  E9 01     DE4     SBC   #$01 
1EE0  B0 03             BCS   DE3  
1EE2  CE F4 17          DEC   TIMH
1EE5  AC F4 17  DE3     LDY   TIMH
1EE8  10 F3             BPL   DE2
1EEA  60                RTS

Anyway, the KIM-1 Simulator 0.9.4. GETCH routine now returns with Y=$FF and the phonebook program seems to work.

DOS/65 sources

Different versions (from 2008 to 2021) of this CP/M for the 6502 system by Richard Leary hosted here.

Work in progress, hope to get more information from Richard!

with his permission

DOS/65

An operating system for the 6502. Published here with permission by the author Richard Leary, 2021.
In the following text “I” is Richard Leary.

What you will find here:

License
“DOS/65 software and documentation are provided as shareware for non-profit, educational, or private use. Any other use is prohibited without approval of Richard A. Leary.”

The DOS/65 V3 ROM software and all other DOS/65 software are free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the license, or any later version.

Introduction

Of all the problems which plague the 6502 enthusiast, the lack of a low-cost, compatible operating system is one of the most critical. The operating system, the media, and the floppy disk hardware of the common 6502 systems (Commodore, Apple, OSI, Atari, and AIM/SYM/KIM) are not compatible and can not readily be interfaced to systems other than the original. This incompatibility has been the major factor which has prevented the 6502 machines from achieving the status that other systems have achieved.

The challenge then is to establish a standard which minimizes cost, allows easy use by different systems, and ultimately will help make the 6502 and its derivatives the universal processor it is capable of being.
What Richard has done is attack the software side of the problem in order to make any 6502 system a truly workable disk based system. In addition a degree of compatibility is now possible not only between 6502 systems but with large parts of the world of CP/M systems. The result of my efforts is a system of software which Richard has named DOS/65.

DOS/65 itself is a software system which has the same basic structure as the foremost 8080/Z80 software standard, CP/M, and is file compatible with CP/M Version 1.4 and later versions. Since the machine language software obviously can not be compatible between the 8080/Z80 and the 6502, the term “file compatible” simply means that a DOS/65 diskette could be inserted into a CP/M system or vice-versa and the files manipulated in every way except actual execution.

The system could not tell the difference between files created on the host versus those created on a CP/M system. For example a BASIC-E source program which had been created, edited, and used on a CP/M system could be used on a DOS/65 system using the BASIC-E/65 compiler and interpreter with at most only minor changes. Data files of all forms could be exchanged between systems without restriction

The reasons for selecting CP/M as the standard are simple. CP/M has many features including:

  • Nearly total hardware independence
  • Easy access to operating system primitives
  • Easy alteration to accommodate system unique characteristics
  • Large library of compatible software that in many cases can be ported to DOS/65
  • Simplicity

None of these claims are overwhelming in themselves, but taken as a whole they stand as a compelling reason to use CP/M as the format and structure standard for a 6502 operating system.

CP/M is a trademark of Caldera.

Version 3, upto 2020

DOS/65 V3 can run from a read-only memory (ROM). To prove the concept I’ve implemented the ROM version on two different platforms. The first is the WDC W65C02SXB and the second is Daryl Rictor’s SBC2. In both cases I built an auxiliary board using Andre Fachat’s VIA-based SPI interface design. Both platforms are up and running with a micro-SD card as the storage media. Each system has four 8 MB drives provided by the micro-SD card. The interfaces are implemented as four layer printed circuit boards from Express PCB. Because the connector configuration on the two platforms are slightly different each is a unique interface.
Changes associated with DOS/65 V3.0 are small in number, they significantly improve the utility of DOS/65 especially for those users having some sort of high capacity mass storage device attached to their system.
The key changes are:

  • PEM and CCM changes to implement a CP/M 2.2 compatible “USER” area concept for storage devices.
  • Addition of a COPY3 transient that is able to set source and destination USER areas for any file copy operation.
  • CCM changes to implement a CP/M compatible batch command processing capability.
  • Addition of the CP/M compatible SUBMIT transient command to initiate batch command processing by CCM.
  • Change to SYSGEN to allow either .KIM or .HEX input files for the BOOT and SIM modules used when building a new system.
  • Use of the IOSTAT defined but previously unused storage location as a means of exchanging USER and DRIVE data between CCM and SIM.

All software has used 6502 op-codes and addressing modes. No 65C02-only code has been used.

Downloads:
Documents DOS/65 V3
Sources DOS/65 V3

DOS/65 for OSI

From http://osiweb.org/osiforum/viewtopic.php
Files come form here: https://github.com/osiweb/DOS65/tree/master/DOS65_v2.1

I released (sold in those days) a version for 5.25 inch drives for OSI and an eight inch OSI version. Development of these was frozen in 1986 as there was not enough demand to continue OSI support. I did normally ship DOS/65 as a two disk start up where the first disk was used under OS65D. I did the ROM because for all practical purposes I never used OS65D. If I remember correctly the 5.25 inch version need 9 or 10 diskettes and the 5 inch version a lot less because of the increased diskette capacity.

The SIM (system interface module) code – that is what talks to the hardware – was straightforward and could easily be expanded to handle larger capacity drives. I strongly recommend that for 5.25 inch systems.

DOS/65 manages disk use by dealing with 128 byte logical records. However because of the characteristics of the OSI floppy disk controller the physical sectors are full tracks and a full track is what is read from or written to the diskette. The SIM code maps logical records from or into the full track buffer. A physical track for the standard 5.25 in drive is 2048 bytes. Every track on a DOS/65 5.25 inch diskette is 2048 bytes long.


Downloads:
Documents OSI DOS/65
Sources OSI DOS/65

Version of 2008 on z80.eu: C64

C64 port of DOS/65
“What I (Richard A. Leary) have done is attack the software side of the problem in order to make any 6502 system a truly workable disk based system. In addition a degree of compatibility is now possible not only between 6502 systems but with large parts of the world of CP/M systems. The result of my efforts is a system of software which I have named DOS/65.”
Richard’s implementation is initially made for S-100 based systems, but he began to port it to the C64 also (see below).
DOS/65 has a lot of CP/M look-alike commands for the command line and also some applications like BASIC-E included.
Of course some differences between CP/M-80 and DOS/65 exist – the lowest memory areas (e.g. the “zero page”) are not usable for the TPA, so the usable system memory area starts at a higher address (e.g. $0400).

Richard has prepared two .D64 images
DOS65-1C.D64 (Bootdisk with updated SIM C64S304.ASM)
DOS65A.D64 (Blank disk)

Load the bootdisk with: LOAD “DOS65”,8,1:RUN

Downloads:
Sources DOS/65 V2 2008
Documents DOS/65 V2 2008

DOS/65 V3.03 65C02 version by Kevin Maier

Kevin, a.k.a floobydust enhanced the DOS/65 V3 system to his 65C02 system.

See the topics on the retrobrew forum 6502.org and his github repository.

Port DOS/65 to new hardware

What makes CP/M and DOS/65 special is the separation between hardware and the operating system with a well defined interface. In CP/M terms this is the BIOS, the only part to implement for new hardware. In DOS/65 system this is the interface module (SIM). Various examples are in the sources archives.
This part of the “V3 ROM Supplement”, see the V3 section illustrates how this works in DOS/65.

The first steps in implementing the ROM version of DOS/65 on a new platform are:

  • First, determine functions to be provided by the OEM monitor or other software that can support the overall DOS/65 processing needs. For example in the case of the W65C02SXB the only functions that would make sense to use for DOS/65 are the character I/O functions, i.e., those that support console I/O. The W65C0SXB has no storage I/O capability built into it so there was nothing to exploit in designing the system.
  • Second determine what resources are essential to performing the functions previously assessed as required. Then either allocate existing resources or acquire additional resources. That is exactly what was done for the SPI/SD interface. It did not exist but there was a VIA and a VIA was what was used by Andre Fachat in his elegant SPI/SD interface.
  • Third, test the resources assigned to ensure that the intended functions are provided correctly. For this step a standalone software package is recommended.
  • Finally, build the operational software around the resources and functions tested and conduct further testing as the software is built. This is precisely the process that was followed in the development of the SPI/SD interface and the ROM version of DOS/65. One key advantage of such a process is that problems are found when the complexity of the software is limited thus allowing easier debugging. It does not mean that problems will not be found at the top level but discovery should be at a sufficiently low level to allow clear resolution.

Implementation is straightforward. The basic DOS/65 software structure need not change. However, the specific addresses of functions may have to change as a function of the platform monitor or other software elements. The process of implementing D0S/65 for the SBC2 drew heavily upon the experience involved in producing the version for the WDC SXB but was actually simpler because of the capabilities provided by the SBC2 monitor.

The SD interface for the W65c02SXB based on Andre Fachat’s v1.1 design using a VIA and three eternal ICs.

nhyodyne modular backplane system

DOS/65 V2 as implemented on the nhyodyne modular backplane system.

More information in the 6502proc folder at this github page.

KIM-1 Diagnostic board

Dwight Elvey designed and programmed a diagnostic board for the KIM-1, to determine what might be wrong with the KIM-1
The board switches off the 6530 ROMs and one can run tests on teh onboard ROM, looking for for defective RAM, defective LED display, defective 6530 ports.

Here I present the complete design of the board, with help and permission of Dwight Elvey, Santo Nucifora and Liu Ganning.