0001****************************************************************** 0002*** 0003*** HP2116 Computer System 0004*** ASCII Post-Fix Record Basic Binary Loader 0005*** 0006*** 28 Apr 2004, by bhilpert 0007*** 20 Feb 2008, asm21.pl conversion by Tim Riker 0008*** 0009****************************************************************** 0010* 0011* Address Routine 0012* ------- ------- 0013* 017700: AblStart1 - execute loader, used when operating from front panel. 0014* 017702: AblStart2 - execute loader, used if calling program has assigned 0015* termination address in location 2. 0016* 017704: AblStart3 - execute loader, used if calling program has assigned 0017* termination addresses in 2 and 3. 0018* 0019* The ASCII Binary Loader reads ASCII characters from a 12531 High-Speed-Terminal (serial async) 0020* device, interpreting the characters as load records of a binary image to be deposited in memory. 0021* The ASCII Binary Loader functions as a simple language interpreter maintaining 3 variables: 0022* blmNumber, blmAddress and blmChecksum. 0023* 0024* The commands of the language have a post-fix operator structure. 0025* Received characters and their functions: 0026* 0..7 Digit - a new digit is appended to blmNumber 0027* (shifted left 3 bits and the new digit value added) 0028* : Address - blmAddress and blmChecksum are set to blmNumber, 0029* blmNumber is set to 0 0030* , Data - blmNumber is stored in memory at address blmAddress and added 0031* to blmChecksum, blmAddress is incremented, blmNumber is set to 0 0032* # Checksum - blmNumber is compared with blmChecksum, blmNumber is set to 0 0033* 0034* ! End - loading is terminated 0035* 0036* Other characters are ignored. 0037* blmNumber is initially 0. 0038* Operations on blmChecksum are modulo 16 bits. 0039* 0040* The following simple sequence loads 3 words (1,2,7) starting at octal address 002000: 0041* 0042* 002000:1,000002,07, 000012# ! 0043* 0044* At termination, the loader will jump to either the address stored in location 2 (successful) 0045* or location 3 (checksum error). For front panel operation or system loading the loader stores 0046* the addresses of it's own default termination sequences in those locations. A calling program 0047* can assign addresses to those locations (to return to the calling program) before invoking 0048* the loader or the loaded program itself can overwrite locations 2 and 3 with preferred jump 0049* destinations (for auto-start of the loaded program). 0050* 0051* The default termination sequences halt the processor and present a termination code in the 0052* two LSDs (octal) of the T display: 0053* 77 - normal termination 0054* 11 - checksum error 0055* In addition, the program counter is left such that pressing RUN will restart the loader. 0056* 0057****************************************************************** 0058* Configuration 0060* machine HP21xx 0062 00011 HstDev EQU 11B channel select code of input device 0064 00001 B EQU 1 0066****************************************************************** 0067* 0068* ASCII Boot Loader 0069* 0070****************************************************************** 0071 17700 ORG 17700B 0073 17700 063761 AblStart1 LDA ablEndErr store address for checksum error termination 0074 17701 070003 STA 3 0075 17702 063756 AblStart2 LDA ablEnd store address for normal termination 0076 17703 070002 STA 2 0078 17704 107700 AblStart3 CLC 0,C disable all devices and interrupts 0080 17705 063774 LDA HstCmdInput set device to input mode 0081 17706 102611 OTA HstDev 0082*--------------------- 0083 17707 006400 _finCmd CLB B will be blmNumber 0084*--------------------- 0085 17710 103711 _getInput STC HstDev,C start character read 0086 17711 102311 SFS HstDev is character available? 0087 17712 027711 JMP *-1 no 0088 17713 102511 LIA HstDev A contains character 0089 17714 103111 CLF HstDev needed to enable bit clock if only one stop bit 0090 17715 013773 AND AsciiMsk get rid of possible busy flag from HST 0091*--------------------- 0092 17716 053764 CPA AsciiColon and check for command characters 0093 17717 027741 JMP _cmdAddress 0094 17720 053765 CPA AsciiComma 0095 17721 027744 JMP _cmdData 0096 17722 053766 CPA AsciiHash 0097 17723 027752 JMP _cmdChecksum 0098 17724 053767 CPA AsciiExclaim 0099 17725 027755 JMP _cmdEnd 0101 17726 073777 STA holdChar ..modifying A, hang onto character 0102 17727 013770 AND AsciiIsOctMsk check for ASCII 0..7 by masking out lower 3 bits 0103 17730 053771 CPA AsciiIsOctVal and comparing upper bits 0104 17731 027733 JMP _cmdDigit 0106 17732 027710 JMP _getInput everything else is ignored 0107*--------------------- 0108 17733 005723 _cmdDigit BLF,RBR move blmNumber up one octal digit (rotate left 3 bits) 0109 17734 063777 LDA holdChar retrieve new octal digit 0110 17735 013772 AND OctDigitMsk 0111 17736 030001 IOR B and put new digit 0112 17737 070001 STA B into lowest digit of B 0113 17740 027710 JMP _getInput 0114*--------------------- 0115 17741 077775 _cmdAddress STB blmAddress set the memory address for loading to blmNumber 0116 17742 077776 STB blmChecksum and restart the checksum 0117 17743 027707 JMP _finCmd 0118*--------------------- 0119 17744 177775 _cmdData STB blmAddress,I save the blmNumber in memory 0120 17745 047776 ADB blmChecksum and update checksum 0121 17746 077776 STB blmChecksum 0122 17747 037775 ISZ blmAddress increment address 0123 17750 000000 NOP 0124 17751 027707 JMP _finCmd 0125*--------------------- 0126 17752 057776 _cmdChecksum CPB blmChecksum do checksums match? 0127 17753 027707 JMP _finCmd yes, go load some more 0128 17754 124003 JMP 3,I no, checksum error termination 0129*--------------------- 0130 17755 124002 _cmdEnd JMP 2,I successful termination 0132*----------------------------------------------------------------- 0133* Default termination sequences 0135 17756 017757 ablEnd DEF *+1 0136 17757 102077 HLT 77B normal termination, if not redirected 0137 17760 027700 JMP AblStart1 0139 17761 017762 ablEndErr DEF *+1 0140 17762 102011 HLT 11B checksum error termination, if not redirected 0141 17763 027700 JMP AblStart1 0143*----------------------------------------------------------------- 0144* Static data (constants) 0146 17764 000072 AsciiColon OCT 72B 0147 17765 000054 AsciiComma OCT 54B 0148 17766 000043 AsciiHash OCT 43B 0149 17767 000041 AsciiExclaim OCT 41B 0150 17770 000170 AsciiIsOctMsk OCT 170B 0151 17771 000060 AsciiIsOctVal OCT 60B 0152 17772 000007 OctDigitMsk OCT 7B 0153 17773 000177 AsciiMsk OCT 177B 0155 17774 140000 HstCmdInput OCT 140000B command word to set device to input mode 0157*----------------------------------------------------------------- 0158* Dynamic data (variables) 0160 17775 000000 blmAddress OCT 0 0161 17776 000000 blmChecksum OCT 0 0162 17777 000000 holdChar OCT 0 0164****************************************************************** AblStart1 017700 01/0073 -- 01/0137 01/0141 AblStart2 017702 01/0075 -- unreferenced AblStart3 017704 01/0078 -- unreferenced AsciiColon 017764 01/0146 -- 01/0092 AsciiComma 017765 01/0147 -- 01/0094 AsciiExclaim 017767 01/0149 -- 01/0098 AsciiHash 017766 01/0148 -- 01/0096 AsciiIsOctMsk 017770 01/0150 -- 01/0102 AsciiIsOctVal 017771 01/0151 -- 01/0103 AsciiMsk 017773 01/0153 -- 01/0090 B 000001 01/0064 -- 01/0111 01/0112 HstCmdInput 017774 01/0155 -- 01/0080 HstDev 000011 01/0062 -- 01/0081 01/0085 01/0086 01/0088 01/0089 OctDigitMsk 017772 01/0152 -- 01/0110 _cmdAddress 017741 01/0115 -- 01/0093 _cmdChecksum 017752 01/0126 -- 01/0097 _cmdData 017744 01/0119 -- 01/0095 _cmdDigit 017733 01/0108 -- 01/0104 _cmdEnd 017755 01/0130 -- 01/0099 _finCmd 017707 01/0083 -- 01/0117 01/0124 01/0127 _getInput 017710 01/0085 -- 01/0106 01/0113 ablEnd 017756 01/0135 -- 01/0075 ablEndErr 017761 01/0139 -- 01/0073 blmAddress 017775 01/0160 -- 01/0115 01/0119 01/0122 blmChecksum 017776 01/0161 -- 01/0116 01/0120 01/0121 01/0126 holdChar 017777 01/0162 -- 01/0101 01/0109 26 symbols 2 unreferenced 164 lines assembled, 64 words generated 0 errors, 0 warnings