PTASM, a modern bug fixed crossplatform version of TASM32 for 6502

I have been using TASM32 for a very long time. A simple DOS based assembler, called from Notepad++ as a simple IDE setup.
Convenient for small 6502 projects, let it create Intel Hex, load in the Simulator, test and debug.
Papertape format needed a further step, with the Convert8bitHex programs (CLI or GUI now)

It has some things that could be better
– simple macro facilities
– the MOS Technology (papertape) output is broken
– it does not recognize the ‘>’ and ‘<' operators to get the low or high part of a word - only for DOS, not crossplatform I do not care that much about the macro facilities. For small projects it is good enough. For bigger projects there is the CC65 suite or LLVM-6502. The other three are annoying. I wanted a replacement that fixed those last three issues. And since I only use it for 65(C)02 the table setup could go. Also only Intel hex and MOS Technology papertape object code. So PTASM V1.0 is born. Written in portable Freepascal, a CLI command line assembler for the 65(C)02.

PTASM 6502/65C02 Assembler. Version 1.0
Usage: ptasm -65 [-options ...] src_file [obj_file [lst_file [exp_file [sym_file]]]]
Options:
  -65      6502 instruction set (default). -t65c02 = -65 -x3
  -a[mask] Assembly checks: 2=unused data in MS byte, 4=duplicate labels (default 4)
  -c       Object file written as one contiguous block
  -dname   Define a macro (-dname=value gives it a value)
  -e       Show source lines after macro expansion
  -fXX     Fill memory with byte XX (hex)
  -g0      Intel hex object (default)
  -g1      MOS Technology hex (paper tape) object, same as -m
  -h       Hex table of the object code in the listing
  -i       Ignore case in labels
  -l[al]   Label table in the listing (a=all labels, l=long form)
  -m       MOS Technology hex (paper tape) object
  -oXX     Bytes per object record (hex, default 18 = 24 bytes)
  -p[n]    Page the listing, n lines per page (default 60)
  -q       Quiet: no listing file
  -s       Write a symbol table file
  -x[mask] Extended instructions: -x3 65C02, -x5 R65C00/21 MUL, -x = all
  -y       Time the assembly
Default files: src.obj, src.lst, src.exp, src.sym
Environment:   TASMOPTS holds default options

Sofar it has created identical object, listings and symbol files as TASM32. I will keep on testing it side by side.

MOS TECH 9 DIGIT BASIC FOR KIM V1.1 or KB-9

This is my story about a first and a second version of KB-9 or, as it is officially called,
MOS Technology 6502, 9 DIGIT BASIC by MICROSOFT, Copyright 1977
MOS TECH 9 DIGIT BASIC FOR KIM COPYRIGHT 1977 BY MICROSOFT, 1977
Inside the binary you can find the version number: V1.1.

KB-9 cassette

KB-9 cassette

In 1978 I bought KB-9 for my KIM-1. It came from Johnson Computers, a distributor for Microsoft.
I had just upgraded the memory and had built a simple video terminal (32 characters, 24 lines, uppercase only).
As you can see in the image above, it was serial number 2167, ID 01, $2000-$4260, starting at $4065.
Reading the tape into my KIM-1 was quite a task. I had to adjust the azimuth of the player head for a sharp-pitched sound, tune the PLL on the KIM-1 and adjust the volume during reading, since part of the tape was quite soft in the middle. The recording was in the normal KIM-1 audio format, so it took a long time to load!
After many tries I had it in memory without loading errors and immediately made a new recording. In hindsight, I recorded a bit more memory than required; there are unused data bytes at the end of this dump. This backup tape was recorded in Hypertape 6x, which loads much faster. The backup tape was stored safely and a working copy was used to play with BASIC.

Fast forward to 2004.
My KIM-1 had not been used as my main computer since 1985, but I had kept many of the audio cassettes. With a quality audio cassette recorder and a high-quality sound card in my PC, I dumped all the cassettes to WAV files on the PC. The format is 22050 Hz, 8-bit mono, uncompressed. I chose this format because I had found a DOS utility called KIMTAPE, written in Ed’s DX-Forth, that could convert a WAV file to binary and the other way around. It worked well, and I now had all the cassettes I had kept in binary format.

tape:    tones 2455/3238 Hz, bit 1,38 ms, HYPERTAPE 6x

