****************************************************************** *** *** HP2116 Computer System *** ASCII Post-Fix Record Basic Binary Loader *** *** 28 Apr 2004, by bhilpert *** 20 Feb 2008, asm21.pl conversion by Tim Riker *** ****************************************************************** * * Address Routine * ------- ------- * 017700: AblStart1 - execute loader, used when operating from front panel. * 017702: AblStart2 - execute loader, used if calling program has assigned * termination address in location 2. * 017704: AblStart3 - execute loader, used if calling program has assigned * termination addresses in 2 and 3. * * The ASCII Binary Loader reads ASCII characters from a 12531 High-Speed-Terminal (serial async) * device, interpreting the characters as load records of a binary image to be deposited in memory. * The ASCII Binary Loader functions as a simple language interpreter maintaining 3 variables: * blmNumber, blmAddress and blmChecksum. * * The commands of the language have a post-fix operator structure. * Received characters and their functions: * 0..7 Digit - a new digit is appended to blmNumber * (shifted left 3 bits and the new digit value added) * : Address - blmAddress and blmChecksum are set to blmNumber, * blmNumber is set to 0 * , Data - blmNumber is stored in memory at address blmAddress and added * to blmChecksum, blmAddress is incremented, blmNumber is set to 0 * # Checksum - blmNumber is compared with blmChecksum, blmNumber is set to 0 * * ! End - loading is terminated * * Other characters are ignored. * blmNumber is initially 0. * Operations on blmChecksum are modulo 16 bits. * * The following simple sequence loads 3 words (1,2,7) starting at octal address 002000: * * 002000:1,000002,07, 000012# ! * * At termination, the loader will jump to either the address stored in location 2 (successful) * or location 3 (checksum error). For front panel operation or system loading the loader stores * the addresses of it's own default termination sequences in those locations. A calling program * can assign addresses to those locations (to return to the calling program) before invoking * the loader or the loaded program itself can overwrite locations 2 and 3 with preferred jump * destinations (for auto-start of the loaded program). * * The default termination sequences halt the processor and present a termination code in the * two LSDs (octal) of the T display: * 77 - normal termination * 11 - checksum error * In addition, the program counter is left such that pressing RUN will restart the loader. * ****************************************************************** * Configuration * machine HP21xx HstDev EQU 11B channel select code of input device B EQU 1 ****************************************************************** * * ASCII Boot Loader * ****************************************************************** ORG 17700B AblStart1 LDA ablEndErr store address for checksum error termination STA 3 AblStart2 LDA ablEnd store address for normal termination STA 2 AblStart3 CLC 0,C disable all devices and interrupts LDA HstCmdInput set device to input mode OTA HstDev *--------------------- _finCmd CLB B will be blmNumber *--------------------- _getInput STC HstDev,C start character read SFS HstDev is character available? JMP *-1 no LIA HstDev A contains character CLF HstDev needed to enable bit clock if only one stop bit AND AsciiMsk get rid of possible busy flag from HST *--------------------- CPA AsciiColon and check for command characters JMP _cmdAddress CPA AsciiComma JMP _cmdData CPA AsciiHash JMP _cmdChecksum CPA AsciiExclaim JMP _cmdEnd STA holdChar ..modifying A, hang onto character AND AsciiIsOctMsk check for ASCII 0..7 by masking out lower 3 bits CPA AsciiIsOctVal and comparing upper bits JMP _cmdDigit JMP _getInput everything else is ignored *--------------------- _cmdDigit BLF,RBR move blmNumber up one octal digit (rotate left 3 bits) LDA holdChar retrieve new octal digit AND OctDigitMsk IOR B and put new digit STA B into lowest digit of B JMP _getInput *--------------------- _cmdAddress STB blmAddress set the memory address for loading to blmNumber STB blmChecksum and restart the checksum JMP _finCmd *--------------------- _cmdData STB blmAddress,I save the blmNumber in memory ADB blmChecksum and update checksum STB blmChecksum ISZ blmAddress increment address NOP JMP _finCmd *--------------------- _cmdChecksum CPB blmChecksum do checksums match? JMP _finCmd yes, go load some more JMP 3,I no, checksum error termination *--------------------- _cmdEnd JMP 2,I successful termination *----------------------------------------------------------------- * Default termination sequences ablEnd DEF *+1 HLT 77B normal termination, if not redirected JMP AblStart1 ablEndErr DEF *+1 HLT 11B checksum error termination, if not redirected JMP AblStart1 *----------------------------------------------------------------- * Static data (constants) AsciiColon OCT 72B AsciiComma OCT 54B AsciiHash OCT 43B AsciiExclaim OCT 41B AsciiIsOctMsk OCT 170B AsciiIsOctVal OCT 60B OctDigitMsk OCT 7B AsciiMsk OCT 177B HstCmdInput OCT 140000B command word to set device to input mode *----------------------------------------------------------------- * Dynamic data (variables) blmAddress OCT 0 blmChecksum OCT 0 holdChar OCT 0 ******************************************************************