******************************************************************
***
*** HP 2116A/2115A Computer System
*** 2752A Teleprinter Basic Binary Loader
***
*** Original: 1967
*** This re-creation: Apr 2004 / bhilpert
*** 20 Feb 2008, asm21.pl conversion by Tim Riker
***
******************************************************************
*
* This is a recreation of the Basic Binary Loader for use with the
* 2752A Teleprinter (teletype). This recreation is based on a disassembly of
* the data found in the "Standard Systems Software Operating Manual"
* for the HP 2116A/2115A computer.
*
* The I/O interface board presumably is a 12531A. The program reads
* serial bits from the interface, where the data bit shows up in
* bit 7 of the interface input register. Presumably the interface
* synchronized a bit clock to a received start bit and then set the
* interface flag bit in accordance with the 11 following bit clock cycles.
*
* Input consists of a sequence of blocks terminated by a minimum of 10 null bytes:
*
* = ... 0 0 0 0 0 0 0 0 0 0
*
* where each block is a sequence of bytes:
*
* =
* ... _HI_BYT> _LO_BYT>
*
* = the number of data words in the block.
* The checksum is the sum of the address word and the data words.
*
* Note the channel select code may need to be altered as per system configuration.
*
* Termination codes displayed in T register:
* 77 - normal
* 11 - checksum error
* 55 - addressing/range error
*
******************************************************************
* Configuration
* machine HP21xx
TtyChannel EQU 10B used in 4 places in ReadByte
A EQU 0
B EQU 1
******************************************************************
*
* Start Teleprinter Loader
*
******************************************************************
* org 007700B for 4K of memory
org 017700B for 8K of memory
Start STC 0,C
CLB,RSS
_nextBlock LDB ConstNeg11 look for 10 null bytes
_again INB,SZB terminate if 10 null bytes seen
JMP _loadLength
STC 0
HLT 77B terminated due to end-of-tape
JMP Start repeat if user restarts
_loadLength JSB ReadByte read length byte
SZA,RSS if null then
JMP _again ignore byte, go count down
CMA,INA negate length so we can count up to 0
STA blmLength save length
JSB ReadByte skip a byte
JSB ReadWord read address
STA B B will be checksum, address included
STA blmAddress save address
_wordLoop LDA blmAddress get destination address
CLE
ADA AddrLimit and check for range
SEZ
JMP _errAddress
JSB ReadWord get a data word
ADB A add to checksum
STA blmAddress,I and put it in memory
ISZ blmAddress
ISZ blmLength if blmLength less than 0 then
JMP _wordLoop get next word
JSB ReadWord read checksum
CPB A if checksums match then
JMP _nextBlock OK, go load next block
HLT 11B terminate with checksum error
JMP Start
_errAddress HLT 55B terminate with addressing/range error
JMP Start
*-----------------------------------------------------------------
* Read a Word
* word is returned in A
ReadWord NOP
JSB ReadByte get upper 8 bits into A
ALF,ALF and shift up
STA wordTmp store them temorarily
JSB ReadByte get lower 8 bits into A
IOR wordTmp OR in the upper bits
JMP ReadWord,I return
*-----------------------------------------------------------------
* Read a Byte
* byte is returned in A
ReadByte NOP
LDA ConstNeg11 count 11 times up to 0 (start bit, 8 data, 2 stop)
STA readBitCnt
CLA start with 0 byte
STC TtyChannel start the paper tape reader
_readBit RAR rotate bits down
CLF TtyChannel prepare to receive a bit
SFS TtyChannel wait
JMP *-1
MIA TtyChannel OR bit 7 from device into A
ISZ readBitCnt if end of frame
JMP _readBit wait for next bit
RAL,RAL rotate back to get rid of 2 stop bits
AND ByteMask and mask so we have just 8 desired bits
JMP ReadByte,I return
******************************************************************
* Data
ConstNeg11 OCT 0-11
blmLength OCT 0
blmAddress OCT 0
* AddrLimit OCT 170100B for 4K of memory
AddrLimit OCT 160100B for 8K of memory
wordTmp OCT 0
readBitCnt OCT 0
ByteMask OCT 000377B
******************************************************************