Program 01  address 2000  checksum OK  8816 bytes

As you can see, the dump is 8816 bytes, while the original recording, $2000-$4260, is $2261 = 8801 bytes. That is 15 bytes too many, recorded by me! These extra bytes are in all binaries of KB-9 on the internet …

My tape collection is the origin of many programs that are now available and can run on the KIM-1 and its clones.

All KB-9 versions floating around the web come from this backup cassette dump I made. The first time it showed up was when Vince Briel made the MicroKIM; my website was already up and (with my help) he added KIM-1 software to the kit.
Another place it showed up is the excellent Create your own Version of Microsoft BASIC for 6502 by Michael Steil: a disassembled, commented and rebuildable source of many early Microsoft BASICs for the 6502, including my KIM-1 KB-9.
Derivatives of KB-9 V1.1 were now easy to make, so V1.2 and V2.0 are now the best versions to run on the KIM-1.

2026, a second dump of KB-9!
I had never seen another dump of KB-9. A photo of an audio cassette showed up, but there was no recording to dump. More versions of the manual, yes, but the tapes were lost.
Until this summer! My friend Gerben Voort found an Elektor Junior, and with it came some audio cassettes. One of them is a KB-9 tape!

KB-9 tape serial number 233

The label states $2000-$437D, which is larger than my original version. Is that a different version?
Extra page in the KB-9 manual
The manual has an extra page I had not seen before! Hypertape support? This must be a later version than mine? But the start location is the same as the original if you do not want Hypertape?

In October I visited Gerben and he lent me the tape. I also got a cassette player.
Then I spent several days dumping the tape directly to the PC as a WAV file. I fought with dirty recorder heads, with the PC resetting the microphone input options (which did horrible things to the audio), and with learning Audacity to export a WAV file suitable for the old KIMTAPE running in DOSBox (it is too old for a modern PC). And it kept on failing!
KB-9 tape in Audacity

So I made a new version of KIMTAPE in Free Pascal. It is also a command-line utility, but cross-platform, and with much more powerful routines to detect the bytes in the audio.
In the end, a combination of three different recordings on two PCs, varying volume and tone control, and the power of the new KIMTAPE resulted in a dump with a correct checksum.

KIMTAPE output for the KB-9 tape

The second dump
I named the second dump KB9SN233. I loaded it into the KIM-1 Simulator and it runs. It is the same version, V1.1.
The next step was to see what had changed. WinMerge showed the differences between the two versions. As expected, KB9SN233 has extra bytes at the end.
Differences between KB9V11AA and KB9SN233
But as you can see, two other bytes were different. Both had bit 5 flipped. The checksum was OK, but the two bytes were wrong.

The first was in the text SiN, which had to be SIN (uppercase I instead of lowercase i). The second, further on, was $40 (RTI), which had to be $60 (RTS) in the Hypertape return (the full source is shown later).
Flipping these bits back made sense: the checksum calculation in KIM files does not detect these errors, because one flip adds $20 and the other subtracts $20, so they cancel out. KIMTAPE was happy with the repaired dump and its good checksum.

The BEQ/BNE bug

There is another byte that differs between the two versions: at location $2AEE, KB9SN233 has F0 instead of D0. This is not a reading error but a deliberate patch in this version.
From the pagetable source:

; BUG: The beq/bne L2AF8 below is supposed
; to be always taken. For this to happen,
; the last load must be a 0 for beq
; and != 0 for bne. The original Microsoft
; code had ldx/ldy/bne here, which was only
; correct for a non-ZP INPUTBUFFER. Commodore
; fixed it in CBMBASIC V1 by swapping the
; ldx and the ldy. It was broken on KIM,
; but okay on APPLE and CBM2, because
; these used a non-ZP INPUTBUFFER.
; Microsoft fixed this somewhere after KIM
; and before MICROTAN, by using beq instead
; of bne in the ZP case.

My V1.1 KB-9 for the KIM-1 has this bug. In KB9SN233 the bug has been fixed!

Conclusion: apart from the BNE/BEQ bugfix and the extra code at the end, KB9V11AA and KB9SN233 are identical from $2000 to $4260!

The extra code

I disassembled the extra code after $4260. It consists of a template Hypertape routine, a patch to the JSR $1800 (the KIM audio dump routine) at $27EE, a routine that moves Hypertape to $0200 or $0300, and patches to Hypertape for the page it lands on.

See the KB-9 page for the dumps and the source code of the Hypertape extension.

KIMTAPE, convert audio datafiles

A utility to convert an audio file with data created with a KIM-1 or clones to binary and to create an asuio file from a binary.
These are KIM-1 audio cassette data files as described in the KIM-1 User manual.

KIMTAPE version 1.0  (Free Pascal port of KIMTAPE 0.5)

Use:  KIMTAPE [options] infile[.typ] [outfile[.typ]]

-C    console output              -M    make wavefile
-Bn   HYPERTAPE speed  2x 3x 6x   -I    invert wavefile
-U    SYM-1 high speed format     -V    VOC wavefile
-Fn   offset  -127 to 127         -R    RAW wavefile
-Hn   hysteresis  0 to 127        -Ln   leader (sec)
-Gn   timing  -2 to 2             -T    sine tone
-An   load address (hex)          -Dn   prog ID (hex)

Additional options in this version:
-K    classic decoder (zero crossings, as KIMTAPE 0.5)
-En   high tone boost 0..4 (default: automatic)
-N    no automatic DC/level adjust  (-K and SYM-1 decoding)
-Pn   channel  0=mix 1=left 2=right  (decode, stereo files)
-Sn   sample rate: output wavefile (encode, default 22050)
      or RAW input file (decode, default 22050)
-Wn   sample width 8 or 16 bits  (encode, default 8)
-O    overwrite output file without asking

Several recordings of the same tape can be combined:
  KIMTAPE rec1.wav+rec2.wav+rec3.wav outfile

default: decode WAV file, KIM-1 format
         load address=0200, file ID=00

Recording tips

  1. Turn off automatic gain control (AGC) and any “enhancements” on the sound card input. AGC makes the start of a recording overdriven and then fades the level, which damages the first part of the data.
  2. Record at a moderate level with no clipping; 16 bit, 44.1 or 48 kHz, mono or stereo.
  3. Also turn off noise suppression, noise gates and limiters. They cut quiet parts to silence and squash the loud parts.
  4. Record the whole program plus a few seconds of silence after it.
  5. A quiet recording is fine; clipping or a limiter is not.
  6. If KIMTAPE reports a high tone boost, the player’s head is probably not aligned with the recorder that made the tape. Adjusting the azimuth screw for the brightest sound helps.
  7. If one stereo channel is cleaner, select it with -P1 or -P2.
  8. Several recordings of a difficult tape can be combined (+).

VIDEO PLUS card

I acquired a VIDEO PLUS card. A video card for AIM 65 KIM or SYM-1.
This is one of the cards produced by The Computerist (of MICRO journal fame!) in the PLUS range.

A convenient moment to upgrade the pages on the The Computerist. Standard layout, all scans corrected and newly build to PDF’s.Also the program listings are typed in to standard MOS Technology assembler syntax.

post

MEMORY PLUS

MEMORY PLUS: 8K RAM, 8K ROM, VIA 6522, 2716 EPROM programmer

The MEMORY PLUS board is a RAM/ROM expansion board for  KIM-1, SYM-1 or AIM65. Made by the The Computerist.
With up to 8k of RAM, 8k of (EP)ROM and the ability to program EPROMs (2716) this was quite the must have upgrade for anyone who could afford it.

My review of the Memory Plus
May 1979 Radio Bulletin
The Manual in HTML format,
original OCRed by Lee Davison
corrected and enhanced with Appendix A Circuit Diagram by Hans Otten.
Memory Plus manual in color
MEMORY PLUS manual #MP2149
MEMORY PLUS manual #MP2233
MEMORY PLUS sources
Memory test and EPROM programmer

Circuit diagrams (click for larger format)

MEMORY PLUS of Dirk Dral, with 8K Basic in EPROM.

post

Chessmate for the KIM-1

Since I have a well documented source of the Chessmate ROMs and made a VT100 version of Microchess I made a VT100 version of the VT100.

You can download source and papertape version here.

; The Chessmate engine from CHESSMATE.ASM (reconstructed source of
; the 4K ROM, Hans Otten) with the opening book of OPENBOOK.ASM
; (6530-024 RRIOT ROM) included, and the display routines of the
; KIM-1 VT100 version of MicroChess (MCHESSVT2000.ASM).
;
; KIM-1 VT100 version, Hans Otten, 2026
; – output to a VT100 (or compatible) terminal through the KIM-1 TTY
; routines OUTCH and GETCH, KIM-1 in TTY mode, terminal 80×24
; – the board is drawn once and only changed squares are updated
; (a shadow copy of the screen is kept in SHADOW), dark squares in
; reverse video, White at the bottom
; – the LED display, the “check” and “Chessmate loses” LEDs and the
; colour LEDs are shown as text next to the board
; – no sound and no chess clocks (commands C, D and E are gone, there
; is no interrupt routine)
; – the opening book and the game record (RRIOT ROM and RAM in the
; Chessmate) are normal tables in this program
; – the random number that picks the opening is a counter of the
; characters sent and received (the Chessmate reads the RRIOT timer)
; – the move stack (STACK2) starts at $01A0 instead of $01B8, page 1
; is not shared with page zero on the KIM-1

Chessmate for the KIM-1

Since I have a well documented source of the Chessmate ROMs and made a VT100 version of Microchess I made a VT100 version of the VT100.

You can download source and papertape version here.

; The Chessmate engine from CHESSMATE.ASM (reconstructed source of
; the 4K ROM, Hans Otten) with the opening book of OPENBOOK.ASM
; (6530-024 RRIOT ROM) included, and the display routines of the
; KIM-1 VT100 version of MicroChess (MCHESSVT2000.ASM).
;
; KIM-1 VT100 version, Hans Otten, 2026
; – output to a VT100 (or compatible) terminal through the KIM-1 TTY
; routines OUTCH and GETCH, KIM-1 in TTY mode, terminal 80×24
; – the board is drawn once and only changed squares are updated
; (a shadow copy of the screen is kept in SHADOW), dark squares in
; reverse video, White at the bottom
; – the LED display, the “check” and “Chessmate loses” LEDs and the
; colour LEDs are shown as text next to the board
; – no sound and no chess clocks (commands C, D and E are gone, there
; is no interrupt routine)
; – the opening book and the game record (RRIOT ROM and RAM in the
; Chessmate) are normal tables in this program
; – the random number that picks the opening is a counter of the
; characters sent and received (the Chessmate reads the RRIOT timer)
; – the move stack (STACK2) starts at $01A0 instead of $01B8, page 1
; is not shared with page zero on the KIM-1

Chessmate ROM reverse engineered

With the aid of the source of Microchess and some detective work, started several years ago, I now have a more thorough commnted source of the Chessmate ROMs.

You can download here the source of the main ROM and the openings in the 6530-024 RRIOT ROM.
;
; CHESSMATE.ASM – Commodore Chessmate main ROM ($F000-$FFFF)
;
; Microchess 1.5 by Peter Jennings, Commodore Chessmate 1978
; (the same ROM is used in the Novag Chess Champion MK II)
;
; ROM dumps: 4K 6332 ROM 005_2179 (= chessmate.bin)
; early models 2x 2K: 901462-01 ($F000) + 901462-02 ($F800)
; Opening book: 6530-024 RRIOT ROM, see OPENBOOK.ASM
;
; Reconstructed source, Hans Otten, 2022, 2024, 2026
; Information on the RRIOT timer and the opening book by Michael Gardi
; Names of variables and routines follow the original Microchess
; source (KIM-1, 1976) wherever the Chessmate code is the same.

My Chessmate

Microchess for VT100

Microchess for the KIM-1 was one of the first commercial computer games. Sold as listing and later on on cassette.
The program runs on a standard KIM-1, using the hex keyboard and seven segment displays. Peter Jennings did a great job!

I (Hans Otten) have added a VT100 compatible display routine to the original. A lot easier to use, the same program underneath.
Two versions, one for a KIM-1 with RAM above 0400, one for a KIM-1 or clone with RAM above $2000.

Papertape binaries and full source available, with corrected source and comments.

Cubit microprocessor card

Control Universal started as a company selling Rockwell microcomputer products (AIM65). Later on they focussed on Acorn (BBC computer).

On this page information on some Cubit products, the EPROM programmer and the Cubit microprocessor module for AIM 65.

Cubit microprocessor card manual
Thanks to Dick Blok for the scans!

Cubit microprocessor card


Cubit microprocessor card