Digital PDFs
Documents
Guest
Register
Log In
DEC-8I-RZPA-D
December 1971
126 pages
Original
4.1MB
view
download
Document:
cmnUsedRtn
Order Number:
DEC-8I-RZPA-D
Revision:
Pages:
126
Original Filename:
https://svn.so-much-stuff.com/svn/trunk/pdp8/src/dec/dec-8i-rzp/dec-8i-rzpa-d.pdf
OCR Text
PDP-8 Family Commonly Used Utility Routines (Dumps, Verifier, Duplicator^ Conversion and Printing Routines) For additional copies, order NO. DEC-8I-RZPA-D from the Program Library, Digital Equipment Corporation, Maynard, Mass, 01754. PDP-8 LIBRARY Fi rsl- Frlif-ion, Jamifirv 19 71 This volume is a collection of manuals printed 1965-1970 Copyright @ 1971 by Digital Equipment Corporation The following are trademarks of Digital Equipment Corporation, Maynard, Mass. DEC PDP COMPUTE RLAB FLIPCHIP FOCAL UN I BUS DIGITAL Or^NIBUS PREFACE This document is a collection of proven routines for the PDP-8 family of computers. These routines in themselves are useful to many programmers and are all illustrative of assembly language programming techniques. The user is advised to first investigate the sections on assembly language pro- gramming in Programming Languages and Introduction to Pro gramming 19 70 . CONTENTS Chapter 1 RIM Loader 1=1 Chapter 2 Binary Loader (33-ASR, High-Speed Reader) 2-1 Chapter 3 RIM Punch 3-1 (33-ASR, High-Speed Punch) Chapter 4 Binary Punch (33-ASR, High-Speed Punch) 4-1 Chapter 5 Octal Memory Dump (33-ASR, High-Speed Punch) 5-1 Chapter 6 Teletype I/O Subroutines 6-1 (33-ASR) Chapter 7 Master Tape Duplicator/Verifier (High-Speed Reader/Punch) 7-1 Chapter 8 ^"1 Chapter 9 Incremental Plotter Subroutine (Type 350 Control and Plotter) Decimal to Binary Conversion and Input (Single Precision, Signed or Unsigned, 9-1 33-ASR) Chapter 10 Decimal to Binary Conversion and Input (Double Precision, Signed or Unsigned, 10-1 33-ASR) Chapter 11 BCD to Binary Conversion, Single Precision 11-1 (33-ASR) Chapter 12 BCD to Binary Conversion, Double Precision 12-1 (33-ASR) Chapter 13 Unsigned Decimal Integer Print, Single Precision (33-ASR) 13-1 Chapter 14 Signed Decimal Integer Print, Single Precision (33-ASR) 14-1 Chapter 15 Unsigned Decimal Integer Print, Double Precision (33-ASR) 15-1 Chapter 16 Signed Decimal Integer Print, Double Precision (33-ASR) 16-1 Chapter 17 Binary to BCD Conversion 17-1 r^V-ini-v-l-,^-!^ v-.j.j.<^^ <_v_ J- 1Q JL v^ t5-i*-.o -Y-tT i-> J- 1 i. >^ J- jf 4-/-\ o\_/ D/^'Tv JJV_i^ /^^*-.TT^ v-r- J. -i^i-» v^>^ii V c: J- o v^ij. ( ^ A —r\A -i- \ i-tJ-^J-'—J V"* -i 1Q_1 w J. j_ Formerly DEC-08-LRAA-D CHAPTER 1 RIM LOADER ABSTRACT 1. The Re6.d.— In Mode ^RIM^ Loa.d.er is s. miniinuiTi— sized routine for reading and storing into core information contained in Read-InMode coded tapes via the 33-ASR perforated tape reader or high speed perforated tape reader. 1.2 REQUIREMENTS The RIM Loader requires 17^^ ..^ — ^ _-„^ C21o) core locations and is used family computer with a 33-ASR Teletype v-^ . a high speed perforated tape reader is optional. 1. USAGE Loading 1.3.1 To place the RIM Loader into memory via the console switches, proceed as follows: a. Set 7756 in the switch register (SR) b. Press LOAD ADDress. c. Set the first instruction (6032 d. Press DEPosit. e. Set the next instruction (60 31 for 33-ASR) f. Press DEPosit. g. Repeat steps e. and deposited. f. for 33-ASR) until all instructions have been S tar t-up /Entry 1.3.2 a* Place the i^erf orated tape which m.ust be in RIM form.at in the perforated-tape reader. PDP Procrramjned Data Processor- is a rei^istered trademark of the Digital Equipment Corporation. ; ©P.'eletype is a trademark of the Teletype Corporation. 1-1 b. Make sure the reader is set to LINE. c. Place the starting address (7756) in the switch register. d. Press the LOAD ADDress key. e. Press the START key. f If the 33-ASR version is used, move the reader control to START. There are no error stops in this routine. 1.4 DESCRIPTION This is a basic routine that alternately assembles an address from two successive characters on tape, then assembles data contained in the next two characters and stores this data at the associated address Because a tape in RIM format is twice as long as a comparable tape in binary format, it is suggested that the RIM Loader only be used to load the Binary Loader. After this, the Binary Loader should be used. Any tapes to be read by this program must be in Read-In-Mode coded format. Leader tape for RIM format tapes should be about two feet of leader-trailer codes; i.e., any code with channel 8 punched, preferably code 200. @ keys simultaneously (Depress ALT MODE, CTRL, and to punch 200 leader trailer.) Characters representing the absolute, machine language program are arranged in an alternating pattern of address, contents, address, contents, etc. punched. Addresses have channel 7 punched, channel Contents have no punch in channel 7 or 8. Trailer tape should be the same as leader tape. 1-2 8 not 1.5 EXAMPLE OF READ-IN-MODE CODED FORMAT Channels Tape Channel 8 and 7 Indicate 87 654 S 321 10 000 01 Al 00 A3 00 Dl 00 D3 . . . . . Leader code is always tound first. 000 A2 A4 Absolute octal Address of data in next two characters. D2 D4 Octal Data to be stored at preceding address. This pattern repeats in similar four character groups until the concluding Trailer Code is 10 000 000 encountered. . Note that a 3-bit group by the notation Al above. single octal character) is designated (a The 1 in this notation indicates that this particular octal character is used as the most significant three bits in specifying the absolute address into which following data is deposited. Correspondingly, A2 , A3, and A4 designate successively less significant octal characters in the absolute address. The remarks above apply equally to data as specified by the notation Dl, D2 , D3, and d4. 1-3 1.6 PROGRAM LISTING 1.6.1 33-ASR Version Abs Addr. Octal Contents 1156, 1151 1160, 1161, 1162, 1163, 7764, 1165, 1166, 1161 1110, 1111, 1112, 1112, lllA, 1115, 1116, 1111 6032 6031 5357 6036 7106 7006 7510 5357 7006 6031 5367 6034 7420 3776 3376 5356 Comments Instruction BEG, KCC KSF JMP .-1 KRB CLL RTL RTL SPA JMP BEG+1 RTL KSF JMP .-1 KRS SNL DCA I TEMP DCA TEMP JMP BEG TEMP, JMP start of BIN loader 1.6.2 High-speed Version Abs Addr. Octal Contents 7756 7757 7760 7761 7762 7763 7764 7765 7766 7767 7770 7771 6014 6011 5357 6016 7106 7006 7510 5374 7006 6011 5367 6016 7772 7420 SNL 7773 3776 DCA 7774 7775 7776 7777 3376 5357 DCA TEMP JMP BEG+1 ^ Instruction BEG, TEMP, ^ 1-4 /read, do not clear /checking for address /store contents /store address /next word /temp storage Comments RCF RSF JMP .-1 RCC CLL RTL RTL SPA JMP TEMP -2 RTL RSF JMP .-1 RCC I /clear AC and flag /skip if flag = 1 /looking for char /read buffer /ch8 in ACO /checking for leader /found leader /0K,ch7 in link TEMP /clear flag and fetch char. /skip if flag = 1 /wait for fetching to be done /put char. in AC; fetch another /rotate channel 8 to /bit j? of AC /was it set (leader-trailer)? /yes - leader trailer /no - rotate channel 7 to link /character fetched yet? /no - wait for it /yes - add it to AC; fetch /another /is 12-bit word in AC an /address? /no - store in last stored /address /yes - store new address /get next word /temporary storage /start of binary loader . 1.7 OTHER POSSIBLE RIM LOADERS Variations of the RIM Loader may prove useful in special cases where, due to circumstances, RIM must be located in a different section of core. On the other hand, the equipment involved may make it necessary to use a variation of RIM tailored specifically to a particular situation. As an example of this, consider a special-purpose PDP-8 system used for text editinfT* In this system., no 33— ASR's are used* In- stead, several typewriters which use a different code (including provision for upper and lower case) are time-shared with respect to input and output with a central PDP-8. Please consult the Applied Programming Department at Digital Equipment Corporation for details of other RIM Loaders currently available or for assistance in special cases. 1.8 USE OF PDP-8 SYSTEM PROGRAMS Certain system programs^ such as the DECtape Library System require that the RIM Loader be used precisely as (DEC-08-SUCO) , listed in section 1.6. 1.9 USING THE RIM LOADER WITH EXTENDED MEMORY The RIM Loader as described in section 1.6 can run in any memory field provided that it is loaded into memory following a slightly different procedure than that described in 1.3.1. The Instruction Field register and the Data Field register must both be to 7) where N indicates the memory field set to N (a number from in which the RIM Loader is to be placed. a. b. This is easily done. Set the DATA FIELD extension of the switch register to N. Set the INSTRUCTION FIELD extension of the switch register to N. c. Follow procedure in steps a through g in section 1.3.1. 1-5 Formerly DEC-0 8-LBAA-D CHAPTER 2 BINARY LOADER 2 . ABSTRACT The Binary Loader is a short routine for reading and storing informa- tion contained in binary-coded tapes, using the 3 3-ASR reader or the High-Speed Reader. The Binary Loader accepts tapes prepared with the PAL III, PAL-D, PALS, or riACRO-8 assemblers. Diagnostic messages may be included on tapes produced when using either PAL or MACRO. The Binary Loader ignores all diagnostic messages. 2 . REQUIREMENTS This program occupies 94, q (136o) core locations. The Binary Loader can be used with a system consisting of the PDP-8 and a 3 3-ASR Teletype only. On the other hand, the same program operates with systems including the High-Speed Tape Reader Memory Extension Control. and/or the This loader is compatible with the 552 DECtape Library System and the TCOl DECtape Library System. 2.3 LOADING PROCEDURES The Binary Loader is brought into memory by the RIM or Read-In= Mode Loader. This requires that the Binary Loader tape itself be in RIM format. See Introduction to Programming and Chapter 1 for dis- cussions of the RIM Loader and RIM format. NOTE: Memory Extension users; refer to Special Requirements section. Proceed as follows: a. Load the RIM Loader for the type of reader which is to load the Binary Loader. b. Place the Binary Loader tape in the reader. c. Make sure that the reader is on-line. d. Place the starting address of the RIM Loader (7756) in the SWITCH REGISTER. e. Press the LOAD ADDRESS key. f. Press the START key. g. If the 33-ASR is the chosen reader, move the READER CONTROL switch to the START position. 2-1 Switch Setting NOTE: Memory Extension users see "Special Requirements" section. 2.3.1 2.4 USING THE PROGRAM a. Place the tape to be loaded (which must be in binary format) in either the 33-ASR Tape Reader or the High-Speed Reader, with leader-trailer under the read head. When using the 33-ASR, make sure the reader is on-line. When using the High-Speed reader, make sure the reader is on. b. Place the starting address of the Binary Loader (7777) in the SWITCH REGISTER. c. Press LOAD ADDRESS key. When using the High-Speed Reader, change the SWITCH REGISTER to 3777 (bit 0=0). Omit this step if using the 33-ASR. d. Press console START key. When using the 33-ASR, move the READER CONTROL switch to START. 2 . ERRORS When any of the PDP-8 assemblers is used to produce a binary tape, a checksum is automatically punched at the end of the binary tape. checksum is the sum The of all data on the tape including the origin word. To be more specific, it is the sum of all data contained on tape that will enter the accumulator (AC) in bit positions 4 through 11 from, for example, the 33-ASR Reader buffer. The sum is accumulated charac- ter by character and not word by word. Overflow (a carry out of the most-significant bit position of the AC) is ignored both when calculating a checksum (which is done by the assembler used) and when the Binary Loader accumulates a checksum while loading a tape. If the checksum accumulated while using the Binary Loader does not agree with the last two characters on the tape (i.e., the checksum on the tape calculated and placed there by the assembler) , an error has occurred. When the computer halts, the display lights will be static, the memory buffer (MB) will contain 7402, and the contents of the AC will be unequal to zero if a checksum error has occurred. 2-2 Restart the computer after the tape has been repositioned by pressing the CONTINUE key. 2.6 DETAILS OF OPERATION AND STORAGE This program furnishes the basic means by which the contents of binary-coded tapes are loaded into core. The heart of the program is a short subroutine (tagged BEGG) which operates in outline as follows: The incoming character is tested to see if it is a "rubout" eight tape channels punched) (all If this is the case, all subsequent information coming from the reader is ignored until another rubout is detected. This is the mechanism by which assembler diagnostic messages are detected. They are preceded and followed by a single rubout char- Within a diagnostic message, in contrast to the rules concerning the balance of the binary tape, any character is valid except, of course, acter. a single rubout character which would prematurely conclude the diagnostic message. Note that two consecutive rubouts within a diagnostic message would, in effect, be ignored. Next the character is tested to see if it is leader or field setting. These tests are listed in the order in which they are performed. If none of the actions indicated have occurred upon exit from the BEGG subroutine, the character is part of the origin address, contains part of a data word, or is a part of the checksum, and the appropriate course is followed by the main routine. 2.7 2.7.1 SPECIAL REQUIREMENTS OR FORMATS External Format Tapes to be read by this program must be in binary-coded format and have about 1 foot of leader- trailer code punched; preferably code 200) 2-3 (any code with channel 8 The first two characters represent the address (origin) into which the first command on the next portion of the tape will be placed. Successive coramands are placed in memory at addresses: origin+l,origin+2 , . . . ,origin+n. The initial character of the origin has no punch in channel 8, while channel 7 is punched. The second character designating the origin has no punches in either channel 8 or 7 A concluding 2-character group representing the checksum has no punches present in channels 8 or 7. Trailer tape is similar to leader. Reference to Program Listing indicates that after the BEGG subroutine tests to see if the character just read was leader/trailer, a test is made to determine whether the character is a "field setting." This is a reference to the fact that the assemblers produce tapes on which characters of the form 11 XXX 000 indicate the memory field into which the following data is to be If, for example XXX were 101, all data following the field loaded. Unlike origins and designator should be loaded into memory field five. other data, field settings are not included in the checksum. 2.7.2 Example of Binary Loader Format Tape Channel 87 654 S 321 10 000 01 000 00 000 00 Ill 00 000 00 oil 00 Ill .. .. .. .. .. .. .. Channels 8 and 7 I ndicate Program Proper Notes 000 Leader No 010 000 Origin No In octal the origin 0200. Loading will start at 0200 010 000 Contents of 200 Yes The command 7200 or CLA. 010 110 Contents of 201 Yes The command 3276 or DCA 2-4 Z 76. Example of Binary Loader Format (Cont.) Tape Channel Program Proper Yes The command 7402 or HLT. Mr^ Thfi 87 654 S 321 00 111 00 000 100 010 Contents of 202 _- ,«« ^1 no 010 010 . . 10 000 . 000 Notes Channels 8 and 7 Indicate i.„, ^ nrnaram determines that these two characters are the checksum since trailer follows. No Trailer The octal checksum in this example is 0422. this is the following sum: 102 000 072 000 32 076 074 002 422 Note that Origin First word Second word Third word Memory Extension Usage exist in field 0. This It is recommended that the Binary Loader and 7755 which ensures a permanent program lining around location 7754 The loader can exist in any field, though are used for TCOl DECtape. (this 7755 in field caution must be taken not to use location 7754 and proper field is chosen applies only to DECtape users). Also, when the already be in that field. it should be noted that the RIM Loader must 2.7.3 Binary Loader Loading Procedure for E xtended a. b. " Place the Binary Loader tape in the reader. LISTER Place the proper FIELD in the INSTRUCTION FIELD (7756) Loader ^^Ht-ocq of RIM ..^-^^ iu^ ^4-^^4--ir,rT thf? v^^^-.^^^ — wnen puT-i-j.xig L.iie o ucu. i— in the SWITCH REGISTER. Press the LOAD ADDRESS key. — , L-ii-tj c. d- e Memory Users f Press the START key. press READER CONTROL to start. 33-ASR: Start the reader. should already be ready to start. High-Speed Reader: 2-5 Operat ion and Usage for Extended Memory Users a. b. c. d. Place the tape to be loaded (tape must be in binary format) the reader. When using the 33-ASR, make sure reader is on-line. When using the High-Speed make sure reader is on and tape is positioned with Reader, leader/ trailer over read head. In the DATA FIELD register place the field in which program is to be loaded. In the INSTRUCTION FIELD the register place the field that the Binary Loader is in. Press LOAD ADDRESS key. When using the High-Speed Reader, change the SWITCH REGISTER TO 3777 (bit 0=0). Omit this step if using m Press console START key. Starting Program After program has been successfully loaded, place starting address of program in SWITCH REGISTER. Place the field where program exists in the FIELD INSTRUCTION REGISTER. Press LOAD ADDRESS key. Press START key. 2-6 2.8 PROGRAM LISTING DIGITAL ^JJIP^It^^f ^ASSACHJSSrrS /BINARY AND DECTAPE LOADERS FOR /555 CONTROL /COPr aciHf 1971 Ui^f'jKm 1 jN /-^AfMA^D^ 7612 7613 7614 7615 7616 0000 0000 0000 0000 0000 *7612 SWITCH, r^EMTEM, CHAR, CHKSUM, ORIGIN, *7626 /T? VrtTD /EXTRACT /iliAiKAC 7» /-I 7626 7627 7630 7631 7632 7633 7634 7635 7636 7637 7640 7641 7642 7643 7644 7645 7646 7647 7650 0000 3212 4260 1300 7750 5237 2212 7040 5227 1212 7640 5230 1214 0274 1341 7510 2226 7750 5626 7651 7652 7653 7654 7655 7656 7657 7660 7661 7662 7663 7664 7665 7666 7667 7670 7671 7672 1214 0256 1257 3213 5230 0070 6201 0000 0000 6031 5262 6036 3214 1214 5660 6011 5270 6016 ERRORS, FIELD, L/T BEGG, DCA SWITCH JMS READ TAD M376 SPA SNA CLA JMP .+4 ISZ SWITCH CMA JMP BEGG+1 TAD SWITCH SZA CLA JMP BEGG+2 TAD CHAR AND MASK TAD M200 SPA ISZ BEGG SPA SNA CLA JMP I BEGG TAD CHAR AND FMASK TAD CHANGE DCA MEMTEM JMP BEGG+2 FMASK, CHANGE READ LOR, HIR, /SET SWITCH /GET A CHARACTER /TEST FOR 3 77 /NO /YES: COMPLEMENT SWITCH /NOT 377 /IS SWITCH SET? /YES; IGNORE /NO; TEST FOR CODE /TYPES /DATA OR ORIGIN /DATA, ORIGIN, or L/T /FIELD SETTING /CONTINUE INPUT 70 CDF KSF JMP .-1 KRB DCA CHAR TAD CHAR JMP I READ RSF JMP .-1 RRB RFC 2-7 /WAIT FOR FLAG JMP LOR+3 7673 7674 5265 0300 I^IS 1616 7677 7700 7701 7702 7703 7704 7705 7706 7707 7710 7711 7712 7713 7714 4343 7041 1215 7402 6032 6014 6214 1257 3213 7604 7700 1353 1352 3261 4226 5313 7715 7716 7717 7720 7721 7722 7723 7724 7725 7726 7727 7730 3215 1213 3336 1214 3376 4260 3355 4226 5275 4343 7420 5336 7731 7732 7733 7734 7735 3216 1376 1355 1215 5315 7736 7737 7740 7741 7742 0000 3616 2216 7600 5332 MEMFLD 7743 7744 7745 7746 7747 7750 7751 7752 0000 1376 7106 7006 7006 1355 5743 5262 ASSEMB, MASK, /traile: BEND, M376, BEGIN, GO, CHEX, 300 JMS ASSEMB CIA TAD CHKSUM HLT KCC RFC RDF TAD CHANGE DCA MEMTEM CLA OSR SMA CLA TAD HIRI TAD LORI DCA READ+1 JMS BEGG JMP .-1 DCA CHKSUM TAD MEMTEM DCA MEMFLD TAD CHAR DCA WORDl JMS READ DCA W0RD2 JMS BEGG JMP BEND JMS ASSEMB SNL JMP MEMFLD DCA ORIGIN TAD WORDl TAD W0RD2 TAD CHKSUM JMP GO DCA I ORIGIN ISZ ORIGIN M200, LORI, 7600 JMP CHEX TAD WORDl CLL RTL RTL RTL TAD W0RD2 JMP I ASSEMB JMP LOR 2-8 /SAVE FIELD INSTRUCTION /IGNORE LEADER /LOOK AHEAD /TRAILER, END 1153 7754 0006 0000 7755 0000 1111 5301 ASSEMB BE GG BEGIN BEND CHANGE CHAR CHEX CHKSUM FMASK 7743 7626 7701 7675 7657 7614 7732 7615 7656 7715 7670 7753 7662 7752 7674 7736 7613 7741 7700 7616 7660 7612 7776 7755 HIR-LOR HIRI, W0RD1=111^ W0RD2 *7777 GO HIR HIRI LOR LORI MASK MEMFLD MEMTEM M200 M376 ORIGIN READ SWITCH WORDl WORD 2 JMP BEGIN 2-9 Formerly DEC-OS-PMPO-D CHAPTER 3 RIM PUNCH 3.1 ABSTRACT The RIM Punch program provides a means of punching information contained in selected blocks of core memory as RIM-coded tape via the 33-ASR Perforated Tape Punch or 75E High Speed Punch. The punch pro- gram may occupy either low or high memory depending on the version used. 3.2 REQUIREMENTS The RIM Punch program will run on any PDP-8 with a family computer 33-ASR (Teletype) or 75E (high-speed) punch. This program requires 61^^ ^"^^p^ memory locations. Program tapes are as follows: High-speed Punch Version 33-ASR Version Low Memory Binary Low Source High Memory Binary High Source Low Memory Binary Low Source High Memory Binary High Source DEC-0 8-PMPl-PB DEC-0 8-PMPl-PA DEC-0 8-PMP2-PB DEC-0 8-PMP2-PA DEC-0 8-PMP4-PB DEC-0 8-PMP4-PA DEC-0 8-PMP3-PB DEC-0 8-PMP3-PA LOADING PROCEDURES See Introduction This routine is loaded using the Binary Loader. to Programming or Programming Languages for a complete description of (This routine cannot be called as a subroutine.) the Binary Loader. 3.3 3.4 USING THE PROGRAM The SWITCH REGISTER is used to enter the initial and final address of each block of core memory to be punched. a. Make sure 33-ASR or 75E punch is on. 3-1 b. Set the starting address 0041 (or 7441 if using the highmemory version) into the SWITCH REGISTER and press the LOAD ADDRESS key. Next press the START key. c. The computer halts. Set the initial address of the block to be punched into the SWITCH REGISTER and press the CONTINUE key. d. The computer halts. Set the final address of the block to be punched into SWITCH REGISTER and press the CONTINUE key. e. 3.5 Note that the final address must be larger than the initial address. A block of leader (code 200) tape is punched followed by the selected block of data in RIM format. f. The computer halts. Steps (c) and (d) can now be repeated to punch as many blocks of data as desired. To terminate the tape, proceed as described in (g) below. g. Set the terminating address 0074 (7474) into the SWITCH REGISTER and press the LOAD ADDRESS key. Next press the START key and a block of trailer tape is punched. DETAILS OF OPERATION AND STORAGE Reference to section 1.7, Flow Chart, will illustrate the following discussion. After entry, a short subroutine is entered to punch a block of leader. Next the initial address is picked up and the six most significant bits are rotated right, masked out, added to 0100 (in order to punch channel 7) and punched. The least-significant six , bits of the address are next masked out and punched. A similar process is followed to punch the data associated with the corresponding address except 010 is not added before the first character is punched. This process is repeated until the final address is reached; then the computer halts at the starting address. If more blocks of data are to be punched, this is done as explained in step (f) above. The routine is entered at a different address to punch the final trailer. 3-2 3.6 EXTERNAL DATA See Chapter 4 of Introduction to Programming for a description of RIM paper tape format. 3.7 FLOW CHART LEADER DATA BLOCK ENTRY BEG i 1 HALT PUNCH TRAILER LOAD ADDRESS INITIAL HALT LOAD FINAL ADDRESS PUNCH LEADER ' ' LOAD ADDRESS PA DO SHIFT RIGHT 6 ADD CHANNEL 7 PUNCH LOAD RIGHT HALF ADDRESS PUNCH LOAD CONTENTS PCON SHIFT RIGHT 6 PUNCH LOAD RIGHT HALF CONTENTS PUNCH ^,y^ BLOCK \s^ < PROCESSED J> :s Nr TRAILER ENTRY ^ • i INCREMENT ADDRESS 3-3 _. . J-IJ. <-« J. J. j.>( o /ClPY^IaHf IJll 744! 7442 7443 7444 7445 7 446 7447 7 450 7 451 7452 7 4 53 7454 7455 7456 7457 7 460 746 1 7462 7463 7464 7465 7466 7467 7470 7471 7472 7473 7474 7475 7402 7604 332S 7402 7 604 3323 4276 1322 4306 1326 4314 1322 0325 4314 1722 4306 4314 1722 0325 747 6 7 47 7 1327 7500 3324 7501 7 502 7503 7504 7505 7506 7507 7510 7511 7512 7513 1330 JMS TAD CIA TAD SNA JMP CO^r^ jkA F I J.nj PUN lA FA CLA /TEST FOR END .+4 lA I SZ JMP PADD JMS LTS JMP BEG /ENTRY FOR L/T LTS* MORE* 4314 2324 5301 5676 0000 7012 7012 7012 0325 5706 £JuI.^vi^,Mr /DEC-08-Pr^P2-PA /KIM PUNCH 33-ASK HIGH MEMORY *7441 BEG* HLT /Ei\'TRY FOR LEADER DATA BLOCK LAS /SET INITIAL ADDRESS DCA lA HLT LAS /SET FINAL ADDRESS DCA FA JMS LTS /GO TO L/T SUBROUTINE PADD* TAD I A /PUNCH ADDRESS J.MS SHFT TAD CH7 JMS PUN TAD I AND SL6 JMS PUN PCON, TAD I I A /PUNCH CO>JTENTS JMS SHFT JMS PUN TAD I I AND SL6 4314 1322 7341 1323 7650 5275 2322 5250 4276 5241 0000 DIGITAL /L/T SUBROUTINE TAD DCA TAD JMS M10! CTR C200 PUN I SZ CTR JMP MORE JMP I LTS /MORE L-T CODES SHFT* /SHIFT RIGHT RTR RTR RTR AND SL6 JMP I SHFT 3-4 7514 7515 7516 7517 7520 7521 7522 7523 7524 7525 7526 152.1 7530 0000 6046 /PUNCH SUBROUTIiME PUN, TLS TSF JMP CLA JMP 6041 5316 7200 57 14 0000 0000 0000 0077 0100 leil 0200 I -1 T HI It>j A, FA> Z1R> SL6, CH7* •M 1 77 100 -101 200 1 * C200* /COPy^lGHf 1971 /-lAYMAnJD, DIGITAL Z^JlP^Z^l CO-^POKAflOM .^ASSACH JSri: f IS /DIGITAL-8-4-U-RIM /RIM PUNCH 33 LOW MEMORY 0041 0042 0043 0044 0045 0046 0047 0050 0051 0052 0053 0054 0055 0056 0057 0060 0061 0062 0063 0064 006 5 0066 0067 0070 0071 0072 0073 0074 0075 7402 7604 3122 7402 7604 3123 4076 1122 *41 BEG PADDj 4106 1126 4114 1122 0125 4114 1522 4106 4114 1522 0125 4114 1122 7041 1123 7650 5075 2122 5050 4076 5041 PCONj HLT LAS DCA lA HLT LAS DCA FA JMS LTS TAD lA JMS SHFT TAD CH7 JMS PUN TAD lA AND SL6 JMS PUN TAD I lA JMS SHFT JMS PUN TAD I lA AND SL6 JMS PUN TAD lA CIA TAD FA SNA CLA JMP • +4 ISZ lA JMP PADD JMS LTS JMP BEG /ENTRY FOR LEADER DATA BLOCK /SET INITIAL ADDRESS /SET FINAL ADDRESS /GO TO L/T SUBROUTINE /PUNCH ADDRESS /PUNCH CONTENTS /TEST FOR END /ENTRY FOR L/T 3-5 0076 0077 0100 0101 0102 0103 0104 0105 0106 0107 0110 0111 0112 0113 0114 0115 0116 0117 0120 0121 0122 0123 0124 0125 0126 0127 0130 0000 3124 1130 4114 2124 5101 5476 0000 7012 7012 7012 0125 5506 0000 6046 6041 5116 7200 5514 0000 0000 0000 0077 0100 7677 0200 /L/T SUBROUTINE LTS^ 1127 MORE* TAD M101 DCA CTR TAD C200 JMS PUN ISZ CTR JMP MORE JMP I LTS /SHIFT RIGHT SHFT* RTR RTR RTR AND SL6 JMP I SHFT /PUNCH SUBROUTINE PUN* TLS TSF JMP .-1 CLA JMP I PUN I A* FA, CTR* SL6* CH7* M101* 77 100 -10] C.200* 200 /c OR r UGH r I 19 71 /DIGITAL-8-4-U-RIM /HIM PUNCH 7 5 HIGH 7441 7442 7 443 7444 7445 7446 7447 7450 7451 745f? 7453 7454 7455 7456 7^57 7460 7461 746S 7463 7^64 7402 7604 3322 7 402 7604 3323 4276 1322 4306 1326 4314 1322 0325 4314 1722 4306 4314 1722 0325 4314 /MORE L-T CODES *7441 BEG» PADD, PCON, 1 G I r AL £ ^ J I f:a h:.nj r C J.^POf^ ATI.J M i^lENORY HLT LAS DCA lA HLT LAS DCA FA JMS LTS TAD lA JMS SHFT TAD CH7 JMS PUN TAD lA AND SL6 JMS PUN TAD I lA JMS SHFT JMS PUN TAD I lA AND SL6 JMS PUN /ENTRY FOK LEADER DAT /SET INITIAL ADDRESS /SET FINAL ADDRESS /GO TO L/T SUBROUTINE /PUNCH ADDRESS /PUNCH CONTENTS 3-6 RLOCK 7465 7466 7467 7470 1322 7041 1323 7650 7471 7472 5275 2322 5250 7473 7474 7475 7476 7477 7 500 427 6 5241 0000 1330 4314 2324 751 1 7512 7513 7514 7515 7516 7517 7520 7521 7522 7523 7524 7525 7526 7527 7530 lA PADD LIS BEG TAD 1^101 DCA CTR TAD C200 JMS PUN ISZ CTR JMP MORE JMP I LTS MORE^ /ENTRY FOR L/T /MORE L-T CODES /SHIFT RIGHT SHFT* RTR RTR RTR AND SL6 Ji^P I SHFT /PUNCH SUBROUTINE PUN PLS PSF JMP .-1 CLA JMP I PUN 6021 5316 7200 5714 0000 0000 0000 0077 0100 7677 0200 /TEST FOR END . + 4 /L/T SUBROUTINE 5301 5676 0000 7012 7012 7012 0325 5706 0000 6026 FA CLA Ji^P 1327 7501 lA LIS 3324 7 502 7503 7504 7505 7506 7507 7510 TAD CIA TAD SNA JMP ISZ JMP JMS I A* FA* CTR> oLo* 77 CH7# M101 C200 100 - 10] I 200 /COPYilGHT 1971 />lArNA^D> OlGlfAL SJUIP-ICNf COiif'Oii^ilO^i /iASSACHJS.EirrS /DIGITAL-8-4-U-RIM /RIM PUNCH 7 5 LOW MEMORY *41 0041 0042 0043 V t-* —1 — 0045 0046 0047 0050 0051 0052 7402 7604 3122 7 402 7604 3123 4076 1 122 4106 1126 BEi PADD, HLT LAS DCA HLT LAS DCA JMS TAD JMS TAD /ENTRY FOR LEADER DATA BLOCK /SET INITIAL ADDRESS lA /SET FINAL ADDRESS FA /GO TO L/T SUBROUTINE /PUNCH ADDRESS LTS lA SHFT CH7 3-7 0053 41 14 00 54 1 122 0055 0056 0057 0060 0125 0061 41 14 0062 0063 0064 0065 0066 0067 0070 0071 0072 0073 0074 0075 0076 0077 0100 0101 0102 0103 0104 0105 0106 0107 01 10 01 1 1 01 12 01 13 01 14 01 15 01 16 01 17 0120 0121 0122 0123 0124 0125 0126 0127 0130 41 14 1522 PCON, 4106 122 7041 1 I 123 130 MORE, 2124 5101 5476 TAD DCA TAD JMS ISZ JMP JMP M101 CTR 0200 PUN CTR MORE I LTS /MORE L/T CODES SHFT* /SHIFT RIGHT RTR RTR RTR AND SL6 JMP I SHFT PUN /PUNCH SUBROUTINE PLS PSF JMP .-1 CLA JMP I PUN 6021 5116 7200 5514 0000 0000 0000 0077 0100 7677 0200 /ENTRY FOR L/T /L/T SUBROUTINE 41 14 0000 7012 7012 7012 0125 5506 0000 6026 /TEST FOR END LIS 127 3124 1 /PUNCH CONTENTS SHFT JMS PUN TAD I lA AND SL6 JMS PUN TAD lA CIA TAD FA SNA CLA JHP . + 4 TSZ lA JMP PADD JMS LTS JMP BEG 1522 7650 5075 2122 5050 4076 5041 0000 PUN lA SL6 PUN lA I Ji^S 0125 4114 1 JMS TAD AND JMS TAD FA, CTR, SL6, CH7, M1 1 77 100 , C200, -101 200 3-8 Formerly DEC-0 8-YXYA-D CHAPTER 4 BINARY PUNCH (Binary Core Dump to High-speed or Teletype Punch) 4.1 ABSTRA.CT This program provides a means of punching information con- tained in selected blocks of core memory as binary-coded paper tape using the high-speed or Teletype punch. 4.2 REQUIREMENTS This program occupies "75,^ (113g) core memory locations. The Binary Punch program runs on the basic PDP-8, 8/S , 8/1, 8/L, or 8/E with standard 33-ASR Teletype or standard high-speed punch. Program tapes are as follows 4.3 33-ASR Binary DEC-0 8-YXlA-PB 33-ASR Source DEC-0 8-YXlA-PA High-speed Binary DEC-0 8-YX2A-PB High-speed Source DEC-0 8-YX2A-PA LOADING PROCEDURES This program is loaded by means of the Binary Loader. See Introduction to Programming o r Programming Languages for a complete discussson of the Binary Loader and its use. (This program cannot be called as a subroutine.) The SWITCH REGISTER is used to enter initial and final addresses of blocks to be punched as well as the number of blocks to be punched, This program is used in the following manner: 4-1 a. Assuming the program is in memory as listed in 4.7, place the starting address 7465 in the SWITCH REGISTER and press the LOAD ADDRESS key. b. Press the START key. Leader tape is punched and the computer halts. Set the number of blocks to be punched into the SWITCH REGISTER and press the CONTINUE key. c. Set the initial address of the block The computer halts. to be punched into the SWITCH REGISTER and press the CONTINUE key. d. The computer halts. Set the final address of the block to be punched into the SWITCH REGISTER and press the CONTINUE key e. Note that the final address must be greater than the initial address. f. The indicated block of data is punched. If only has been called for, the trailer tape is punched If more than one block has been computer halts. the computer halts at step (a) waiting for a new address. The second block is punched following of steps (c) and (d) etc. one block and the called for, initial completion , 4 . 4 METHOD This is a basic program used to produce tapes acceptable by the Binary Loader. With each punched block of data, an initial address (into which that data is to be loaded) is punched as the first two characters. Following the initial address, each 2-character group represents the binary contents of a computer word. At the end of each block, a 2- character checksum is punched. Reference to Section 4.6, Flow Chart, will illustrate the com- putational approach. Basically data is picked up from memory, the most significant half shifted right and punched, and the least significant half masked out and punched. A similar process is followed with respect to the initial address and the checksum^ which is accumulated character by character as a block is punched. 4-2 See Chapter 4 of Introduction to Programming for a complete discussion of tape format. 4.6 FLOW CHART , tion, not connectives. PLOT PUNCH LEADER I ENTER NUMBER OF BLOCKS ENTER BLOCK lA AND FA PUNCH 2 BINP 4-3 ) CHARACTERS INCREMENT CUSM ^ , , -I- -; 1 .,• r, -. 4. / FKUCiKAJyi IjibTliSHo A listing of this program with BPUN located at 7465 is as follows: /COPfUGHr A^lAf,NJA:<i), 7465 7466 7467 7470 747 1 7300 6026 3366 4330 7402 19/1 DIGir-^L E:5JIP^£iviT CO-JPOnriQiNl r-IASiACH JS-iriS /BIN PUNCH HIGH SPEED PUNCH (PC03> PP8I> PP8L) *7465 CLA CLL BPUN^ /INITIAL PUNCH PLS /CLEAR CHECK-SUM DCA CKSM /GO PUNCH LEADER CODES JMS PLOT /SET SWITCHES=NUMBER OF HLT BLOCKS LAS CIA /STORE MINUS NUMBER OF DCA NB BLOCKS NXBL> HLT /SET SWITCHES = IN IT lAL ADDRESS OF BLOCK 7472 7473 7474 7604 7475 7402 7476 7477 7500 7604 3370 7402 LAS DCA lA HLT 7501 7604 7001 3371 1370 7120 LAS 7041 3367 /SET SWITCHES=FINAL ADDRESS OF BLOCK 7502 7503 7504 7505 7506 7507 7510 751 1 7512 7513 7514 7515 7516 7517 7520 7521 7522 7523 7524 752 5 7526 7527 7530 7531 7532 4341 lAC PUNL^ 1370 7041 1371 7650 5320 1770 7100 2370 5306 2367 5275 1366 7100 4341 4330 7402 5265 0000 7300 13 72 DCA FA TAD lA STL JMS BINP TAD CIA TAD SNA JMP TAD CLL ISZ JMP ISZ JMP TAD /TO PUNCH lA AS ORIGIN /GO PUNCH WORD AS TWO LINES OF TAPE lA FA CLA .+5 IIA lA /AC=FA-IA /WAS IT LAST WORD OF BLOCK? /IT WAS THE LAST WORD /GET WORD TO PUNCH /NOT AN ORIGIN /JUST INDEX lA PUNL NB NXBL CKSM /IS THERE ANOTHER BLOCK? /HANDLE NEXT BLOCK CLL JMS BINP JMS PLOT HLT JMP BPUN /GO PUNCH CHECK SUM /GO PUNCH TRAILER CODES /DONE PLOT:* CLA CLL TAD M212 4-4 /TO PUNCH 212 OCTAL LEADER TRAILER CODES 7533 7534 7535 7536 7531 1 DCA CTRl TAD C200 J MS PUN ISZ CTRl JMP .-2 3373 1374 4361 2373 5335 T J-^ICI 7541 7542 7543 7544 7545 7546 7547 0000 3375 1375 7012 7012 7012 0376 PI nT /LEADER TRAILER CODE /PUNCH C (AC) /ANOTHER L-T CODE OR NO /GO PUNCH ANOTHER / EXIT B I NP > DCA TEMl TAD TEMl RTR RTR RTR AND SL 7 /FIRST TWO OCTAL DIGITS IN AC 5-11 7550 7551 7552 7553 7554 PUN CKSM CKSM J MS 4361 1366 TAD DCA TAD AND 3366 1375 0377 TEMl SL6 /PUNCH C (AC) /LAST TWO OCTAL DIGITS I AC 6-11 7555 7556 7557 7560 JMS PUN TAD CKSM DCA CKSM JMP I BINP 4361 1366 3366 5741 PUM^ 7561 0000 7562 7563 7564 7565 7566 7567 7570 6021 53 62 PSF JMP .-1 6026 PLS JMP I 757 1 7572 7573 7574 7575 7576 7577 4.8 5761 0000 0000 0000 0000 7566 0000 0200 0000 0177 0077 PUN /PUNCH C (AC) /EXIT /ROUTINE TO PUNCH C (AC) /AND EXIT WITH C (AC) /UNALTERED /PUNCH IT /EXIT CKSM, NB, lf\> FA, M212> CTRl > -212 C200> TEMl, SL7, SL6, 200 177 77 33-ASR TELETYPE PUNCH PROGRAM To use this program with the 33-ASR Teletype, make the following changes 7466 7562 7564 6046 6041 60 46 TSF TLS /AND EXIT WITH C /PUNCH IT 4-5 (AC ) Formerly DEC-0 8-YPPA-D CHAPTER 5 OCTAL MEMORY DUMP (Octal Core Dump to Paper Tape) This program enables the user to dump, in octal, any or all data in any memory field to either the Teletype or high-speed paper During dumping the absolute address of each location being dumped is held in the accumulator. When dumping is completed output devices and memory fields can be changed to dump another tape punch. section of memory. 5.2 REQUIREMENTS This program requires one core page; initially 7400-7577. The Octal Memory Dump program runs on any PDP-8 family computer with at least 4K words of core, a 33-ASR Teletype and/or high-speed paper tape punch. The program leaves the No additional software is required. BIN and RIM Loaders untouched. 5.3 The program tapes are as follows: Binary DEC-0 8-YPPA-PB Source DEC-0 8-YPPA-PA USAGE The program is supplied in ASCII format on punched paper tape, and can be assembled by any 4K PDP-8 assembler (i.e., PAL III, MACRO- 8, or PAL-D) Vv J. uii i^iiC e lJj: O •-' jf . The origin of this program (7400) iiiJ-'w j. j-\^ j-it^^i. v^v^ j. j-xx v^x. <wxC: j. <^\^ \^ vaxhj^ can be changed j.>j>^»^»,j.%^*i~ . -->- ._?. . (See the appropriate assembler section of Programming Languages for assembly instructions.) 5.3.1 Loading The program is loaded into core with the Binary Loader (see Introduction to Programming or Programming Languages for loading procedures) and can be loaded into any available memory field. 5-1 - 5.3.2 Operating Procedures The SWITCH REGISTER on the PDP-8 console is used to control the program; all options are determined by the position of bit The 0. program can be interrupted by depressing the STOP switch. With Octal Memory Dump program in core: a. Set the SWITCH REGISTER to the starting address (7400) and the INSTRUCTION FIELD to the field containing the Octal Dump. Set DATA FIELD to the field containing the code to be dumped. Press the LOAD ADDRESS key. b. Set SWITCH REGISTER bit to 1 for a core dump to the when dumping via the high-speed Teletype punch, or to paper tape punch. c. Press the START switch. d. Set the SWITCH REGISTER to the starting address of the section of core to be dumped. e. Press the CONTINUE switch. f. Set the SWITCH REGISTER to the final core address of the section of core to be dumped. g. Press the CONTINUE switch; dumping commences and stops after dumping the contents of the final core address specified in step (f) above. The computer halts. The computer halts. Another dump can be performed at this time by continuing at step (a) when the output device or data field is to change. wise, continue at step Other- (d) The program halts after each dump. The preceding operations are illustrated in Figure 5-1. 5 . INPUT/OUTPUT The program contains its own Teletype and high-speed punch output, and there are no external I/O handlers used. bit determines the output device. 5.5 FUNCTIONAL DESCRIPTION The program is written in the PAL III language. are used in the program: 5-2 SWITCH REGISTER Four routines Load BIN Loader and Press STOP c rrx Set Start \zy ) " liigh-Speed I Set SR Bit jZf Starting Address and Data Field of Octal f4aTDry Dunp | iMdress In SrI Teletype = jg Set SR Bit I jZf = 1 - ^ Press START ^ I I Ccnputer Halts Set Start Address of Dunp In SR Press COsiT HHEZH I Coiputer Halts Set Ending Address of Dump In SR I Press CDOT I Specified Memory Is Being Dunrped -»( Figure 5-1 Finish^ Operating Procedures 5-3 a. The TOCT routine causes a number to be formatted for a typeout or punchout. b. The TCR routine outputs a carriage return-line feed. c. The TSP routine outputs a space. d. The TCHAR routine is the output routine for both the Teletype and the high-speed punch. The main routine begins with the initialization of variables, and the two address arguments are picked up from the switch register. Two carriage return- line feeds are performed, followed by the, starting address and several spaces. of eight memory locations to be output, a JMP to A loop is then entered to type the contents (if eight remain) . LPjZ(2 If more data remains repeats the process. If during this loop the routine finds that it has processed the last memory location, the loop exits, a carriage return line feed is performed, a JMP to LPi?j2f is executed, and the program halts. See the program listing that follows for more precise information. 5.6 PROGRAM LISTING / OCTAL MEf^ORY DUMP PROGRAM COPYRIGHT 1969 DIGITAL EQUIPME'^T CORP. / MAYXfARD^ MASS. /TO OPERATE: / LOAD ADDRESS 7400 ISi SR / TO CKOSE OUTPUT DEVICE: / SET BIT 0=0 EOR H. S. PUlMCH OUTPUT OR / SET BIT 0=1 EOR TTY OUTPUT TtlE'M PRESS START / SET STARTIiMG ADDRESS AMD DATA EI ELD I Nf SR -PRESS / / ONTIWUE / SET DUMP^ *7400 CLA OSR /EXAMIME SR EOR OUTPUT DEVICE SMA TAD TAD DCA /STORE A "SKP" IM SKPZ IF H. E^XIDIINJG ADDRESS AMD DATA FIELD TIWUE 7400 7401 740 2 7403 7404 MCH 740 5 7604 7700 1265 1270 3325 LI ,P00. HL T SR -PRESS COM CLA 010 C7400 SK PZ T PUT 7402 I'M C /STOP. 5-4 S. PU EMTER DUMP START IMG ADDRESS 740 6 7407 7410 7 60 4 741 1 7 60 4 7412 7413 7414 PED 7415 7416 7417 7420 7040 7421 7422 7423 7424 7425 7426 7427 7430 7431 7432 743 3 7434 7435 7436 7437 7440 7441 4312 4312 A DDR DCA I.MDEX LP01^ 126 1 4272 4320 4 320 4 320 LF02:» 1661 4272 2262 7410 JMS JMS TAD JMS JMS JMS JMS TAD JMS TCP TCR A DDR TOCT TSP TSF TSP I A DDR TOCT ISZ IiNJDE.K JMP OUT I SZ A DDR TAD A DDR 0263 7640 A^\ID 5 22 3 1261 JMP LP02 TAD A DDR 0264 A\ID C7 SZA CLA 5222 4324 OUT. 1267 127 1 3262 4324 2262 5254 / u- u u L\/ 1 Ji n r u rs .\) u iv ur j_. uu o i u t? c JJ L /TYPE CR-LES /OUTPUT STARTING ADDRESS IM OCTAL /OUTPUT 3 SPACES /GET CONiTEMTS OE LOC /TYPE OUT CC^TEMTS /DOME DUMPINJG? /YES. EXIT /MO. KICK ADDRESS UP /HAVE WE OUTPUT /MO. 8 LOGS OM A LT.^E? JMP LP02-1 TAD A DDR AXfD C177 SZA CLA JMP LP01 JMP LP01-1 JMS TCR TAD C214 JMS TCHAR TAD M20 DCA IiMDEX JMS TCHAR ISZ 1261 / VARIABLES SPACE OVER OiVE A.\ID GET MEXT - /OUTPUT CR/LF THEj.nJ ^E\n ADDRESS /OUTPUT CR/LF /OUTPUT A FORM FEED /THEM OUTPUT 20 BLAiMKS OE TRAILER IiVDEK JMP .-2 TAD A DDR JMP LP00 5205 746 0000 PED 7462 0000 DUMPED DUMP E^DIMG ADDRESS C3 SZA CLA 7 640 0266 7640 5216 5215 4312 E!\1TER SKP 5247 2261 1261 7451 7452 745 3 1 /STOP. CMA TAD 3262 126 1 746 DC A A DDR HLT LAS 1261 7442 744 3 7444 7445 7446 7447 7450 7454 7455 7456 7457 LAS 3261 7 40 2 Ai^JD /LEAVE WITH FIlnJAL ADDRESS IM AC /GO TO HALT FOR POSSIBLE RESTART COiMSTA^MTS ADDR^ /LCC OF STARTIMG ADDRESS TO BE DUM Ii\)DEX. /COUJMTER FOR DUMBER OF LOGS TO BE 5-5 7463 7464 7465 7466 7467 7470 747 1 UT 000 3 0007 0010 0177 0214 7400 7760 C3^ C7. C10^ C177^ C214> 07400^ M20^ / 7472 7473 7474 7475 7476 7477 7500 7501 7502 7503 7504 7505 7506 7507 7510 751 1 i000 7104 3344 1352 3345 1344 7006 7004 3344 1344 0264 7513 7514 7515 7516 7517 LP0 WORD M4 ISZ :\IDX 1 LEFT /SET DUMBER OF DIGITS PER WORD MDX WORD /ROTATE WORD 3 LEFT WORD WORD /MASK BITS 9- 1 /ADD 260 FOR OUTPUT /OUTPUT DIGIT /DOXIE FOUR? /IMO. PICK UP A'MOTHER DIGIT /YES. RETURM C7 1 C260 TCHAR ROUTIME TO OUTPUT A CARRIAGE RETUR-M/L I :^E FEED TCR^ TAD JMS TAD JMS JMP 346 4324 5712 0000 1350 4324 5720 DCA TAD DCA TAD RTL RAL DCA TAD AMD TAD JMS JMP LP03 JMP I TOCT / 7520 7521 7522 7523 /FORM FEED /USED TO FORM SKP COMMA^XfB /COU-MTER FOR .\fUM OF BLANKS TO OUTP CLL RAL /ROTATE ADDRESS 4324 2345 5277 5672 1 214 7400 -20 OCTAL TYPEOUT ROUTIME 1351 0000 1347 4324 10 1 77 TOCT. / 75] 2 /MASK VALUES 3 7 0215 TCHAR C212 TCHAR I TOR /OUTPUT A C. R. /OUTPUT A L. F ROUTINE TO OUTPUT A SPACE TSP^ TAD 0240 JMS TCHAR JMP I TSP /OUTPUT 5-6 A SPACE / 75 24 7525 0000 7000 ROUTI-^E TO OUlPul A ChAHACTFR TCHAR^ SKPZ^ 0"^^ TTY OR H. MOP /CHA'XIGED TO A "SKP" JMP TCHl PLS OLA TAD ADDR /OTHERWISE GO TO TTY S. PO.\]CH IF H. S. OUTPU 1 7526 7527 7530 7531 5335 6026 7200 7532 7533 7534 7535 7536 7537 7540 6021 7541 7542 7543 126 1 5332 5342 6046 TCHl^ 7 200 1261 6041 5340 7200 TCH2^ 5724 / PSF JMP JMP TLS CLA TAD TSF JMP CLA JMP VARIABLES /KEEP ADDRESS I;.\J OUTPUT AC WHILE PUNCHIIMG .-1 TCH2 /TTY OUTPUT ROUTIME ADDR .-1 I TCHAR AinJD C0l\) STAiM TS 7544 0000 WORD. /STORAGE FOR DIGIT TO BE FORMATTED 7545 7546 0000 0212 0215 0240 NDX. C212. C215. C240. C260. M4. /COU'^ITER 7547 7550 7551 75 5 2 260 77 74 212 215 240 260 -4 FOR MUM OF DIGITS OUTPUT /code for lime feed " " carriage returm / / " " " " space; formatting digits /number of digits per word / 5-7 CHAPTER 6 TELETYPE I/O SUBROUTINES 6 . ABSTRACT The routines described in this chapter are illustrative of the procedures to be followed in creating I/O routines to be used with The user is advised to peruse these routines the ASR-33 Teletype. prior to writing I/O routines tailored for his particular needs. Subroutines are provided which perform input and output of character These routines are strings and single alphanumeric characters. illustrative and by no means exhaustive of routines to handle the ASR-33 Teletype. 6.2 REQUIREMENTS The routines as supplied require 124^ (174^) core locations. The Teletype I/O Subroutines run on any PDP-8 family computer with an ASR-33 Teletype console. The program is distributed as an ASCII tape as follows: DEC-0 8-FIKA-PA 6 . 6.3.1 USAGE Assembly The routines as supplied will be automatically assembled onto the first available core page. There is no $ character at the end of the tape; although a PAUSE statement is present to allow for the later loading of additional programs, if any. This collection of subroutines can be assembled with PAL III, PAL-D, PALS, or MACRO-8. (If using the tape with TSS/8, remove the PAUSE statement from the end of the tape.) If the routines are to be assembled separately program), they will assemble at location 200. 6-1 (without a user In this case, the user should append a separate tape with a $ character to the end of the Teletype I/O Subroutines tape before assembly. If the routines are to be assembled with a user program (such as the example program in section 6.6), the Teletype I/O Subroutines tape should be loaded after the user program and the whole followed by a tape with a $ character. In this case, the I/O sub- routines will fit on the first available free core page and will not overlay the user program. (Tapes can be loaded after the I/O routines if allowance is made for the length of the routines or by assigning a specific address to the beginning of the I/O routines.) Calling Sequence 6.3.2 The calling sequence for the Subroutines is designed so that the user can easily incorporate messages into his program. The user inserts a series of JMS instructions to the I/O routines followed by the address of the message to be transmitted. The subroutines the user is likely to call are as follows: Subroutine TYPX Purpose Calling Sequence Prints a message. Message is coded by programmer if using PAL III, or set in a labeled TEXT pseudo-op statement if using PAL-D, PALS, or MACRO- 8. ENTRY, TLSX Prints a single character, used by TYPX to print message, character by character. Subroutine is entered with character to be printed in AC bits 6 to 11. KREAD Inputs a message. KREAD accepts ENTRY, 8-bit ASCII and does not convert to 6-bit ASCII, therefore TYPX cannot directly cause a message read by KREAD to be printed, although a simple routine to do so can be written by the user. Remember, the size of the input buffer must include the carriage return character. 6-2 JMS TYPX POINTER /ADDR OF /MESSAGE /EXIT IS TO /ENTRY+2 WITH /AC CLEAR JMS TLSX /CHAR IN AC /BITS 6 TO 11 JMS KREAD POINTER /ADDR OF /INPUT BUFFER -LENGTH /-SIZE OF /INPUT BUFFER /EXIT IS TO ENTRY+3 /WITH AC CLEAR /ZERO PLACED AT /BUFFER END Subroutine Purpose KRBX Inputs single character from Teletype, exits with character read in the AC. '^t-iicj. J- v-(i-i ojLiico pjLuvj.cicu. Callincr Se'^uence j.iiuj.uu.fc; j\x%.uiD , ENTRY, JMS KRBX /EXIT IS TO /ENTRY+1 WITH /CHAR READ IN AC wiixuii ufcjxeteb tue ±asT: character in the input buffer when the RUBOUT key is typed. This routine is not necessary to Teletype I/O but allows for erasing of typing mistakes and also performs echoing. If the user rubs out characters past the beginning of the input buffer, a carriage return/line feed is performed as a warning. 6.4 RESTRICTIONS The user program must initialize the teleprinter flag before calling these subroutines. CLA TLS Initialization is performed as follows /SET AC TO ZERO, GOOD PRACTICE /INITIALIZE TELETYPE The routines can only be called from the memory field in which they reside. The following characters have special meaning to the output subroutines 6-bit value Character 00 (3 37 ^ Purpose Marks the end of a message; supplied via the TEXT pseudo-op when using PAL-D, PALS, or MACRO-8. Must be supplied by user if using PAL III. Causes a carriage return-line feed to be output to the Teletype. The following characters have special meaning to the input subroutine: 6-3 Character Purpose 212 LINE FEED Ignored on input. 000 null Ignored on input. 377 RUBOUT Deletes the previous character typed, echoes a backslash after the first RUBOUT typed and a closing backslash after the first non-RUBOUT character typed. 215 RUBOUT Echoes a carriage return/line feed and exits from the input subroutine to the user program (calling program) 8-bit value On input buffer overflow while reading characters into the Teletype buffer, characters echo as "bell" Teletype rings) . (the bell within the All characters other than RETURN and RUBOUT are lost if typed while "bell" is being rung as a warning. 6.5 DESCRIPTION Table 6.1 shows the ASCII values of the characters which can be used with the supplied Teletype I/O Subroutines. When using PAL III, the user must code these ASCII values at the location referenced by the output routine. The PAL III assembler reads the ASCII codes directly as octal numbers. PAL-D, PALS, and MACRO- 8 can use the TEXT pseudo-op to directly format alphanumeric characters into ASCII code. The TEXT pseudo-op puts the desired message into 6-bit ASCII format; the routines convert the 6-bit ASCII to the printable 8-bit ASCII and then output the message. If the user were outputting the message HELLO, it would be done as follows, where MESG is the location given for the message: PAL III MESG, PAL-D, MACRO- 8, or PALS 10j2f5 1414 17j?j? /HE /LL /O END OF /MESSAGE CODE MESG, TEXT/HELLO/ 6-4 TABLE 6 . 6-BIT ASCII CHARACTER SET FOR INPUT WHEN USING THE PAL III ASSEMBLER, 8-BIT ASCII FORMAT IS ALSO SHOWN FOR COMPLETENESS. Character 6-BIT Value 8-BIT Value n UX 02 03 04 05 06 07 10 11 12 13 14 15 16 17 20 21 22 23 24 25 25 27 oux 302 303 304 305 306 307 310 311 312 313 314 315 316 317 320 321 322 323 324 325 326 327 330 331 332 260 261 262 263 264 265 266 267 270 271 -1 i-i B C D E F G H I J K L M N P Q R S T U V w X Y Z 1 2 3 4 5 6 7 8 9 30 31 32 60 61 62 63 64 65 66 67 70 71 Character • II # $ % & 1 ( 8-BIT Value A 1 IX 42 43 44 45 241 242 243 244 245 246 247 250 251 252 253 254 255 256 257 272 273 274 275 276 277 300 333 334 335 336 337 200 212 215 240 377 000 207 211 214 46 47 50 + 51 52 53 f 54, ) * , / • 7 <' \ > '? h [ ] i <- leader tape LINE FEED RETURN SPACE RUBOUT blank BELL TAB FORM 6-5 6-BIT Value 55 56 57 72 73 74 75 76 77 00 33 34 35 36 37 40 The same results are achieved in both cases. The TEXT pseudo- op performs all of the necessary operations in the case of PAL-D, PALS, and MACRO- 8 which the programmer must perform if using PAL III. The input routines echo characters typed at the keyboard, accept 8-bit ASCII characters (as they come from the Teletype keyboard) for internal storage, and allow character editing via Once the RETURN key is typed, no further input the RUBOUT key. is accepted from the keyboard until the next time such input is requested by the calling program. Additional information on these routines and their usage can be found by reading through the listing (section 6.7) and by reading Chapter 5 in Introduction to Programming 1970. , 6.6 EXAMPLE PROGRAM The following example program was assembled with the Tele- type I/O Subroutines as shown in section 6.7 (PROGRAM LISTING). The demonstration program was loaded prior to the I/O routines. If no program had preceded the I/O routines they would, of course, have started at location 200 (instead of location 400) The output of the demonstration program is shown below: FLEASE TYPE YOUR NAME HERMAN IT IS A PLEASURE TO MEET YOU* HEP^AN The computer causes PLEASE TYPE YOUR NAME and a carriage return/line feed to be output. The user types his name on the keyboard, enters it with the RETURN key, and the computer then prints a carriage return/line feed followed by IT IS A PLEASURE TO MEET YOU, HERMAN 6-6 The program as input to the Assembler (PAL-D in this case) looks as follows /DEMONSTRATION OF TTY I/O SUBROUTINES / *200 START* LOOP* DONE* TLS JMS TYPX MESGl JMS KREAD INAREA -20 JMS TYPX MESG2 TAD (INAREA-1 DCA 10 CLA CLL TAD I 10 SNA JMP DONE JMS TLSX JMP LOOP HLT JMP START /ADDRESS OF START OF PROGRAM /INITIALIZE TELEPRINTER FLAG /PRINT A MESSAGE /••PLEASE TYPE YOUR NAME'' /READ IN REPLY /UP TO 16 CHAR* 1 PER WORD /BEGINNING IN INAREA /PRINT SECOND MESSAGE /••IT IS A PLEASURE TO MEET YOU* " /SET AUTO INDEX REGISTER 10 TO /ADDRESS WHERE NPME IS STOREDC-1) /BEGIN PRINTING THE NAME /GET A CHARACTER /TEST FOR ZERO /IF ZERO* ALL DONE--QUIT /ELSE PRINT A CHARACTER /IT IS A GOOD PRACTICE TO PUT /A JMP TO SOMEWHERE AFTER THE /HLT AT THE END OF A PROGRAM /IN CASE SOMEONE INADVERTANTLY /HITS •'CONTINUE^^. MESGl* TEXT /^-PLEASE TYPE YOUR NAME-/ MESG2* TEXT /-IT IS A PLEASURE TO MEET YOU* / INAREA* /INPUT AREA FOR NAME The demonstration program assembled with PAL-D looks as follows /DEMONSTRATION OF TTY I/O SUBROUTINES *200 0200 0201 0202 0203 0204 0205 0206 0207 0210 6046 4777 0222 4776 0256 7760 4777 0236 1375 START. TLS JMS TYPX MESGl JMS KREAD INAREA -20 ^^S TYPX MESG2 TAD (INAREA-1 OF START OF PROGRAM /INITIALIZE TELEPRINTER FLAG /PRINT A MESSAGE /••PLEASE TYPE YOUR NAME** /READ IN REPLY /UP TO 16 CHAR* 1 PER WORD /BEGINNING IN INAREA /PRINT SECOND MESSAGE /••IT IS A PLEASURE TO MEET YOU* /SET AUTO INDEX REGISTER 10 TO 6-7 02 U 0212 0213 0214 0215 0216 0217 0220 0221 0222 0223 0224 0225 0226 0227 0230 0231 0232 0233 0234 0235 0236 0237 0240 0241 0242 0243 0244 0245 0246 0247 0250 0251 0252 0253 0254 0255 0256 3010 7300 LOOP, 1410 7450 5220 4774 5212 7402 5200 DONE, 3720 1405 0123 0540 2431 2005 4031 1725 2240 MESGl, LE AS 1601 1505 3700 NA ME -/ /ADDRESS WHERE NAME IS STORED(-l) /BEGIN PRINTING THE NAME /GET A CHARACTER /TEST FOR ZERO /IF ZERO, ALL DONE-- QUIT /ELSE PRINT A CHARACTER /IT IS A GOOD PRACTICE TO PUT /A JMP TO SOMEWHERE AFTER THE /HLT AT THE END OF A PROGRAM /IN CASE SOMEONE INADVERTANTLY /HITS "CONTINUE". TEXT /-P E TY PE Y OU R 3711 MESG2, 2440 T 1123 IS 4001 4020 A 1405 LE 0123 2522 0540 2417 4015 0505 2440 3117 2554 4000 0000 DCA 10 CLA CLL TAD I 10 SNA JMP DONE JMS TLSX JMP LOOP HLT JMP START TEXT /-I P AS UR E TO M EE T YO U, / I N AREA, /INPUT AREA FOR NAME 6-8 6.7 PROGRAM LISTING As explained in section 6.6, this listing of the I/O routines was made following the example program shown in that section. These routines can start at any address if the user changes the starting address or will start at the beginning of the first free page after any programs loaded previously. /BASIC TELETYPE I/O SUBROUTINES /REVISION: 18-JAN-7 1 /GWB /COPYRIGHT 1971 DIGITAL EQUIPMENT CORPORATION MAYNARD* MASSACHUSETTS 01754 / /THESE SUBROUTINES ILLUSTRATE TYPICAL METHODS OF USING THE /STANDARD TELETYPE TO INPUT AND OUTPUT ALPHANUMERIC DATA /ON A PDP-8 FAMILY COMPUTER. --NOTES— / / / PRINTER FLAG BEFORE CALLING THESE SUBROUTINES. / / (2) THESE ROUTINES MAY ONLY BE CALLED FROM THE FIELD IN WHICH THEY RESIDE. (1) THE USER PROGRAM MUST INITIALIZE THE TELE- /ORIGIN TO NEW PAGE *.-l 177+1 /SUBROUTINE TO TYPE MESSAGES. /THIS SUBROUTINE PRINTS A MESSAGE TO BE STORED IN STRIPPED /SIX=BIT ASCII, TWO CHARACTERS PER WORD. THIS FOP-MAT /CAN BE EASILY GENERATED BY USING THE "TEXT" PSEUDO-OP IN /PROGRAMS ASSEMBLED BY PALD* PAL8, OR MACRO-8. /ENTRY* JMS TYPX POINTER (ADDRESS OF MESSAGE) /EXIT IS TO ENTRY+2 WITH THE AC CLEAR. / 6-9 — NOTE /THE FOLLOWING CHARACTERS HAVE SPECIAL MEANINGS: COMMENTS /VALUE CHARACTER MARKS THE END OF MESSAGE* THE TEXT / 00 / / / PSEUDO-OP INSERTS THIS CHARACTER. CAUSES A CARRIAGE RETURN/LINE FEED 37 TO BE OUTPUT. 0400 0401 0402 0403 0404 0000 7300 0405 0406 0407 0410 0411 0412 0413 1616 TYPX* CLA CLL TYPX TAD I TYPNT DCA TYPX ISZ 1600 3216 2200 TYPXl* 7012 7012 7012 4217 1616 2216 0414 0415 4217 5205 0416 0000 /GET POINTER /AND SAVE IT LOCALLY I TYPNT /GET LEFT HAND CHARACTER /THIS CAN BE CHANGED TO A /BYTE SWAP ON THE PDP-8E! I ISZ TYPY TYPNT TYPNT /CONVERT AND TYPE /GET RIGHT HAND CHARACTER /MOVE POINTER TO NEXT WORD JMS JMP TYPY TYPXl /CONVERT AND TYPE /CONTINUE UNTIL DONE. TAD RTR RTR RTR JMS TAD /POINTER TO STRING TYPNT* /THIS SUBROUTINE IS CALLED BY "TYPX" (AND "HRBX"!)-/ENTER WITH THE CHARACTER TO TYPE IN AC6- 1 1 / (1) TESTS FOR TERMINATOR (00) / (2) TESTS FOR CR-LF (37) CHARACTER / (3) CONVERTS CHARACTER TO 8-BIT ASCII AND TYPES IT 0417 0420 0421 0422 0423 0424 0425 0426 0427 0430 0000 0236 7450 5600 0431 0432 0433 0434 0435 7510 TYPY* AND SNA JMP TAD SZA JMP TAD JMS TAD 1237 7440 5231 1240 4244 1241 1242 1243 4244 5617 TYPYl* SPA TAD TAD JMS JMP TK77 I TYPX TKM37 TYPYl TK215 TLSX TKM125 I TK100 TK237 TLSX TYPY 6-10 /MASK OFF CHARACTER /TEST FOR TERMINATOR /EXIT IF TERMINATOR /TEST FOR CR-LF /NOT A 37 /TYPE A -CR- /CONVERTS TO A -LF- (212) /TEST RANGE /RANGE IS 301-336 /RANGE IS 240-277 /TYPE CHARACTER 0436 0437 0440 0441 0442 0443 mil 7741 0215 7653 0100 0237 TK77* TKM37* TK215* TKM125* TK100, TK237* /MASK FOR AC6-11 /TEST FOR CR-LF CHARACTER /ASCII VALUE OF -CR/THIS PLUS 337 = 212 -LF/CONVERT TO RANGE 301-336 /CONVERT TO RANGE 240-277 77 -37 215 -125 100 237 /TELETYPE OUTPUT SUBROUTINE. /ENTER WITH CHARACTER IN THE AC. / --NOTE-/THE TELETYPE FLAG MUST BE INITIALIZED /BEFORE CALLING THIS SUBROUTINE! 0444 0445 0446 0447 0450 0451 0000 6041 5245 6046 7200 5644 TLSX, TSF JMP TLS CLA JMP -1 I /WAIT FOR TELETYPE READY TLSX /TELETYPE INPUT SUBROUTINE. /EXIT WITH CHARACTER READ IN THE AC. 0452 0453 0454 0455 0456 0000 6031 5253 6036 5652 KRBX* KSF JMP KRB JMP .-1 I /WAIT FOR CHARACTER KRBX /TELETYPE INPUT SUBROUTINE. /THIS SUBROUTINE DEMONSTRATES HOW TO INPUT /ALPHANU-MERIC CHARACTERS FROM THE TELETYPE. IT READS /THE CHARACTERS INTO A BUFFER, ECHOES CHARACTERS TYPED, /AND PERFORMS MINOR EDITING: / (1) CHARACTERS NULL(200 AND 000) AND LINE FEED / ARE DELETED ON INPUT. / (2) CHARACTER RUBOUT (377) DELETES THE PREVIOUS CHARACTER TYPED. IT ECHOES AS A BACKSLASH FOLLOWED / / / BY THE CHARACTER DELETED (MULTIPLE RUBOUTS DO NOT ECHO BACKSLASH AFTER THE FIRSTS A NON-RUBOUT CHAR- / ACTER CAUSES A "CLOSING" BACKSLASH TO BE PRINTED). /THE CHARACTt«CAKRl AGE RETURN TEP?MINATES INPUT. /ECHOES AS A CARRIAGE RETURN FOLLOWED BY A LINE FEED. 6-11 IT KREAD /ENTRY* JMS (ADDRESS OF INPUT BUFFER) POINTER -LENGTH (MINUS SIZE OF INPUT BUFFER) /EXIT IS TO ENTRy+25 ON EXIT: / ( 1) AC IS CLEAR. / (2) A TERMINATING WORD OF ZERO IS PLACED IN THE / INPUT BUFFER (THE CARRIAGE RETURN IS NOT ENTERRED / IN THE BUFFER). / / --NOTE-- / /ON BUFFER OVERFLOW* CHARACTERS WILL BE ECHOED AS "BELL" /TO INFORM USER THAT BUFFER IS FULL. ALL CHARACTERS* /OTHER THAN CARRIAGE RETURN AND RUBOUT* ARE LOST. /THIS SUBROUTINE IS WRITTEN TO CO-RESIDE WITH THE TELETYPE /OUTPUT SUBROUTINES "TYPY" AND "TLSX". 0457 0460 0461 0462 0463 0464 0465 0000 7300 0466 0467 0470 0471 4252 3616 KREAD* CLA CLL TAD I KREAD KREAD ISZ DCA KRPNT KREAD TAD I DCA KRCNT 1657 2257 3216 1657 3200 1360 3345 KRBl* JMS DCA I TAD DCA /ENTER SCANNING KRB3* TAD /GET CHARACTER /SAVE CHARACTER /LOAD POINTER TO TABLE /INTO TEMP. STORAGE KRPNT KRBKS /ADD IN CURRENT CHARACTER /ADVANCE INDEX TO JMP WORD 0472 1616 2345 ISZ 0474 7650 5745 2345 SNA CLA KRBKS JMP I 1745 TAD SZA JMP 047 5 0476 0477 0500 0501 7440 5272 0502 0503 0504 4345 2200 5312 0505 0506 0507 0510 4244 7240 0511 1356 1200 5265 ISZ I /SET UP POINTER /GET SIZE OF BUFFER /SET UP COUNTER KRBX KRPNT KRTAB KRBKS LOOP. 047 3 I /GET ADDRESS OF BUFFER KRBKS KRBKS KRB3 /CALL SPECIAL ROUTINE /GO ON TO NEXT ENTRY /GET TABLE ENTRY /ZERO MARKS END OF TABLE /CONTINUE SCAN /NORMAL CHARACTER ROUTINE /CHECK FOR BUFFER OVERFLOW* ECHO CHARACTER* AND /RETURN TO FETCH NEXT CHARACTER. JMS KRBKS /ECHO BACKSLASH IF NEEDED ISZ KRCNT /TEST FOR BUFFER OVERFLOW JMP KRB6 /NORMAL ROUTE /BUFFER OVERFLOW TAD TK207 /ECHO "BELL" KRB5* JMS TLSX CLA CMA /DECREMENT CHAR COUNTER TAD KRCNT JMP KRBl/RETURN TO GET NEXT CHAR 6-12 0512 0513 0514 0515 1616 2216 4244 5266 KRB6^ TAD I ISZ JMS JMP KRPNT KRPNT TLSX KRBl /GET CHARACTER /ADVANCE BUFFER POINTER /ECHO CHARACTER /RETURN TO GET NEXT CHAR /RUBOUT ROUTINE-/THIS ROUTINE IS CALLED WHEN A RUBOUT IS typed; IT DELETES 0516 0517 0520 0521 0522 0523 0524 0525 0526 0527 0530 0531 0532 7240 4345 2355 1657 7041 1200 7650 5333 7240 1216 3216 1616 5306 0533 0534 0535 4217 4345 0536 5266 1243 0537 4345 0540 0541 0542 0543 0544 1243 4217 3616 8257 5657 /THE LAST CHARACTER IN THE BUFFER, RESET THE POINTERS* /AND DOES SOME FANCY ECHOING. KRUB> CLA CMA /REVERSE RUBOUT FLAG TEST JMS KRBKS /EHCO BACKSLASH IF NEEDED ISZ KRFLAG /SET RUBOUT FLAG TAD I KREAD /CHECK FOR "EMPTY" BUFFER CIA TAD KRCNT /BY COMPARING COUNTERS SNA CLA JMP KRUBl /NO RUBOUT PAST BEGINNING CLA CMA TAD KRPNT /DECREMENT BUFFER POINTER DCA KRPNT TAD I KRPNT /GET CHARACTER TO ECHO JMP KRB5 /ECHO CR-LF- BACKSLASH ON ATTEMPT TO RUBOUT PAST THE START /OF THE INPUT BUFFER. KRUBl, TAD TK237 /LOOKS LIKE A "-"! JMS TYPY /FORCES A CR-LF JMS KRBKS /ALWAYS FORCES A BACKSLASH JMP KRBl /CARRIAGE RETURN ROUTINE-/THIS ROUTINE IS CALLED WHEN A CARRIAGE RETURN IS TYPED; /ECHOES CR-LF> DEPOSITS IN INPUT BUFFER* AND EXITS. KRCR* JMS KRBKS /ECHO BACKSLASH IF NEEDED TAD JMS DCA I TK237 TYPY KRPNT /LOOKS LIKE A /FORCES A CR-LF /STORE ZERO IN BUFFER I KHEAD KREAD /AND EXIT. IS2 JMP ' ! 6-13 /THIS SUBROUTINE ECHOES BACKSLASH WHEN KRFLAG IS NON-ZERO /NOTE-- LOCATION "KRBKS" IS ALSO USED AS A TEMPORARY 0545 0546 0000 0547 7640 0550 0551 0552 0553 0554 7440 4244 3355 5745 0555 0000 KRBKS* KRFLAG TAD SZA CLA TK334 TAD SZA TLSX JMS KRFLAG DCA KRBKS JMP I 1355 1357 /GET FLAG /BACKSLASH CHARACTER /TYPE A BACKSLASH /CLEAR FLAG /EXIT /SET TO +1 IF A RUBOUT WAS KRFLAG* /LAST CHAR* OTHERWISE 0. 0556 0557 0207 0334 /SAVE A COUPLE LOCATIONS BY USING TYPX AND TYPNT. /POINTER TO INPUT BUFFER KRPNT=TYPNT /MINUS NO. OF WORDS LEFT KRCNT=TYPX /BELL IS ASCII 207 207 TK207* /BACKSLASH IS ASCII 334 334 TK334* /SPECIAL CHARACTER TABLE/ENTRIES IN THIS TABLE ARE TWO WORDS LONG; -VALUE OF CHARACTER / (WORD 1) JMP TO PROPER ROUTINE (WORD 2) / /THE TABLE IS TERMINATED BY AN ENTRY OF 0. 0560 0560 0561 0562 0563 5266 7600 5266 7 566 5266 7563 5337 7401 5316 0000 0564 0565 0566 0567 0570 0571 0572 KRTAB* /NULL -- IGNORE JMP KRBl -2005 JMP KRBl -2125 JMP KRBl -2155 JMP KRCR -3775 JMP KRUB /NULL -- IGNORE /LINE FEED -- IGNORE /CARRIAGE RETURN -- EXIT /RUBOUT -- DELETE CHARACTER /DENOTES END OF TABLE. PAUSE 6-14 Formerly Digital-8-16-S CHAPTER 7 MASTER TAPE DUPLICATOR/VERIFIER "7 ABSTRACT This program duplicates and verifies 8-channel paper tapes using a PDP-8 family computer with high-speed reader and high-speed punch. the punch to operate at maximum speed. The program accumulates two types of checksums while reading and punching: 1) the number of nonzero characters on the tape, and 2) the sum of characters on the tape (both are taken modulo 4096) When duplicating, the program compares the checksums at the end If of the tape with the checksums accumulated by the read routine. these differ, a reader error has occurred and a message is printed. Tapes are verified by reading them and comparing accumulated checksums with those at the end of the tape. Only master tapes produced by the program can be duplicated. The master tape has the two checksums punched at the end. 7.2 REQUIREMENTS The program uses all of memory, except for the last page, as a buffer. The Master Tape Duplicator program runs on any PDP-8 family computer with high-speed reader and high-speed punch. The program tapes are as follows: 7 . 7.3.1 Binary DIGITAL-8-16-S-BIN Source DIGITAL -8-16-S-ASC USAGE Loading The program is loaded with the Binary Loader (see Introduction 7-1 to Programming or Programming Languages for details) To Produce a Master Tape 7.3.2 A tape is read and duplicated by the punch. When the tape has run out of the reader, the accumulated checksums are punched. The tape that has been punched is the master tape used for duplication. It should be compared against the original to ensure that the tape was read correctly. 7.3.3 To Duplicate the Master Tape The master tape that has been produced (see 7.3.2) is reproduced by the punch. Checksums are accumulated by the read routine and are compared with the checksums at the end of the tape. Checksums are punched and are used for verification (see 7.3.4). If the master tape is short enough to fit into the buffer, the program will notify the operator that more copies can be made without rereading the master. Blank tape is punched between copies. 7.3.4 Verify Duplication Similar to duplication, but no punching takes place. Tapes are read and the accumulated checksums are compared against the checksums punched at the end. 7 . 4 OPERATION PROCEDURES a. Set the SWITCH REGISTER to 200. b. Press the LOAD ADDRESS key; press the START key; the program halts. c. Set SWITCH REGISTER for the mode of operation as follows: 0=1 Bit 1=1 Bit 2=1 Bit Make master tape Duplicate master tape Verify duplication d. Place tape in reader starting on blank tape (all modes of operation must be started with blank leader tape in the reader) e. Turn reader on. f. Press the CONTINUE key. g. The program prints a message when the operation has been completed and then halts. Turn punch on. 7-2 h. 7.5 Proceed from step made (c) unless multiple copies are being DESCRIPTION This program uses the program interrupt to keep the reader and the punch running at full speed. The reader fills a buffer and the punch punches from it. Checksums are accumulated by both the reader and the punch routines. 7-fi KTHTF OM "PYTPa RT.aM'K' PT?aMT?c: TM r\rTDT Tr'T^nrcr^ mTvn-dC The Master Tape Duplicator does not check for extra blank frames in the duplicate tape. A future version of this program will perform such a check. Until this version is released, users with tape Digital-8-16-S having difficulty with binary tapes which load and verify properly but do not run properly should order tape and document number 5-10 from the DECUS Program Library. The document is called Paper Tape Reader Tester. It is a program for the PDP-5, but will run on the PDP-8 and should be used as a second verifying operation. Programs which are too long for the space left in core should be broken into two or more shorter tapes for this operation. 7-3 7 . 7 PROGRAM LISTING OIGir^L £jJIf^'1i^f /COPf^IGHT 1971 /;vjAr^lAK':)> COr^r^O <A FI O.M ^AS:i^GHJ5^rfS /TAPE DUPLICATOR FOR PDP-5/S / -DEC-1/15/65 /SINGLE BUFFERING-HEAD AND PUNCH UTILIZING /PROGRAiV} INTERRUPT /COMPUTE A CHARACTER COUNT AND CHECK SU'^ /FOR EACH TAPE-COMPARE WITH CHECKS AT /END OF TAPE /CHECKS ARE ALSO COMPUTED DURING PUNCHING /AND COMPARED /THREE MOOES OF OPERATION: ON-MAKE MASTER TAPE /A. SWITCH ON-DUPLICATE MASTER TAPE /B. SvaiCH /C. SWITCH 2 ON- VERIFY DUPLICATION /DURING DUPLICATION, THE PROGRAM WILL NOTIFY /THE OPERATOR WHETHER OR NOT MORE COPIES /CAN BE MADE WITHOUT RE-READING THE /MASTER /DEFINITIONS OF INTERRUPT LOCATIONS: /FOR THE PDP-8J INTER=0 /FOR THE POP- 5; INTER=1 /PAGE INTER=0 1 1 *INTER+ 3001 0002 0003 0004 5020 0632 0600 0615 0016 0017 0020 0000 0000 0021 0022 7410 5431 0023 0024 0025 0026 0027 0030 0031 0032 0033 0034 0035 0036 0037 6021 601 1 7410 5434 4567 0000 5400 0000 6014 5027 0000 6026 7230 5027 1 NPNT, JMP HNDL DPRT El, E2, TES2 /HANDLE INTERRUPT TESl *16 NDXR, /AUTO-INDEX REGISTER /AUTO-INDEX REGISTER iMDXP, HNDL, DSMS* RSF SKP JMP PSF SKP JMP JMS ION JMP READ /750 CAUSED INTERRUPT I PNC CRLF I INTE /7 5A PUNCH CAUSED INTERRUPT /EXTRANEOUS-CLEAR FLAGS /ENABLE INTERRUPT /RETURN /CALLED AS A /SUBROUTINE TO PROVIDE /RETURN ADDRESS /CALLED AS SUBROUTINE /PROVIDES RETURN I I READ, RFC JMP DSMS PNC, PLS CLA JMP DSMS 7-4 0040 0041 0042 0043 0044 0045 004 6 0047 00 50 0051 00 52 0053 0054 0055 0056 0057 0060 1417 7510 5570 3143 1 143 7440 2145 7000 1 147 3147 1 143 4034 5040 6012 3J42 5105 1 7440 2144 00 63 70'30 0064 1 0065 3146 0066 0067 00 7 007 1 00 72 0073 0074 00 7 5 0076 0077 0100 0101 0132 0103 0134 0105 0136 0107 01 10 01 1 1 01 12 t RSTl* 146 160 3157 7410 5155 1 RDl 142 0062 0061 PNCH* RST2# J,^P 3416 2163 7410 ;M64 5055 7240 3175 5040 JiMP FRST, 161 7640 5060 1 153 01 13 01 14 3057 5060 1142 0115 1 162 01 16 7640 0117 0120 0121 0122 Si 23 1154 3057 5060 /GO GET NEXT /READ 750 BUFFER /SAVE IT /OF "SCND" OR "THRD" /COUNT MODULO 409 6 /ACCUMULATE SUM /RESET END-OR-TAPE TIMER VY /GET CHARACTER /PUT IN BUFFER /IS BUFFER FULL? /NO /YES /FETCH NEXT CHARACTER /DELAY START OF PUNCHING I 5571 4031 1 /COUNT NON-ZERO CHARACTERS /MODULO 409 6 /ACCUMULATE SUM MODULO 4096 TAD HLDl DCA NDXR ISZ RCNT SKP JMP I FUL J>1S READ ISZ STRT 142 1142 /GET NEXT CHARACTER /IF IT IS 7777, IT /IS END OF TEXT TAD I NDXP SPA JMP I PDUN OCA HLD2 TAD HLD2 SZA ISZ ZROP NOP TAD CHKP OCA CHKP TAD HLD2 JMS PNC JMP PNCH HRB DCA HLDl Jf^P FRST TAD HLDl SZA ISZ ZROR NOP TAD CHKR DCA CHKR TAD TIME DCA 1 1 MR SKP SCiMD* RDl CLA CMA OCA SCON Ji^P PNCH TAD HLDl TAD TSTl SZA CLA JHP RST1^1 TAD TRY2 DCA RSTl JMP RSTl+1 TAD HLDl TAD TST2 SZA CLA JHP • i-4 TAD TRY3 DCA RSTl JMP RSTl+1 /START PUNCHING /TEST TO SEE IF /CHARACTER IS FIRST /IN CHECK- SUM IDENTIFIER /IF IT IS-SET SWITCH /TO TEST FOR SECOND /CHARACTER NEXT /CHECK FOR SECOND CHARACTER /IDENTIFIER - IF FOUND /TEST FOR THIRD NEXT 7-5 0123 0124 0125 0126 0127 0130 0131 0132 0133 0134 0135 0136 0137 0140 0141 0142 0143 0144 0145 0146 0147 0150 151 0152 0153 0154 0155 0156 0157 0160 0161 52 5121 142 1161 7 6 40 1 I 1 5123 7240 3416 4541 3151 4541 3150 5 540 0303 0565 0000 0000 0000 0000 0000 0000 0000 0000 5105 THRD, TAD JMP TAD TAD SZA HLDl TSTl CLA J(^P .-5 TRYl .-3 CLA CMA OCA I iMDXR JMS I GETl DCA MCHK J.VJS I /GET 12-BIT WORD NON-ZERO READ NON-ZERO PUNCHED /CHECK SUM - READ /CHECK SUM - PUNCH /#0F NON-ZERO MEASURED /CHECK SUM - MEASURED /f^OF /itOV i^CHK, TIMR* TIME* TSTl, 7526 0162 7653 TST2* 7653 0163 0164 0165 0166 3167 0170 0171 0172 0173 0174 0175 0176 0177 0000 0000 7000 7410 0345 0000 0320 RCiMT* 0000 0000 0000 0377 0002 /MEASURED ZERO-COUNT HLDl, HLD2* ZROR> ZROP* CHKR, CHKP, ^ZRO, 5055 0000 0000 7526 00 7 7 /MEASURED CHECK- SUM GETl 11 GETU 4031 5125 /SET END-OF PUNCH FLAG DCA MZRO JMP I .-n SWT GET TRYl* TRY2> TRY 3* VY* 51 14 /TEST FOR THIRD CHARACTER /l^ IDENTIFIER - IF FOUND /READ CHECKS FROM TAPE /IF NOT - RESET FOR FIRST STRT* NOPT* SKIP> CRLF* PDUN, FUL, BIT6, DCON, JMP FRST JVJP scm JMP THRO JMS READ JMP RDl /WHEN VERIFY I NG-DON' START /PUNCHING /2'S COMPLEMENT 1ST AND /THIRD IDENTIFIER /TWO'S COMPLEMENT OF 2ND /IHENTI FI ER NOP SKP CFLG 8FUL 007 7 VCt^T* SCON, 0311 TWO* /START OF PUNCHING FLAG 037 7 0002 7-6 *2i 0200 0201 0202 0203 0204 020 5 ltJC-)£J U 0207 0210 021 1 7200 3174 7200 3144 3145 3146 O 1 3173 6012 6022 7200 3175 3057 0221 3303 022 5 0226 0227 0230 0231 0232 0233 0234 0235 0236 1 1 152 166 3070 1 166 1341 3164 7402 7604 7004 7430 5250 7 004 7430 7402 7004 7630 L0P1> 3303 0243 0244 0245 0246 3070 1342 3336 024 7 0250 0251 526 1 7200 343 02 52 02 53 3336 3174 0254 0255 0256 0257 0260 5261 7200 1344 3336 3174 1 /RESET PUNCH* READER /COi^PUTED CHECKS r«LJiy^o /RESET BUFFER OVER FLAG /CLEAR HARDWARE FLAGS DCi SCON TRYl Z RSTl Z SKIP Z RST2 Z SKIP SwTl DLAY Z STRT /RESET START PUNCH FLAG /SET PROGRA^I SWITCHES Z /SET START OF PUNCHING DELAY OSR SZL /BIT 0=1* CREATE MASTER SZL JiV]P 7040 5224 1 DCA RRB PCP CLA DCA TAD DCA TAD OCA TAD DCA TAD DCA HLT CLA RAL /RESET VERIFY COUNT JMP CRTE RAL 5241 023 7 0240 024 0242 1 -7 /. "7 0212 0213 0214 0215 0216 0217 0220 0222 0223 0224 LOOP* CLA DCA Z VCiMT CLA DCA ZROR DCA ZROP DCA Z CHKR 165 165 CRTE* 1 OUP. DUP RAL SZL JHP CM A JMP TAD DCA TAD DCA TAD DCA LOPl NOPT SWTl J.'-IP GO /BIT 1=1* DUPLICATE CLA .+3 /BIT 2=1* VERIFY /ERROR SET C(AC)=7777 /NO PUNCHING - DON'T /WAIT FOR PUNCH NOPT RST2 VRPT /DON*T START PUNCHING CO.^JR /SET-UP RETURN FOR END Z CLA TAD CRPT DCA COiMR DCA Z VCi^iT JMP GO CLA TAD DUPT DCA CONR nnA 7 UCiMT /SET-UP RETURN FOR END /SET-UP RETURN FOR END 7-7 026 1 0P62 0263 0264 0265 0266 026 7 0270 027 1 4345 3016 1337 3017 1340 3163 1333 3000 0272 0273 3157 02 7 4 4031 027 5 5055 2157 5276 3000 7240 3416 7410 5736 1336 3170 02 7 6 0277 0300 0301 0302 0303 0304 0305 0306 0307 0310 031 1 0312 0313 0314 0315 0316 0317 0320 0321 0322 0323 0324 0325 0326 0327 0330 0331 0332 0333 0334 0335 0336 0337 0340 1 1 160 SAT> 7700 5315 0000 7200 5313 1334 3000 5102 7240 3416 2173 1335 3170 5307 1341 SWT W 0312 0326 0000 1 0342 0400 CFLG BUF /CLEAR FLAGS iMDXR /SET-UP BUFFER /POINTERS FOR /READ AND PUNCH BUF NDXP OVH RCNT SA /SET BUFFER- FULL COUNT I.NITER /INITIALIZE INTERRUPT TIME TIMR READ /SET END-OF-TAPE TIMER /START READING Z Z RDl ISZ Z TIMR I .- 1 /END-OF-TAPE OF CMA CLA OCA SKP JMP TAD DCA TAD SMA JMP I Z I COiMR iSJDXR CONR PDUN Z SCON CLA /DID WE START PUNCHING? /NO /YES - WAIT FOR PUNCHING .<-4 BFULi CLA JMP TAD DCA JMP CLA DCA /SET END-OF- PUNCHING FLAG /OR NOP FOR VERIFY /SET RETURN FOR PUNCH DONE ION .-1 /START PUNCHING SAl INTER Z FRST-3 CMA I Z iVDXR ISZ Z DCON TAD RET DCA Z PDUN JMP BFULTAD DLAY DCA STRT DCA Z SCON PCF JMP GO+1 SAT 8FUL-6 FILL /BUFFER-FULL /SET-UP END-OF-PUNCHING FLAG /•FILL' 1 FILL# 3164 3175 6022 5262 027 6 JMS TAD DCA TAD DCA TAD DCA TAD DCA TAD DCA JMS JMP JMP 175 1063 1274 7760 034 GO, 1337 SA, SA1# RET* CONR, BUF* OVR* DLAY* VRPT* /ENTER WHEN BUFFER /OVERFLOWED AND HAS /BEEN PUNCHED X-1 /START OF BUFFER /BUFFER-FULL COUNT /DELAY START OF PUNCHING /DONE POINTERS X + 210 1169 VRFY ) 7-8 0343 0344 0345 34 6 0347 0350 0351 404 0445 0000 6042 6072 CRPT, OUPT* CFLG, HRFT DUPL 6 7 72 6 7 72 0353 6502 6732 7 320 03 54 70 12 0355 6722 7004 6702 6502 6732 CLA CLL CML RTR 6722 RAL 3 52 0356 0357 0360 0361 0362 0363 04 10 041 3000 1325 403 4 1 04 12 04 13 04 14 0415 0416 0417 420 0421 0422 0423 0424 042 5 6652 6534 KCC JMP I CFLG 6534 6032 5745 21 74 1 PAUSE *400 VRFY* 4403 536 1 5351 4404 CRET* 5345 4314 1327 1326 4034 1325 4034 1 1 1 144 177 JtVJP i^ER JMS TAD OCA TAD JMS TAD 3LNK HERE 423 4314 1 PNC Z T2 PNC TAD Tl / Ji^S /10101010 /PUNCH CHECKS /ALTER CHECKS PiMC TAD ADl 4734 J<4S 1 PrvNT 57 33 Ji^lP I LOP 143 Z HLOP 1 1 1 1 /PUNCH BLANK TAPE RL.^K Ji^S 133 5 SIX, /PUNCH NUMBER IN AC 1 )0 '9 0432 3143 DCA MA33 1 43 T An. 0434 7012 i'43S 7^il2 04 3^ 7 RTn RTR RTR 012 /SET INTERRUPT POINTER /PUNCH CHECKSUM /IDENTIFIER CODES /BIT PATTERN IS: / 10101010 liVTER Tl 042 6 0427 0430 1 /COMPUTED VS PLEASURED CHECKS /VERIFY ERROR /VERIFY OK /CO.^PUTED VS PUNCHED /ME.viORY ERROR TAD CHKR TAD C3 7 7 Ji^S SIX TAD / ZkOR TAD Z TWO j^yis SIX 1 1 ISZ Z VCNT JMS I El JMP VER JMP VOK JMS I E2 J;^s 146 176 423 /DISABLE WCO FLAG C 57A) /SET C(AC)=4000 /DISABLE TCR FLAG ( 57A) /LINE-PRINTER FLAG /1 33 ADC FLAG /KEY- BOARD C AND AC) 6 7 02 6 6 52 0400 0401 8402 0403 40^ 0405 0406 040 7 /CLEAR FLAGS /TELEPRINTER /LIGHT PEN /Mi CRO TAPE /PLOTTER /DISABLE ERF FLAG (57A) TCP 6072 . 1 U, l> c 7-9 0437 0440 044 0442 0443 0444 0445 1 0446 0447 Z Z BIT6 Z Z Z HL02 BIT6 0172 4034 AND JNS TAD AND JMS 563 JiAP I SIX OUPL Jf«1S I Z J(AP Ji^S R£R GOl vJi'^P i^ER 0172 4034 1 143 1 4403 5347 4 404 5345 I PNC P.MC Z E2 04 50 0451 0452 0453 0454 3000 1325 4034 TAD HERE DCA INTER TAD Tl J>1S Z PNC 0455 1146 TAD Z 0456 0457 0460 4231 144 4231 Ji^S SIX 1 TAD Z 04 6 1 0462 4314 J>1S Ji^S 0463 04 6 4 7640 5356 0465 0466 1324 7 6 40 SIX BLNK TAD Z DC ON SZA CLA JMP DOK TAD DCNT SZA CLA 0467 ;d305 JMP TST4 0470 0471 0472 0473 1336 4734 7 402 7604 TAD AD2 Jt^S I PRNT HLT CLA OSR 04 7 4 7 04 1 C(^A 0475 0476 0477 3324 3170 DCA DCNT TAD HEKl DCA Z PDUN 0500 1360 3017 3145 3147 5040 2324 7410 5356 1337 4734 7 602 5330 TAD BF DCA Z NDXP DCA Z ZROP DCA Z CHKP J.^P Z PNCH DCNT ISZ SKP JMP DOK TAD AD3 JMS I PRNT HLT CLA jMP TST4-5 132 7 /COMPARE COMPUTED VS /f^EASUKED CHECKS /HEADER ERROR /COi^PARE COMPUTED VS /PUNCHED CHECKS /MEMORY ERROR El /PUNCH THIRD IDENTIFIER /READER STOPPED WHEN THIRD /IDENTIFIER /HAS BEEN FOUND, IE IT IS CHKK /NOT IN THf BJS'FFR 1 173 ZkOR /PUNCH BLANK TAPE /BUFFER OVERLAP-NO MORE DUp. /STARTED MULTIPLE /DuPLICAI US)?? /MULTIPLE DUPLICATION HAS I /SI A'<IED 501 0502 0503 0504 0505 0506 0507 0510 051 1 0512 0513 1332 TST4, I /READ NUMBER FROM SR AC /SET RETURN FOR PUNCHING /DONE /RESET BUFFER POINTER /RESET PUNCH-COMPUTED CHECKS /START PUNCHING /ARE WE DONE YET? /YES /NO /HALT /MAKE NEXT COPY 7-10 0514 0515 0000 516 0517 3 157 0520 /SUBROUTINE TO PUNCH /BLANK TAPE BL.^K* TAD DCA JMS ISZ 1323 4034 2157 tVjCiMT Z Z Z Tli^R JMP I 7600 BLiMK PNC Tli^iR CO 1 T 0522 0523 0524 0525 0526 0527 0530 0531 0532 0533 0534 0535 0536 0537 0540 0541 0542 0543 0544 0545 0546 0547 05 50 0551 0552 0553 0554 0555 0556 0557 0560 056 0562 0563 0564 0565 1 5714 7600 0000 0252 0125 0530 7200 5330 0447 0202 0673 0741 0751 1007 1017 1026 1036 1045 1054 1342 T . 12, 0252 0125 HERE* HERE^-l 1 HEHl, LOP, PRNT* AOl, AD2, AD3* AD4, AD5> AD6, AD7> AD8* MER, RER* 174 VOK, 1 4402 1340 4734 5733 1341 5354 1063 DOK> 174 BF* VER> 4402 1344 5354 0000 GET* 1 4031 057 0572 0573 0574 0575 7006 7006 3142 4031 6012 057 6 0577 5765 6012 7 106 1 142 /IDENTIFIERS CLA JMP .-1 5354 1343 5354 0566 0567 0570 1 MCNT* DCNT* GOl LOOP PR I. TABl TAB2 TAB3 TAB4 Si /MASTER CREATED /PRINT TABLE /PRINT TABLE /VERIFY OK /DUP OK /MEMORY ERROR /READER ERROR /VERIFY ERROR TABS TAB6 TAB7 TABS TAD AD6 JMP VOK+3 TAD AD7 JMP V0K^3 TAD Z VCiMT JMS I iNJPNT TAD AD4 JMS I PRNT JMP I LOP TAD AD5 JMP VOK+3 /VERIFY OK /DUPLICATION OK X-1 /VERIFY OK TAD Z VC.MT JMS I Z NPNT TAD ADS JMP VOK+3 /ROUTINE TO READ 2-6 BIT /CHARACTERS JMS Z READ RRB CLL RTL RTL RTL DCA Z HLDl JMS Z READ KRB TAD Z HLDl JMP I GET 7-11 0600 0000 0601 7 200 0608 060 3 0604 060 5 060 6 0607 0610 144 7041 150 7 6 40 ^oWid TESIj. /COMPAHE READER COi^PUTED CLA TAD Z ZROR CMA I AC TAD Z i^ZHO SZA CLA JMP I TESl TAO Z CHKK 1 1 5600 1 146 7 04 1 CiMA I 061 1 1 151 TAD Z 0612 0613 0614 0615 7650 2200 5600 0000 0616 0617 0680 7 200 0621 0622 0623 0624 062 5 0626 062 7 0630 0631 0632 AC >1CHK CLA ISZ TESl TESl J^AP I /COMPARE PUNCH COMPUTED /SUMS T?rs ?.> 145 7041 1 144 7 6 40 CLA TAD Z C-V)A I AC 1146 7041 147 7650 /CONVERT BINARY WORD IN AC 06 3 7 1263 0640 0641 0642 0643 0644 0645 0646 0647 0650 3245 TAD ADDR DCA XYZ<-3 SKP DCA Z HLD2 CLL TAD Z HLD2 TAD CON SZL ISZ Z HLDl SZL JHP XYZ CLA TAD Z HLDl TAD C260 JMS TYPE DCA Z HLDl ISZ XYZ + 3 ISZ CNT JMP xyz-f-2 06 51 06 52 0653 0654 0655 0656 06 57 06 60 0661 74 10 1 143 7422 7430 2142 7430 5242 7200 142 127 1 1 4325 3142 2245 2272 5244 DIGIT UNSIGNED DECIMAL /NUMBER AND TYPE IT /TO HLD2 DC A Z HLDl TAD CNTR DCA C.MT DCA 3143 7100 RETURN TO CALL^- 2 /OTHERWISE RETURN TO CALL*- /IE EQUAL* DKK T, 3143 3142 1264 3272 0633 0634 0635 0636 /TO READER COMPUTED SUMS ZHOP TAO Z ZROK SZA CLA JMP I TES2 TAD Z CHKk Ci^A I AC TAD Z CHKP SNA CLA ISZ TES2 JiMP I TES2 5615 2215 5615 0000 1 SiMA 1 1 /TO MEASURED SUMS /IF EOUAL> RETURN TO CALL+ ^ /OTHERWISE RETURN TO CALL+ XYZ.» Z 4 /IDENTICAL TO ROUTINE IN /LI BRARY '-12 0662 0663 0664 0665 0666 0667 06 70 0671 0672 0673 0674 0675 0676 06 7 7 SIR IN G 0700 0701 0702 07 03 0704 0705 0706 0707 07 10 0711 0712 0713 07 14 0715 0716 0717 0720 721 0722 0723 0724 0725 726 0727 0730 0731 07 32 0733 0734 0735 0736 0737 0740 0741 7 42 0743 5632 7422 7774 6030 7634 7766 7777 0260 0000 0000 3143 1543 7450 5320 7012 7012 7012 4310 1543 4310 2143 5275 0000 0172 1334 7510 1335 1336 4325 5710 1337 4325 1340 4325 5673 0000 6046 6041 5327 6042 7200 5725 7740 0100 0240 0215 0212 1501 2324 522 JMP ADOH, I DPHT CON> TAD CO.N 7774 6030 7634 7766 C260> 0260 CiMTR^ nil CtMT, PRIiM, OCA TAO ^ I /ROUTINE TO PRINT A STRING /OF PACKED ASCII PM AC APTCLJ /ENTER WITH S.A. OF STRING HL02 KLD2 SiMA JMP CR /IN AC: EXIT ON /IN STRING RTR RTR RTR JMS GPRT TAD I Z HLD2 JMS GPRT ISZ Z HLD2 /AFTER TYPING CR-LF PRIN+2 JtMP /THIS ROUTINE CONVERTS /6BIT TO ASCII GPRT, CR> ELE^vjr.NJx Z BIT6 M40 AND TAD SPA TAD TAD JMS JMP TAO JMS TAO JMS C100 C200 TYPE I GPRT CAR TYPE LF TYPE PRIN I Ji^P /TYPE CR-LF /TYPE CHARACTER IN AC TYPE* TLS TSF JMP .-1 TCF CLA J,^P I fv!40* 7745 C100^ C200* CAR> LF* TAB1> 0100 0240 0215 0212 TYPE ) /PRINT TABLES 150] 1 2324 0522 7-13 c- 07 4 4 0745 0746 0747 0750 07 51 0752 0753 0754 0755 0756 0757 0760 4003 2205 0124 3504 0000 2305 2440 2327 4003 2205 124 TAB2» 0504 0000 2305 2440 2327 124 1124 0310 0523 4024 0310 0762 0763 1740 1625 1502 0522 1740 1625 1502 07 64 401 7 0765 0766 0317 07 6 7 20 0770 0771 0772 0523 4024 1740 0205 4015 0104 07 6 1 07 7 3 0774 0775 0776 07 7 7 1000 1001 1002 1003 100 4 100 5 1006 1007 1 523 4024 0522 4017 0640 0317 640 1 2011 0523 4024 1 17 40 0205 4015 104 540 0540 2022 0523 2340 0317 2022 0523 2340 031 7 1624 1116 2505 0000 2022 1624 1116 2 50 5 TAB 3> 0000 2022 1010 523 523 10 11 2340 1012 1013 1014 1015 1016 1017 1020 031 7 2340 0317 0000 4040 2605 1624 1116 2505 1624 1116 TAB45 2505 0000 4040 2605 1021 221 1 221 1 1022 1023 1024 63 1 063 4017 13 40 401 7 1340 \i^p-r> 0000 0000 1 7-14 1026 1027 1030 2014 0425 2014 103 124 0124 1117 1640 1713 1117 1640 1713 42 5 1 1031 1032 1 133 1034 1035 1036 1037 10^0 1041 1042 1043 1044 1045 1046 104 1051 1052 10 53 1354 1055 1056 1057 1060 1061 10 62 1063 1364 1 0000 150 5 1517 2231 400 5 i AB6> 103 0000 1505 1517 2231 400 5 2222 2222 1722 1722 0000 2205 0104 0522 4 005 2222 1722 0000 4040 2605 0000 2205 i TAR 7, 4 1522 / 10 50 TAB5> 4005 2222 1 722 0000 4040 2605 TABS 221 1 0631 221 1 0631 4005 2222 4005 2222 1722 0000 0000 0000 1722 /START OF BUFFER 7-15 Formerly DIGITAL-8-12-U CHAPTER 8 INCREMENTAL PLOTTER SUBROUTINE ABSTRACT 8.1 The Incremental Plotter Subroutine moves the pen of a type 350 plotter to a new position along the best straight line. The pen can be raised or lowered during the motion. REQUIREMENTS 8.2 The subroutine requires one memory page of storage (12 8, The routine works on any PDP-8 family computer or 200o words) o equipped with a type 350 Plotter Control and Plotter. . The routine is distributed as an ASCII source tape as follows : Digital- 8-12-U-ASCII USAGE 8.3.1 Loading and Assembly The source tape as supplied has no origin setting and ends with a PAUSE statement. This tape can be assembled with a user program (which supplies an origin setting) or assembled by itself The tape can be assembled with any of the PDP-8 family asiKI i^i T-c c Cimrv I i-1 Calling Sequence 8.3.2 The plotter routine is called by executing a JMS PLOTX. The contents of the accumulator specify the operation of the subroutine as follows C(AC) = -1 The location registers internal to the subroutine are reset to zero and the pen is raised. Control returns to the instruction following the calling JMS instruction. CCAC) = The pen is lowered (if it was up) and is moved to the new located as described below. C(AC) = 1 The pen is rai s ed (if it was down) and is moved to the new location as described below. The two locations following the calling JMS instruction contain, respectively, the new X coordinate and the new Y co- ordinate in steps (these values must be less than 4096) The pen is moved from the previous location to the new location . along the best straight line with the pen up or down depending upon the contents of the accumulator when the subroutine is Control returns to the instruction following the Y called. co- ordinate. 8.3.3 Examples Initialization of Plotter: CLA CMA JMS I PLOT return PLOT, PLOTX /AC = -1, INITIALIZE ROUTINE AND PEN UP /JUMP TO PLOTX ROUTINE, PAGE INDEPENDENT /CONTROL RETURNS TO THIS ADDRESS /CONTAINS ADDRESS OF PLOTX ROUTINE \-2 Plot with Pen Down: CLA JMS I PLOT X coordinate Y coordinate rerurn /AC = 0, PEN DOWN /MUST BE IN RANGE -4096<X<4096 /-4096<Y<4096 PLOT, PLOTX Plot with Pen Up : CLA lAC JMS I PLOT /AC = 1, PEN UP X coordinate Y coordinate /-4096<X<4096 /-4096<Y<4096 return PLOT, PLOTX 8.4 DESCRIPTION The routine has two registers which contain the location of the last position plotted. When the subroutine is entered, the accumulator is tested to determine if initialization is being performed; if so the location registers are set to zero, the pen raised, and the subroutine exits. If the routine is not being initialized, the subroutine compares the current pen position (up or down) with the requested one and raises or lowers the pen if appropriate. The new X and Y coordinates are retrieved from the two locations follov/ing the calling JMS and placed in the location registers. The X and Y difference between the current location and the desired location are computed and compared. The subroutine selects motion commands depending upon the quadrant of the new location compared to the old. to either the X-axis a combined motion. The possible motions are now parallel (drum motion) or the Y-axis (pen motion) or The subroutine determines which of these motions to use, and when the new location is reached, it exits. 1-3 The X and Y coordinates are specified in numbers of steps. Increasing X corresponds to lowering the drum. Increasing Y cor- responds to moving the pen left. The subroutine is limited by the speed of the plotter. The minor subroutine, PLOTWT can be replaced, if necessary, by a routine making use of the program interrupt. 8.5 PROGRAM LISTING /COf YdlGHi 1971 iJIGIfAL EQ JI PiiSM f CO^^PO^AFUN /DIGITAL 8-12-U /PLOT SUBROUTINE /CALLING SEQUENCE / / / / / / 0200 0201 0202 0203 0204 0205 0206 0207 0210 0211 0212 0213 0214 0215 0216 0217 0220 0221 0222 0223 0224 0225 0226 0000 7510 5220 1361 7112 7710 5227 7620 5214 3361 6504 5216 2361 6524 4370 5227 7200 6504 3361 3362 3363 4370 5600 C(AC)=-l; INITIALIZE C{AC)= 0; PLOT WITH PEN DOWN C{AC)= IJ PLOT WITH PEN UP JMS PLOTX X CO-ORDINATE (IN STEPS) (RETURN Y CO-ORDINATE (IN STEPS) PL0tX» SPA JMP PLOTA TAD PLOTPN CLL RTR SPA CLA JMP PLOTl SNL CLA JMP .+4 DCA PLOTPN PLPU JMP .+3 ISE PLOTPN PLPD JMS PLOTWT JMP PLOTl PLOTA, CLA PLPU DCA PLOTPN DCA PLOTNX DCA PLOTNY jMS PLOTWT JMP PLOTX IF /MOVE THE PEN? /NO: CONTINUE /ADD PEN STATUS /ANY CHANGE? /NO: CONTINUE /LOWER THE PEN /RAISE THE PEN /LOWER THE PEN /WAIT FOR FLAG /CONTINUE /RAISE THE PEN /0 TO /0 TO X Y I 8-4 CO-ORDINATE CO-ORDINATE AC=-1) /DIGITAL 8*12-U /PAGE 2 /PICK UP ARGUMENTS 0227 0230 0231 02^2 0233 0234 0235 0236 0237 0240 0241 0242 0243 0244 0245 0246 0247 0250 0251 0252 0253 0254 0255 0256 0257 0260 0261 0262 0263 0264 0265 0266 0267 0270 0271 0272 0273 0274 1362 7141 1600 7420 7041 3364 7004 3367 1600 3362 2200 1363 7141 1600 7420 7041 3365 1367 7004 3367 1600 3363 2200 1364 7141 1365 7620 5275 1364 3366 1365 3364 1366 3365 7001 0367 1342 5300 PLOTl CIA TAD SNL ClA DCA RAL DCA TAD DCA /FETCH PREVIOUS TAD PLOTNX I PLOTX 1367 7110 1345 3366 1766 3340 1367 1350 3367 1767 CO"0«DlNATE /FORM NX-NPX /L=0: NX<NPX PLOTDX /ABSOLUTE VALUE OF DIFFERENCE PLOTMV PLOTX PLOTNX IS2 PLOTX TAD PLOTNY /SAVE SIGN BIT /SET NEW /PREVIOUS X /INCREMENT POINTER /FETCH PREVIOUS Y CO-ORDINATE I CIA TAD SNL CIA DCA TAD RAL DCA TAD DCA CLL PLOTX ClA TAD SNL JMP TAD DCA TAD DCA TAD DCA CLL I PLOTDY PLOTMV PLOTMV PLOTX PLOTNY ISZ PLOTX TAD PLOTDX I /FORM NY-NPY /<=0: NPY<NY /ABSOLUTE VALUE OF DIFFERENCE /SAVE SIGN BIT /BIT 10(1)= DRUM-DOWN(POSITIVE) /BIT 11(1)=PEN-LEFT (POSITIVE) /SET NEW /PREVIOUS Y /INCREMENT POINTER PLOTDY CLA PL0T2 PLOTDX plotna PLOTDY PLOTDX PLOTNA PLOTDY lAC AND PLOTMV TAD PLOTTl jMP .+4 /L=0: DELTA Y < DELTA /REVERSE NUMBERS /SET MAJOR MOTION /INSTRUCTION /DIGITAL 8-12-U /PAGE 3 0275 0276 0277 0300 0301 0302 0303 0304 0305 0306 X CLL TAD PLOTMV PL0T2, CLL RAR TAD PL0TT2 DCA PLOTNA TAD I PLOTNA DCA PL0T4 /SET COMBINED MOTION TAD PLOTMV TAD PL0TT3 DCA PLOTMV PLOTMV TAD I !-5 X 0307 0310 0311 0312 0313 0314 0315 0316 0317 0320 0321 0322 0323 0324 0325 0326 0327 0330 0331 0332 0333 0334 0335 0336 0337 3331 1364 7110 3366 1364 7040 3367 2367 7410 5600 1366 1365 3366 1366 7140 1364 7630 5340 0000 1364 7041 1366 3366 4370 5316 DCA PLOTDB TAD PLOTDX CLL RAR DCa PLOTNa TaD PLOTDX CMA DCA PLOTMV PL0T3, IS2 PLOTHV SKP JMP PLOTX /ALL DONE TAD PLOTNA TAD PLOTDY DCA PLOTNA TaD PLOTNA CMa CLL TAD PLOTDX S2L ClA JMP PL0T4 /SINGLE MOTION PLOTDB, /COMBINED MOTION TAD PLOTDX CIA TaD PLOTNA DCA PLOTNA jMS PLOTWT JMP PL0T3 0340 0341 0000 5336 PL0T4, JMP .-3 0342 0343 0344 0345 0346 0347 0350 0351 0352 0353 0354 0355 0356 0357 0360 0343 6511 6521 0346 6512 6514 0351 6513 6523 6515 4355 0000 6514 6521 5755 .+1 PLOTTl, PLPR PLPL ,*1 PL0TT2» PLDU PLDD PL0TT3, .I PLDU PLPR PLUD PLPL PLDD PLPR JMS .! I PLDD plPl JMP I /PEN-RIGHT /PEN-LEFT /DRUM-UP /DRUM-DOWN /UP-RIGHT /UP-LEFT /DOWN-RIGHT /DOWN-LEFT .-3 /DIGITAL 8-12-U /PAGE 4 0361 0362 0363 0364 0365 0366 0367 0000 0000 0000 0000 0000 0000 PLOTPN, PLOTNX, PLOTNY, PLOTDX, PLOTDY, PLOTNA, PLOTMV, 8-6 0370 0371 0372 0373 0374 0000 6501 5371 6502 5770 PLOTWT, PLSF JMP .-1 PLCF JMP PLOTWT I /WAIT FOR DONE FLAG /NOT YET /CLEAR FLAG /EXIT PAUSE PLOTA PLOTDB PLOTDX PLOTDY PLOTMV plotna PLOTNX plotny PLOTPN PLOTTl PL0TT2 PL0TT3 PLOTWT PLOTX PLOTl PL0T2 PL0T3 PL0T4 022 0331 0364 0365 0367 0366 0362 0363 0361 0342 0345 0350 0370 0200 0227 0275 0316 0340 8-7 Formerly Digital- 8-2 8-U-Syin CHAPTER 9 DECIMAL TO BINARY CONVERSION AND INPUT (Single Precision, Signed or Unsigned, 33-ASR) 9 . ABSTRACT This routine accepts a string of up to four decimal digits (single precision for the PDP-8) from the Teletype keyboard and converts it to the corresponding 2's complement binary number. The string can contain as legal characters a sign (+,-, or space) and the digits from 0-9. If the first legal character is not a sign, the conversion is unsigned . A back arrow ( -«) at any point in the string erases the current string and allows the operator to reenter the correct value. Any character after the first, other than another digit or back arrow, causes the conversion to terminate and is found in location SISAVE within the subroutine. 9.2 REQUIREMENTS This subroutine requires 74^^ (112^) core locations and runs on any standard PDP-8 family computer with a 33-ASR Teletype console. Program tape is labelled Single Precision Decimal Input, Digital- 8-2 8-U-ASCII 9 . 9.3.1 USAGE Loading The symbolic tape provided can be assembled with the user's main program by PAL III, r4ACRO-8, or PAL-D. The symbolic tape has neither an origin setting nor a terminating "$", but does have a PAUSE pseudo- instruction at the end. 9.3.2 Calling Sequence The subroutine is called by an effective JMS to location SICONV. Return is to the location immediately following the calling JMS with the binary number in the accumulator. 9-1 9.4 ERRORS IN USAGE If a sign (+, -, or space) precedes the string of decimal digits, the maximum decimal number correctly accepted is 2047 (2 - 1) The sign, if any, must appear first. . If a sign does not precede the string of decimal digits, the maximum decimal number correctly accepted is 4095 (2 12 - 1) If either of these maxima is exceeded, the results are unspecified. . 9.5 RESTRICTIONS The status of the AC and link is not preserved. This subroutine should not be used when the interrupt is on. The magnitude restrictions on numbers are described in Section 9.4. 9.6 DESCRIPTION This subroutine converts to the binary equivalent a signed or unsigned string of decimal numbers read from the console keyboard of the PDP-8. If a minus sign is specified, the results are in 2's complement negative form. if it is a sign (+, -, The first character is examined and, or space), a switch is set to provide the correct sign for the conversion. Regardless, a switch is set after the first character to terminate conversion if a character other than a decimal digit or rubout appears. If a back arrow appears at any time, the conversion is reinitialized and the subroutine waits for the correct entry. The last four bits of the ASCII code for each of the decimal digits are identical to the standard 8-4-2-1 BCD code. Thus, the BCD digit is extracted from the 8-bit code by the AND instruction with a "mask" of 17g. When the first BCD digit comes in, it is added to a cleared location (SJHOLD) in memory and stored back in that location. When the next legal character comes in, location SJHOLD is multiplied by 10, then added to the BCD code of the character and returned to location STORE. This sequence holds 9-2 true for a decimal number of any arbitrary length. 9.7 EXAMPLE Since the PDP-8 can add and shift easily, the multiplication by 10 can be accomplished in three instructions. is equivalent to a multiplication by 2 , equivalent to a multiplication by 4. Since a shift left a double shift left is Assume that the number currently in STORE is 5, and the new code just coming in is the number 1 stored in HOLD. The program sequence to perform the multiplication and storage is as follows: Instruction Sequence Contents of AC Comments CLA TAD STORE /Load C (STORE) into AC CLL RTL /Multiply C (STORE) by TAD STORE /Add STORE giving C (STORE) by CLL RAL /Multiply by TAD HOLD /Add in the next number 000 000 110 Oil DCA STORE /Store back into STORE and return to wait for next character 000 000 000 000 2 000 000 000 101 0000000 10 100 4 5 000 000 Oil 001 giving C (STORE) by 10 000 000 110 010 The number residing in location STORE is 006 Sq or 0051,^. If the next number to come in were "9", using the same sequence and conditions, the result would be 001 000 000 111, the binary equivalent of 519. 9 . SCALING This subroutine assumes an integral decimal number (signed or unsigned) and yields an integral binary equivalent (signed or unsigned respectively) 9 . 9.9.1 FORMAT Input The input string may or may not contain a sign (+, -, or space) 9-3 Any character other than a sign, 0-9, or back arrow causes the subroutine to terminate, as does a sign in any but the first position. 9.9.2 Core Data The terminating character is found in location SISAVE. 9.9.3 Output Spacing, tabulation, carriage return, etc., are not provided for in this subroutine. See Chapter for those purposes. 9-4 6 which contains short subroutines 9.10 FLOW CHART ( ENTRY J INITIALIZE a ZERO ASSEMBLY LOCATIONS ERASE NUMBER NO WAIT FOR INPUT FROM KEYBOARD YES YES SET SIGN INDICATOR TO NEGATIVE MULTIPLY PARTIALLY ASSEMBLED NUMBER BY 10 I FORM 2'S COMPLEMENT ADD INCOMING DECIMAL DIGIT 3 5>^ NUMBER IN AC I C EXIT D 9-5 11 PKUGKAiyi l.lbTl]N«a /COPY UGH /;vlAYNA:^D> i: DIGIIAL ^^JIP-ISMr cor^pO'^ArioN 1971 .^ASS^CH JSH:TTS /SINGLE PRECISION DECIMAL INPUT FROM KEYBOARD /CALLING SEQUENCE: JMS SI CONV /ACC IGNORED, RETURN WITH BINARY WORD IN ACC 0200 020 0202 0000 7300 1273 0203 0204 0205 0206 0207 0210 3232 021 1 3307 0212 1307 1 SI CONV, CLA CLL TAD SI SET 1273 3224 3310 331 5257 1 SIPROC, DCA TAD DCA DCA DCA JMP DCA TAD 1 +1 /INITIALIZE PROGRAM SWITCHES SI CTRL SISETl +1 SIXSWl SIHOLD SINEGl SINPUT SI SAVE SI SAVE /CLEAR NEGATIVE SWITCH /STORE AND THE PROCESS /CHARACTER 0213 1301 02 14 7450 TAD SIRBUT SNA 0215 0216 0217 5201 1302 7510 JMP SI CONV TAD SIM260 SPA 0220 5232 JMP 0221 0222 1303 7740 TAD SIM271 SMA SZA CLA 0223 5232 JMP SICTRL /IS IT GREATER THAN 27 /(IE. "9")? /YES, TRANSFER TO SEE WHAT 0224 7300 CLA CLL /CHAR. IT IS /NO, FIRST CHARACTER WAS A 0225 0226 0227 1231 1777 TAD .+4 DCA .-2 TAD SINMBR /DECIMAL DIGIT /CLOSE SWITCH TO GO TO /"SINMBR" NEXT /SET SWITCH TO SENSE /TERMINATING CHAR. 3232 5246 7300 DCA SICTRL JMP SINMBR CLA CLL /IS IT A "BACK-ARROW" /(IE. ERASE) KEY + /YES, /IS IT LESS THAN 260 /CIE. "0") /YES. TRANSFER TO SEE WHAT SI CTRL /CHAR. 0230 023 0232 0233 0234 0235 1 SIXSWl, 3224 1307 1304 SICTRL, REINITIALIZE IT IS 1 -1 /CONTINUE CHECKING 0236 7450 5273 TAD SI SAVE TAD SIMSPC SNA JMP SISETl +1 0237 0240 0241 1305 7450 5273 TAD SI MPLS SNA JMP SISETl 0242 0243 0244 1306 7650 5273 TAD SIMMNS SNA CLA JMP SISETl + 1 9-6 /IS IT A SPACE? /YES, SET SWITCH TO SENSE /TERMINATING CHAR. /IS IT A "PLUS"? /YES, SET SW TO SENSE /TERMINATING CHAR. /IS IT A MINUS? /YES, SET NEGATIVE XSWITCH /AND TERM. SWITCH 0245 5264 0246 1310 0247 7106 0251 100A 3310 0252 0253 02 54 0255 0256 0257 0260 JMP SINMBR, 1307 1310 3310 026 1 0262 0263 6036 6046 0264 7300 SINPUT* 131 1 0266 7010 /PICK UP CURRENT DIGIT /MASK OFF THE HIGH ORDER /BIT /ADD TO ASSEMBLED NUMBER TAD SIHOLD /STORE BACK IN SIHOLD DCA SIHOLD /INPUT ROUTINE KSF JMP .KRB TLS JMP SIPROC 1 521 1 02 6 5 TAD SIHOLD CLL RTL TAD SIHOLD RAL DCA SIHOLD TAD SI SAVE AND SI MASK 0300 6031 5257 IT WAS A TERMINATING /CHARACTER /MULTIPLY CURRENT ASSEM/BLED NUMBER BY 10 /NO, SI END /TERMINATING ROUTINE CLA CLL SI END, TAD SINEGl RAR /PUT NEGATIVE SWITCH INTO /LINK 0267 0270 7 430 TAD SIHOLD SZL 027 1 7041 CM A 0272 0273 0274 0275 5600 231 1 1310 I /IS THE LINK "1"? /YES, NUMBER NEGATIVE. /COMPLEMENT /RETURN. /SET NEGATIVE SWITCH AC JMP 7300 I SI CON ISZ SINEGl CLA CLL 1777 TAD SINMBR -1 SISETl^ /CLOSE SW TO TRANSFER TO /TERM. DCA SI CTRL JMP SIN PUT 0276 0277 3232 5257 0300 0301 0302 0017 7441 0057 SIMASK, SIRBUT, SIM260, -337 0303 7767 SIM27 1, - 1 1 0304 0305 7540 7765 SIMSPC, SIMPLS, -240 0306 7776 SIMMNS* -2 0307 0310 0000 0000 0000 SI SAVE, /CONSTANTS AND VARIABLES 0311 17 /CODE FOR ERASE /NUMBER USED TO GENERATE /CODE "260" /NUMBER USED TO GENERATE /CODE "271" 57 /NUMBER USED TO GENERATE /CODE "253" (+) /NUMBER USED TO GENERATE /CODE "255" (-) /STORAGE LOCATIONS - 13 SIHOLD, SINEGl, PAUSE 9-7 Formerly Digital-8-29-U-Sym DECIMAL TO BINARY CONVERSION AND INPUT (Double Precision, Signed or Unsigned, 33-ASR) ABSTRACT 10 . This routine accepts and echoes a string of up to eight decimal digits (double-precision for the PDP-8) from the Teletype keyboard and converts it to the corresponding two's complement binary number. The string may contain as legal characters a sign (+, -, or space) If the first legal character is not a sign, the and the digits 0-9. at any point in the conversion is unsigned A "back-arrow" ( ^ ) . string erases the current string and allows the operator to re-enter Termination of input is accomplished by typing one illegal the value. character which will then be found in location DIDSAV within the subroutine. REQUIREMENTS 10.2 This subroutine requires 110-,q (156 g) core locations and runs on The any standard PDP-8 family computer with a 33-ASR Teletype console. paper tape is labelled Double Precision Decimal to Binary Conversion, Digital- 8-29-U- ASCII 10 . 3 10.3.1 USAGE Loading The symbolic tape provided can be assembled with the user's main program with PAL III, MACRO- 8, or PAL-D. There is neither origin setting nor terminating "$" on the symbolic tape, but a PAUSE pseudo-instruction is the last line on the tape. 10-1 Calling Sequence 10.3.2 The subroutine is called by an effective JMS to location DICONV. The location immediately following the JMS instruction contains the address of the location where the high-order portion of the number is to be stored. (It is assumed that the low-order portion of the number is in the location immediately following the high-order portion.) Return is to the second location following the calling JMS with the AC clear. For example: JMS DICONV ADDR HLT ADDR, ERRORS IN USAGE 10.4 If the string of decimal digits is preceded by a sign space) , (+, -, or the maximum decimal number that is correctly accepted is 16777215 (2^^ -1) If neither of these maxima is exceeded, the results are unspecified. 10.5 RESTRICTIONS The status of AC and link is not preserved. This subroutine should not be used with the interrupt on. The magnitude restrictions on numbers is described in section 10.4 10.6 DESCRIPTION The discussion, example, and scaling information about the conversion are given in Chapter 9. The only difference is that the multiplications by "4" and "2" are performed by the arithmetic shifts as described in the section on Arithmetic Shift Subroutines in the PDP-8 Math Routines write up, DEC-0 8-FFAD-D. Information on techniques used in this program can also be found in Chapter 9 of this document. 10-2 FORMAT 10.7 10.7.1 Input Data The input string may or may not contain a sign Any character other than a sign, - 9, (+, -, or space) or rubout causes the subroutine to terminate as does a sign in any but the first position. 10.7.2 Core Data The high-order portion of the binary equivalent of the number is found in the location specified by the address following the JMS The low-order portion is found in the next successive location. is the format compatible with the double-precision, arithmetic subroutines. fixed point The terminating character is found in location DIDSAV. 10.7.3 Output Data Spacing tabulation, carriage return, etc. for in this subroutine. This See Chapter 6 , are not provided which contains short sub- routines for such purposes. This subroutine is input limited at a maximum of 10 cps 10-3 FLOW CHART 10.8 C J INITIALIZE PROGRAM SWITCHES AND ZERO LOCATIONS FOR HOLDING PARTIALLY-ASSEMBLED DOUBLE-PRECISION NO. FIRST CHARACTER A TERMINATING IS CHARACTER PICK UP ADDRESS FROM CALLING SEQUENCE FOR STORING DOUBLE PRECISION NUMBER ERROR MADE OPERATOR WISHES TO ERASE NUMBER COMPLEMENT THE DOUBLE -PRECISION WAIT FOR CHARACTER FROM KEYBOARD OR READER NUMBER THIS IS A TERMINATING CHARACTER SAVE INCOMING CHARACTER IN " D DSAU STORE RESULT IN ADDRESS SPECIFIED BY THE CALLING SEQUENCE FIRST CHARACTER WAS A DECIMAL DIGIT SET SWITCH 'I I SET CONTROL c SWITCH YES PICK UP PARTIALLYASSEMBLED, DOUBLE PRECISION NUMBER MULTIPLY BY FOUR (IE DOUBLE SHIFT LEFT TWICE) PICK UP INCOMING CHARACTER ADD THE PARTIALLY ASSEMBLED. DOUBLE PRECISION NUMBER MULTIPLY BY TWO (!E DOUBLE SHIFT LEFT ONCE) ADD THE INCOMING DECIMAL DIGIT TO THE RESULT YES SET NEGATIVE SWITCH SET CONTROL SWITCH YES 10-4 STORE SUM AS THE NEW PARTIALLY-ASSEMBLED, DOUBLE-PRECISION NO. 10.9 PROGRAM LISTING /COPYRIGHT 197 /;iAY^JAf^D> 0200 020 0202 0203 0204 0205 0206 0000 7300 1324 3235 1324 3227 1600 0207 0210 3351 3352 0211 0212 0213 0214 0215 0216 0217 0220 0221 0222 0223 3353 3347 5275 3350 1 1350 1341 7450 5201 1342 7510 5235 DIGITAL £3 JI P^^ENi F COifOR^ilO^ ^lASSACHJSEirS 1 /DOUBLE PRECISION DECIMAL-TO-BINARY CONVERSION AND INPUT /AC IGNORED /CALLING SEQUENCE: / JMS DICONV /SUBROUTINE CALLED / ADDRES /ADRESS TO STORE HIGH-ORDER \wORD / /LOW -ORDER WORD IN ADDRESS+1 DICONV^ CLA CLL /INITIALIZE PROGRATn SWITCHES TAD DISETl+1 DCA DICTRL TAD DISETl+1 DCA DIXSWl /PICK UP ADDRESS TO STORE TAD I DICONV /HIGH-ORDER WORD DCA DIGET /CLEAR LOCATIONS USED TO HOLD DCA DIHIHD /INCOMING /NUMBER DCA DILOHD /CLEAR NEGATIVE SWITCH DCA DINEGl DIPROC^ JMP DCA TAD TAD SNA JMP TAD SPA JMP DUN /STORE CHARACTER DIDSAV DIDSAV DIRBUT /IS IT A "BACK- ARRO W" C I E. ERASE) KEY? /YES^ REINITIALIZE DICONV+1 DIM260 /IS IT LESS THAN 260 (IE. "0")? /YES^ TRANSFER TO SEE WHAT DICTRL IS / uni-irii-io i rL,i 0224 0225 1343 7740 0226 5235 0227 0230 0231 0232 7300 1234 3227 1250 TAD DIM271 SMA SZA CLA /IS IT GREATER THAN 271 241 3235 525 7200 1350 1344 7450 5 324 0242 0243 0244 1345 7450 5324 1 "9")? /YES^ TRANSFER TO SEE WHAT /CHARACTER IT IS DIXSWl^ CLA CLL /N0:» FIRST CHARACTER WAS A DECIMAL DIGIT TAD .+4 /CLOSE SWITCH TO GO TO "DINMBR" NEXT DCA .-2 /SET SWITCH TO SENSE TERMINATING TAD DINMBR/CHARACTER DCA DICTRL JMP DINMBR /CONTINUE CHECKING TO DETERMINE CHAR. DICTRL^ CLA TAD DIDSAV TAD DIMSPC /IS IT A "SPACE"? SNA /YES^ SET SWITCH TO SENSE TERM. JMP DISETi+i /CHARACTER TAD DIMPLS /IS IT A "PLUS"? SNA /YES^ SET SWITCH TO SENSE TERM. JMP DISETl+1 /CHARACTER JMP DICTRL 1 • 0233 0234 0235 0236 0237 0240 (IE. 10-5 245 246 0247 1346 •7 /^, c i7i 5323 0250 0251 5302 0252 0253 0254 0255 0256 0257 0260 0261 0262 0263 0264 0265 0266 0267 0270 0271 0272 0273 0274 3354 1352 3355 4330 4330 7004 1352 1355 3352 4330 1350 0340 1353 3353 7430 2352 0275 0276 0277 0300 0301 6031 5275 6036 6046 5214 0302 0303 0304 0305 0306 0307 0310 7200 1347 1353 1353 1354 3353 71 10 0312 0313 1352 7430 7040 3751 1353 7430 7141 0314 0315 0316 0317 7430 2751 7000 2351 0320 0321 0322 0323 3751 2200 031 1 5 60 TAD DIMMNS SNA CLA /IS IT A "MINUS"' JMP DISETl /YES^SET NEGATIVE SWITCH AND TERM /SWITCH JMP DIEND /NO^ IT WAS A TERMINATING CHARACTER DINNER^ TAD DILOHD /STORE ASSEMBLED NUMBER /TEMPORARILY DCA DIXTMI TAD DIHIHD DCA DIXTM2 JMS DIDSPL /MULTIPLY CURRENT BY "1 JMS DIDSPL TAD DILOHD TAD DIXTMI DCA DILOHD RAL TAD DIHIHD TAD DIXTM2 DCA DIHIHD JMS DIDSPL TAD DIDSAV /PICK UP CURRENT DIGIT AND DIXMSK /MASK OFF HIGH-ORDER BITS TAD DILOHD /ADD REMAINDER TO CURRENT NUMBER DCA DILOHD SZL /DID IT OVERFLOW? ISZ DIHIHD /YES^ CORRECT HIGH-ORDER WORD /INPUT ROUTINE DIIN^ KSF JMP KRB TLS JMP DIPROC /TERMINATING ROUTINE DIEND^ CLA /PICK UP NEGATIVE NUMBER TAD DINEGl CLL RAR /PUT IT INTO LINK. ("1" IF NEGATIVE) /PICK UP HIGH ORDER PORTION TAD DIHIHD /IS LINK "1"? SZL CMA /YES:. NUMBER NEGATIVE. COMPLEMENT IT DCA I DIGET /STORE IT /PICK UP LOW-ORDER PORTION TAD DILOHD SZL /IS LINK "1"? /YES:. TWO'S COMP.IT. IF OVERFLOW^ CLL CMA lAC /LINK=1 SZL /IS LINK "1"? /INDEX HIGH-ORDER PRTION ISZ I DIGET /TAKES CARE WHEN HIGH-ORDER PORTION =0 NOP /INDEX POINTER FOR LOW-ORDER ISZ DIGET /PORTION /STORE LOW-ORDER POTION OF NUMBER DCA I DIGET /INDEX FOR CORRECT RETURN ISZ DICONV /RETURN JMP I DICONV /SET NEGATIVE SWITCH ISZ r^ T M ISET . 1 u' r: i 10-6 0324 0325 0326 0327 7300 1250 3235 5275 330 0331 0332 0333 0334 0335 0336 0337 0000 0340 0341 0342 0343 0017 7441 0057 7767 7540 7765 7776 0000 0000 0000 0000 0000 0000 0000 0344 0345 0346 0347 0350 0351 0352 0353 0354 0355 1353 7104 3353 1352 7004 3352 5730 CLA CLL /CLOSE SWITCH TO TRANSFER TO TERMINATION TAD DINMBRDCA DICTRL JMP DUN /JUMP TO WAIT FOR NEXT CHARACTER /DOUBLE PRECISION LEFT SHIFT CX2) DIDSPL' TAD DILOHD CLL RAL DCA DILOHD TAD DIHIHD RAL DCA DIHIHD JMP I DIDSPL /CONSTANTS AND VARIABLES DIXMSK^ 17 /MASK FOR LAST FOUR BITS DIRBUT^ -337 /CODE FOR ERASE DIM260:* 57 /NUMBER USED TO GENERATE CODE "260" DIM271^ -11 /NUMBER USED TO GENERATE CODE "271" DIMSPC:» -240 /CODE FOR SPACE DIMPLS^ -13 /NUMBER USED TO GENERATE CODE "253" C+) DLMMNS^ -2 /NUMBER USED TO GENERATE CODE "255" C-) DINEGl^ /STORAGE LOCATIONS DIDSAV^ DIGET^ DIHIHD> DILOHD> DIXTMl^ DIXTM2^ 10-7 Formerly Digital- S-lO-U-Sym CHAPTER 11 BCD TO BINARY CONVERSION, SINGLE PRECISION (Binary Coded Decimal to Binary Conversion Subroutine) ABSTRACT 11.1 coded-decimal numbers to their equivalent binary value. is accomplished by "radix deflation". Conversion REQUIREMENTS 11.2 This subroutine requires 23, ^ ^27g) memory locations and runs on any standard PDP-8 family computer with a 33-ASR Teletype console The source paper tape is labeled BCD to Binary Conversion, Digital-8-lO-U-ASCII USAGE 11.3 11.3.1 Loading Load the subroutine with the Binary or RIM Loader, as described in either Introduction to Programming or Programming Languages . 11.3.2 Calling Sequence Call with the number to be converted in the AC. Return will be to the location following the calling JMS with the result in the AC. 11.4 DESCRIPTION The method used is that of "radix deflation". Upon entry, the BCD number may be considered to be in the following form: (a) D^ 16^ + D 16 + Dq What is desired is the number in the form: (b) D2 10^ + D^ 10 + Dq 11-1 A right shift is equivalent to The PDP-8 can shift (rotate) and add. division by a power of two. An appropriate series of shifts, additions, and subtractions is used to convert the number from the a form of 11.5 (a) to that of (b) EXAMPLE Consider the BCD number 0101 1001 0001 representing the decimal number 519. First the whole number is stored and then brought back into the AC. Next, the four most significant bits are masked out. At this point, the accumulator contains 16xl6xA or 0101 0000 0000 A shift to the right of one bit yields 0010 1000 0000 This number is stored and then brought back to the AC, shifted right two bits, and the stored value added as follows: 0000 0010 1010 1000 0000 0000 0011 0010 0000 Now the original number is added to this result 0011 0101 0010 0001 0000 1001 1000 0011 1001 and the most significant eight bits masked out as 1000 0000 0011 11-2 This is stored, brought back and shifted right once, and the stored value added. 0100 1000 0001 0011 1000 0000 1100 0100 1000 Next the result of this addition is shifted right two places dividing the number by four as follows 0011 0001 0010 negated and the original number added 1100 0101 1110 0001 1110 1001 0010 0000 0111 This result represents in binary 512 plus 4 plus 2 plus 1 or 519, the original number. 11.6 SCALING This subroutine assumes an integral BCD number and yields an integral binary equivalent. 11.7 PROGRAM LISTING A listing of the subroutine with BCDBIN located at 0200 is given below. To simplify mnemonics D^, D, and D^ have been replaced respectively with A, B, and C. 11-3 /BINARY-CODED-DECIMAL TO BINARY COhiVERSTON SUBROUTINE *263 0263 0264 0265 0266 0267 0000 3314 02 70 3313 1313 7010 1315 7041 1314 3314 1314 027 1 0272 0273 0274 0275 0276 0277 03-1/ 1314 031 1 71 12 !/'; i ] ;- 0301 0302 0303 0304 030 5 0306 0307 7112 3313 03 1 031 5 6 63 '/' I 0312 0313 0314 13 1 : 7010 i:-! 1 .-. 7041 1314 7400 7760 0000 0000 BOBBIN^ DCA TEMPH TAD TEMPH AND LDIGIT CLL RTR DCA COUNT TAD COUNT RAR TAD COUNT CMA I AC TAD TEMPH DCA TEMPH TAD TEMPH AND MDIGIT CLL RTR DCA COUNT TAD COUNT RAR TAD COUNT CMA I AC TAD T EMPH JMP I BCDBIN LDIGIT:* 7400 MDIGIT^ 7760 COUNTS /STORE INPUT /160 H /60 H 16 M + L + + 6 M /EXIT TEMPH:. REFERENCES 11.8 11.8.1 DECUS Programs See DECUSOPE January 1965, article entitled "Accelerated Radix Deflation on the PDP-7 and PDP-8". 11.8.2 ACKNOWLE DGMENTS Mr. Donald V. Weaver, Consultant, of New York City, who first described the algorithm used by this subroutine in reference 11.8.1 has granted his kind permission to include this subroutine in the PDP-8 library so that a detailed description may be available. 11-4 Formerly Di'^i"'"3.1— 8— 11—^^ CHAPTER 12 BCD TO BINARY CONVERSION, DOUBLE PRECISION ABSTRACT 12.1 This subroutine converts a 6-digit BCD number to its equivalent binary value in two computer words REQUIREMENTS 12.2 This subroutine requires 89, p. (131„) memory locations and runs on any standard PDP-8 with a 33-ASR Teletype console. The source tape is labeled Double Precision BCD to Binary Conversion, Digital-8-ll-U-ASCII USAGE 12.3 Loading 12.3.1 The subroutine is loaded with the Binary Loader. The symbolic code is either assembled with the user program or separately with the proper origin setting. Calling Sequence 12.3.2 This subroutine is called with an effective JMS DOUBLE followed by the address of the high-order word of the double-precision BCD number. Control is returned to the following location with the high- order part of the result in C(AC) and with the low-order part of the result in C(LOW) 12.4 DESCRIPTION Upon entry, the BCD number is in the form: 2 (16 D, (each digit is + I6D2 + D^) 4 bits, 2 4 2 ; C16 D, + 16D^ + Dg) = 16) 12-1 using the single precision BCD to binary subroutine, this is reduced to: (lO^D^ + IOD2 + D3);(10^D^ + lOD^ + D^) The high order part of the BCD word is effectively multiplied by 1000 (=8(128 - 3)) and the low-order part is added, giving lO^D^ + 10'^D2 + lO^D^ + lO^D^ + lOD^ + D . See Chapter 11. 12 5 . EXAMPLES GO, X, HIGH, LOW, JMS I X HIGH HLT DOUBLE 1001 1001 1001 1001 1001 1001 999,999 If this program were started at GO, the C(AC) at the halt would be 0364g and C (LOW) would be 1077g, i.e., 03641077g = 999,999^q. 12.6 PROGRAM LISTING /COPYRIGHT 1971 /DIGITAL DIGITAL EJJIPMSNf CO'^POKAriON 8-11-U-SYM /DOUBLE PRECISION BCD TO BINARY CONVERSION /CALLING SEQUENCE: JMS DOUBLE / ADDRESS OF HIGH ORDER ARGUMENT / C(AC)=HIGH ORDER PART RETURN: / CCLOW) = LOW ORDER PART / /ALSO CONTAINS SINGLE PRECISION BCD TO BINARY /CALLING SEQUENCE: CCAC) = 3 BCD CHARACTERS / / JMS BCDBIN ANSWER IN CCAC) RETURN: / 12-2 0200 020 0202 0203 0204 1 0205 0206 020 7 0210 (Tl iC O C 1 1 1 DOUBLE. 7300 1600 3271 2200 1671 4275 3272 2271 1 I U f I 0212 0213 0214 4275 ao Q 7 112 021 6 7012 7010 3275 1275 0327 3274 1275 7010 0325 1 0217 0220 0221 0222 0223 0224 0225 0226 0227 0230 0231 0232 0233 0234 0235 0236 0237 0240 0241 242 0243 0244 0245 0246 0247 0250 0251 0252 0253 0254 0255 0256 0257 0260 0261 0262 3271 1272 32 7 3 1272 7104 1272 7 141 1273 3273 7420 i L_/ TAD DCA TAD CLL RAL AND DCA TAD CLL RAL DCA TAD RAL AND TAD 1274 3274 1273 0326 7100 127 3273 1274 7430 1 7001 5600 I n*.i L- »^ VV 1 i /FETCH ADDRESS /STORE /INCREMENT RETURN /FETCH HIGH ORDER /CONVERT IT /STORE /INCREMENT POINTER / p r T Q u LOW ORDER /CONVERT IT /STORE IT 1 CM A 0324 T i JMS BCDBIN DCA LOWl TAD HIGH CLL PTP RTR RAR DCA BCDBIN TAD BCDBIN AND K 177 DCA HIGH TAD BCDBIN RAR AND K7600 DCA LOW TAD HIGHl CLL RAL TAD HI GHl CIA CLL TAD LOW DCA LOW SNL 40 02 6 3 02 6 5 Tn An 1274 3274 1274 7106 7004 0326 32 7 4 1273 7106 7004 3273 1273 7004 7 0264 0266 0267 0270 CLA CLL TAD I DOUBLE DCA LOWl DOUBLE I SZ TAD I LOWl JMS BCDBIN DCA HIGHl LOWl I SZ /MULTIPLY HIGH ORDER /PART BY 128 /MULTIPLY HIGH ORDER /BY THREE /FORM 128*HI GH-3*HI GH HIGH HIGH HIGH /125*HI GH /NOW MULTIPLY BY /MASK K7771 9 BITS HIGH LOW RTL LOW LOW /3 BITS K7 HIGH DCA HIGH TAD LOW AND K777£ /9 CLL TAD L W DCA LOW TAD HIGH SZL I AC I BITS /ADD LOW ORDER PART /STORE LOW ORDER PART 1 JMP 8 RTL /CARRY DOUBLE 12-3 027 0272 02 7 3 1 0274 02 7 5 0276 0277 0300 0301 0302 0303 0304 0305 0306 0307 0310 031 1 0312 0313 0314 0315 0316 0317 0320 032 0322 0323 0324 0325 0326 0327 0330 1 0000 0000 0000 0000 0000 3274 1274 0330 7112 3273 1273 7010 1273 LOWl^ HIGHl, LOW, HIGH, /SINGLE PREC;isiON BCDBIN, DCA HI GH TAD HIGH AND K7400 K7760, K7, 7 K7600, K7770, K177* K7400, 7600 7770 3274 1274 0323 71 12 3273 1273 7010 0007 7600 7770 0177 7400 /LEFT DIGIT CLL RTR DCA LOW TAD LOW RAR TAD LOW CIA TAD HIGH DCA HIGH TAD HIGH AND K 7 7 6 CLL RTR DCA LOW TAD LOW RAR TAD LOW CIA TAD HIGH JMP I BCDBIN 7760 7041 1274 1273 7041 1274 5675 7760 co; 177 7400 12-4 Formerly — o Digitalb-^^-u-bym I '^ '^ CHAPTER 13 UNSIGNED DECIMAL INTEGER PRINT ABSTRACT 13.1 This subroutine permits the printing of the contents of a computer word as a 4-digit, positive, decimal integer. 13 REQUIREMENTS . This subroutine requires 38, ^j core locations and runs on ^^^q^ any standard PDP-8 family computer with a 33-ASR Teletype console. The paper tape provided is labeled Unsigned Decimal Print Subroutine, Digital- 8-22-ASCII USAGE 13.3 Loading 13.3.1 The subroutine can be placed in core by use of the Binary Loader. See Introduction to Programming or Programming Languages for full The symbolic tape provided is either assembled with the details. user program or separately with the proper origin setting. Calling Sequence 13.3.2 The subroutine is called by the usual JMS instruction with the number to be printed in the AC. Return to the location following that of the calling JMS. 13.4 DESCRIPTION This is a basic subroutine used to obtain decimal output corres- ^Kjn'ji.^i.LKj UVJ kjj.xi.CLS. Y WKJJ-KJLO ±.11 luciin^J- _y * xiLKZ j^j. i^Cj J. dill i^^Jc: J- CI w::^ o j-ii «. o »-j. cij.'wj j.* <- First the binary equivalent of 1000 is subtracted from the original number until a negative result is obtained. A count forward manner. is kept of the number of subtractions necessary to accomplish this, thus yielding the most significant decimal digit. 13-1 This process is repeated, using the proper power of ten, to give the three remaining decimal digits. 13.5 METHOD This method of binary to binary-coded-decimal conversion is compact and easily understood, if not sophisticated. The latter consideration is of little consequence, since the subroutine is output limited. 13.6 OUTPUT DATA FORMAT Output is in the form of four consecutive decimal digits. No sign is printed. Spacing, tabulation, carriage return, etc. are not provided in this subroutine. 13.7 PROGRAM LISTING 0200 020 0202 0203 0204 0205 0206 0207 0210 0000 3243 3244 1235 3245 1234 3213 7410 3243 021 02 12 1 7 100 0213 1243 1236 7430 1 0214 0215 0216 0217 0220 0221 0222 0223 0224 0225 022 6 2244 7430 5210 7200 1244 1242 6041 5223 6046 7200 /COPY:<lGHr 1971 DIGITAL £2 JI PM^^sjx COr^POKA f I OnJ /MArNARD, ^^ASSACHJSbfrS /DIGITAL 8-22-U /UiMSIGNED DECIMAL PRINT /CALL WITH NUMBER TO BE TYPED IN CCAO /RETURN TO LOCATION FOLLOWING THE JMS DECPRT, DCA VALUE /SAVE INPUT DCA DIGI T /CLEAR TAD CNTRZA DCA CNTRZB /SET COUNTER TO FOUR' TAD ADDRZA DCA ARROW /SET TABLE POINTER SKP DCA VALUE /SAVE CLL TAD VALUE ARRO W. TAD TENPWR /SUBTRACT POWER OF TEN SZL ISZ DIGIT /DEVELOP BCD DIGIT SZL JMP ARROW-3 /LOOP CLA /HAVE BCD DIGIT TAD DIGIT /GET DI GIT TAD K260 /MAKE IT ASCI I TSF /OR TAD DIGIT JMP .JMS TDIGITCSEE 8- 19-U) / TLS /TYPE DIGIT CLA 1 13-2 0227 0230 0231 0232 0233 3244 2213 2245 5212 5600 0234 1236 023 5 0236 7774 6030 7634 7766 7777 0260 0000 0000 0000 0237 0240 0241 02 42 0243 0244 0245 ADDRZA, CNTRZA, TENPWR. DCA DIGIT ISZ ARROW ISZ CNTRZB JMP ARROWTM D T ViVrC DDT TAD TEiMPWR -4 - 1 /ONE THOUSAND /ONE HUNDRED /TEN /ONE 750 -0144 -0012 -0001 K260, VALUE, DIGIT, CNTRZB, /CLEAR /UPDATE POINTER /DONE ALL FOUR? /NO: CONTINUE /YES: EXIT 260 13-3 Formerly Digital-8-23-U-Syin CHAPTER 14 SIGNED DECIMAL INTEGER PRINT SUBROUTINE, SINGLE PRECISION ABSTRACT 14.1 This subroutine permits printing the contents of a computer word is a "1", the remaining bits represent a negative integer in two's equals "0", the remaining bits represent complement form; if bit a positive integer. If the number is negative, a minus sign is printed; if positive, a space. REQUIREMENTS 14.2 This subroutine requires 51,^ ^^^r^ core locations and runs on any standard PDP-8 family computer with a 33-ASR Teletype console. The program is provided on a source tape labeled Signed Decimal Print, Single Precision, Digital- 8-23-U-ASCII USAGE 14.3 14.3.1 Loading The symbolic tape provided is compatible with the PAL III, MACRO- 8, or PAL-D assemblers. It can be assembled with the user's program or separately with the proper origin setting. Neither origin setting nor "$" terminating character exists on the symbolic tape provided. 14.2.1 Calling Sequence The subroutine is called by an effective "JMS SSPRNT" with the number to be printed in the AC. ing that of the calling JMS. The return is to the location follow- The contents of neither the AC nor the link are preserved, and return is with both active registers clear. 14.4 DESCRIPTION This is a basic subroutine to obtain signed decimal output (integer format) corresponding to binary words in memory stored in two's complement form. First, the number is sensed to determine if it is positive or negative. If positive, a space is printed. 14-1 If negative, a minus sign is printed and the number complemented to form the absolute value in two's complement. Then, the same algorithm is followed as in the unsigned printout described in Chapter 13. OUTPUT DATA 14.5 Output is in the form of four consecutive decimal digits preceded Spacing, tabulation, carriage by either a space or minus sign. return, etc. are not provided in this subroutine. See Chapter 6, which contains details on subroutines for such purposes. This sub- routine is output limited at 10 cps by the 33-ASR. FLOW CHART 14.6 r ENTRY yes CLEAR LINK MODIFY CODE TQ"-" ^.^THE NUMBER \^ V. NEGATIVE ^\ YES TYPE OUT CHARACTER ^^ ^ NO SET LINK TO "l." FORM ABSOLUTE VALUE PICK UP CURRENT POWER OF TEN 1r STORE NUMBER AWAY ^ SUBTRACT CURRENT POWER OF TEN FROM NUMBER ' INITIALIZE COUNTERS. POINTERS AND DIGIT STORAGE REGISTER INDEX DIGIT INDEX INSTRUCTION TO GET NEXT YES LOAD CODE FOR "space" INTO AC POWER OF TEN LOAD GENERATED DIGIT INTO AC TYPE IT OUT SUBROUTINE FINISHED 14-2 c EXIT 3 14.7 PROGRAM LISTING OIGIf^L EJJIP^SNr COrJPOKA /COPr.^IGHF 1971 A^1AYNARD# NlASSACKUSEirS /BINARY TO DECIMAL CONVERSION AND TYPEOUT 0200 0201 0202 0203 0204 0205 0000 7100 7510 0210 3253 3251 1250 3252 1244 0211 0212 0213 0214 3217 1246 7430 1247 DCA TAD SZL TAD 0215 0216 0217 0220 0221 0222 0223 0224 0225 0226 0227 0230 0231 4235 7061 1253 1254 7510 5225 2251 3253 I ON /SINGLE PRECISION /AC CONTAINS BINARY WORD /CALLING SEQUENCE: / JMS SSPRNT /SUBROUTINE CALL /RETURN. AC AND L CLEAR SSPRNT^ CLL SPA CML DCA DCA TAD DCA TAD 0206 0207 1 SSXYZ> JMS TAD TAD SPA JMP ISZ I POSITIVE? /IS IS /NO^ SET LINK^FORM ABSOLUTE VALUE CMA I AC /STORE NUMBER AWAY SSVAL /SET DIGIT LOCATION TO ZERO SSBOX /INITIALIZE OUTPUT COUNTER TO "4" SSCNTR SSCNT /INITALIZE INSTRUCTION TO GET SSADDR /FIRST 10 SSXYZ+1 SSPLUS /GET CODE TO TYPE A "PLUS" NUMBER NEGATIVE? /IS THE T SSMNS /YES> CHANGE CODE TF TYPE A /"MINUS" SSOUT /TYPE IT OUT SSVAL /PICK UP NUMBER SSCON /SUBTRACT CURRENT POWER OF 10 /IS THE RESULT NEGATIVE? T .+4 /YES^ INDEXING IS FINISHED SSBOX /NO^ INDEX THE DIGIT LOCATION SSVAL /STORE REMAINDER IN SSVAL SSXYZ /CONTINUE SUBTRACTING 3251 2217 DCA JMP CLA TAD SSBOX JMS SSOUT DCA SSBOX ISZ SSXYZ+1 0232 0233 0234 2252 5216 5600 ISZ SSCNT JMP SSXYZ JMP I SSPRNT 0235 0236 0237 0240 0000 1245 6046 6041 5240 7300 5635 1254 5216 7200 1251 4235 /PICK UP THE DIGIT NUMBER /TYPE IT OUT /SET DIGIT COUNTER TO "0" /INDEX INSTRUCTION TO GET /POWER OF 10 /have we typed "4" digits /no^ continue /yeSj return /TYPEOUT ROUTINE 0241 0242 0243 0244 SSOUT:. TAD TLS TSF JMP CLA JMP SSADDR> TAD SSTWO .-1 CLL I SSOUT SSCON /INSTRUCTION TO PICK UP FIRST /POWER OF 10 14-3 0245 0246 0247 0250 0251 0252 0253 0254 0255 0256 0257 0260 7760 0015 7774 0000 0000 0000 SSTWO^ SSPLUS^ SSMNS^ SSCNTR^ SSBOX^ SSCNT^ SSVAL^ 6030 7634 7766 7777 /TABLE OF POWERS OF 10 SSCON^ /-1000 6030 /-100 7634 /-10 7766 7777 /-I 260 -20 15 -4 /BASIC CODE FOR DIGITAL OUTPUT /NUMBER USED TO GENERATE "SPACE" /NUMBER USED TO GENERATE "MINUS" /COUNT OF "4" DIGITS /STORAGE REGISTERS 14-4 Formerly Digital-8-24-U-Sym CHAPTER 15 UNSIGNED DECIMAL INTEGER PRINT SUBROUTINE, DOUBLE PRECISION 15 . ABSTRACT This subroutine permits printing a double-precision integer stored The one excepin the usual convention for double-precision numbers*. tion is that all 24 bits are interpreted as magnitude bits (i.e., The printout the bit "0" of the high-order word is not a sign bit) is in the form of an eight-digit, positive, decimal integer. . REQUIREMENTS 15.2 This subroutine requires 73^q (lllg) locations and runs on any standard PDP-8 family computer with a 33-ASR Teletype console. The source tape is labeled Unsigned Decimal Print, Double Precision, Digital- 8-24-U-ASCII 15 . 15.3.1 USAGE Loading The symbolic tape provided can be assembled with PAL III, MACRO-8, It can be assembled with the user program or separately or PAL-D. "$" with the proper origin setting. Neither origin setting nor terminating character exists on the tape; the tape does have a PAUSE statement on the end. 15.3.2 Calling Sequence The This subroutine is called by an effective JMS UDPRNT. location immediately following the calling JMS contains the address *For details on storage of double-precision numbers, see the Math Routine s writeup available from the PDP-8 Program Library, section oiT Double Precision Signed Multiply Routine. 15-1 uf the high-order portion of the double-precision integer stored in the usual double-precision format. DESCRIPTION 15.4 This is basic double-precision subroutine used to obtain decimal output corresponding to double-precision binary words. First, the binary equivalent of 10,000,000 is subtracted from the original number until under-flow occurs. A count is kept of the number of subtractions necessary to accomplish this, thus yielding the most significant decimal digit. Then this digit is added to 2608 and printed on the 33-ASR through the AC. This process is repeated using the proper power of ten to give the seven remaining digits. The numbers are interpreted and printed as integers. See Chapter 13 for a discussion of the techniques used. 15 FORMAT . 15.5.1 Core Data The double-precision integers are stored in the usual doubleprecision formats with the exception that bit "0" of the high-order word is interpreted as part of the number not a sign bit. 15.5.2 Output Data Output is in the form of eight consecutive decimal digits. No sign is printed. Spacing, tabulatic^ carriage return, etc., are not provided for in this subroutine. See Chapter 6 which contains details on short subroutines for such purposes. , This subroutine is output limited at 10 cps by the 33-ASR. 15-2 15.6 FLOW CHART C ENTRY D PICK UP ADDRESS OF HIGH ORDER WORD FROM Calling SEQUENCE PICK UP DOUBLE PRECISION NUMBER FOR USE IN SUBROUTINE INITIALIZE COUNTERS, POINTERS AND STORAGE REGISTERS PICK UP CURRENT POWER OF TEN FOR USE IN SUBTRACTION 1 PERFORM DOUBLE PRECISION SUBTRACT FROM NUMBER STORE REMAINING PORTION OF DOUBLE PRECISION NUMBER PICK UP GENERATED DIGIT TYPE IT OUT SUdKUUIINt FINISHED C EXIT 15-3 3 INDEX TO PICK UP NEXT POWER OF TEN. PUT DIGIT COUNT TO ZERO 15.7 PROGRAM LISTING /COPYlIGHf 1971 DIGITAL /M^i^^rio* ;^AssACH'jssrfs /Ui^sISIGiMED DECIi-WAL /CALLING SEQUENCE: / / 0200 020 0202 0000 7 300 0203 0204 3267 020 5 0206 020 7 3261 2267 02 10 02 1 1 0212 3262 1255 3260 02 13 12 56 1 UDPRNT> CLA CLL TAD I UDPRNT 1600 DCA UDGET TAD I UDGET 166 7 DCA UDHIGH ISZ UDGET TAD I UDGET DCA UDLOW TAD UDLOOP DCA UDCNT TAD UDADDR DCA UDPTR ISZ UDPRNT 1667 32 7 02 15 2200 12 16 167 0217 0220 022 0222 0223 0224 22 7 ISZ UDPTR 3263 1670 2270 3264 7100 DCA UDHSUB TAD I UDPTR UDPTR I SZ DCA UDLSUB CLL 022 5 0226 022 7 0230 023 0232 0233 1264 1262 3266 7 004 1263 023 4 023 5 52 42 22 6 5 TAD TAD DCA RAL TAD TAD SNL JMP ISZ 1236 3261 DCA UDHIGH 1 1261 7420 Cj,<PO^^A fl O.nj PRINT, DOUFJLE PRECISION JMS UDPRNT /SUBROUTINE CALLED HI AODR /ADDRESS OF HIGH ORDER /WORD RETURN /RETURN WITH AC AND L /CLEAR 0214 1 £:j JIPM:£,^j f UDARND, UDDO TAD I UDPTR /PICK UP ADDRESS OF /HIGH -ORDER WORD /PICK UP BOTH WORDS FOR /USE IN SUBROUTINE /INITIALIZE DIGIT COUNTER /FOR "8" /INITIALIZE TO TABLE OF /POWERS OF TEN /INDEX LINKAGE FOR CORRECT /RETURN /PICK UP CURRENT /POWER OF TEN FOR /USE IN SUBTRACTION /DOUBLE PRECISION /SUBTRACTION UDLSU3 UDLOW UDTEML UDHSUB UDHIGH UDOUT UDBOX 15-4 /DID IT UNDERFLOW? /NO, COUNT I S DONE /YES, COUNT NOT DONE YET /INDEX DIGIT /DEPOSIT REMAINING PORTIONS /OF WORD 023 7 0240 0241 1266 32 62 522 4 0242 024 3 7 TAD UDTEML DCA UDLOiy\J JMP UDDO 024 4 126 5 1257 0245 0246 6046 6041 CLA TAD uDBOX TAD UDTWO TLS TSF 02 4 7 52 4 6 J\AP 300 3265 2260 5216 5600 CLA CLL DCA UDBOX 0250 02 51 02 52 0253 0254 0255 02 56 02 5 7 0260 02 6 1 0262 026 3 026 4 0265 026 6 026 7 0270 0271 027 2 0273 200 7 0260 0000 0000 0000 0000 0000 0000 0000 0000 0000 3166 UDTWO. 260 1 0302 0303 0304 0305 0306 0307 0310 1 UDCON /INITIALIZE DIGIT TO "0" /HAVE WE TYPED "8" DIGITS /NO, DETERMINE NEXT DIGIT /YES> SUBROUTINE DONE. /RETURN /COUNT OF "8" DIGITS /INITIAL ADDRESS OF /POWERS OF TEN FOR DIGITS /I CODE /STORAGE LOCATIONS 1 UDCiMT, UDHIGH, UDLOW, UDHSUB* U0LS1J3. UDBOX^ UOTEML, UDGET* UDPTR> UDCONl, 4 600 7413 6 7 00 - JMP UDARND JMP I UDPRNT 7770 0271 7747 4540 7775 4360 7777 6030 7777 7634 • /ADD "261 )" TO IT /TYPE IT OUT SZ UDCtMT -10 02 7 5 02 7 7 300 030 I UDLOOP^ UDADDR, 0274 0276 UDOUT^ /GO BACK AND SUBTRACT /AGAIN 7 77 7 7766 7777 7777 /POWERS OF TEN 3166 4600 7413 6700 7747 4540 7775 4360 7777 6030 7777 7634 7777 7765 7777 7777 y 1/-X rx rx ryi r% r% r% / - iVJ > \D\OVJ> \OVJVJ /- 1*000^000 /- 100*000 /- 10*000 /- 1*000 /- 100 /- 10 /- 1 PAUSE 15-5 Formerly Digital-8-25-U-Syin CHAPTER 16 SIGNED DECIMAL INTEGER PRINT SUBROUTINE, DOUBLE PRECISION This subroutine permits printing the contents of two consecutive computer words as one signed double-precision two's complement number. If bit of the high order word is a "1", the remaining 23 bits represent a negative integer in two's complement form; if equals "0", the remaining bits represent a positive integer. If the number is negative, a minus sign is printed; if positive, a bit space, REQUIREMENTS 16.2 This subroutine requires 86, q (126 g) core locations and runs on any standard PDP-8 family computer with a 33-ASR Teletype console. The source tape supplied is labeled Signed Decimal Print Double Precision, Digital-8-25-U-ASCII USAGE 16.3 16.3.1 Loading The symbolic tape provided is compatible with PAL III, MACRO- 8, and PAL-D assemblers. It can be assembled with the user's program or separately with the proper origin setting. Neither origin setting nor "$" terminating character exists on the symbolic tape provided, but a PAUSE pseudo-instruction is the last line on tape. 16.3.2 Calling Sequence The subroutine is called by an effective JMS SDPRNT. The location immediately following the calling JMS contains the address of the high-order portion of the signed, double-precision integer which is stored in the usual double-precision format. 16-1 For example: JMS SDPRNT ADDR HLT ADDR, |?123 4567 16 DESCRIPTION . This is a basic subroutine to obtain signed decimal output corresponding to a double-precision binary word storage in two consecutive locations in memory. First, the binary number is sensed to determine if it is positive or negative. If positive, a space is printed. If negative, a minus sign is printed, and the number complemented to form the absolute value. Then the same algorithm is followed as in the unsigned double-precision printout described in Chapter 15. The numbers are interpreted and printed as integers. FORMAT 16.5 16.5.1 Core Data The double precision integers are stored in the usual signed, doubleprecision format (see the Double Precision Signed Multiply section of the Math Routines writeup, available from the PDP-8 Program Library. 16.5.2 Output Data Output is in the form of seven consecutive decimal digits preceded by either a space or a minus sign. Spacing, tabulation, carriage return, etc., are not provided in this subroutine. See Chapter 6 which contains details on subroutines for such purposes. If the user wishes to print a "+" sign instead of a space, he can change the contents of location SDPLUS from "-15" to "-2". This subroutine is output limited at 10 cps by the 33-ASR. 16-2 16.6 FLOW CHART ENTRY c ) PICK UP ADDRESS OF HIGH -ORDER WORD PICK UP DOUBLE PRECISION NUMBER FOR USE IN SUBROUTINE \r COUNTERS AND POINTERS INITIALIZE } \ PICK UP CURRENT POWER OF TEN \ r PERFORM DOUBLE PRECISION SUBTRACT INDEX DIGIT FROM NUMBER INDEX TO PICKUP NEXT POWER OF TEN. PUT DIGIT COUNT TO ZERO i i i \ YES ^^ Die IT ^N. NO 1 STORE REMAINING PORTION OF DOUBLE PRECISION NUMBER V PICK UP GENERATED DIGIT TYPE IT OUT 1 y^l DIG! rs been\^ NO TYPED OUT ? YES c EXIT 16-3 3 \ 16.7 PROGRAM LISTING GHF 1971 Dibi r COKrO^^A n OiV D, i^ASSACHJSErrS /SIGNED DECIMAL PRINT^r DOUBLE PRECISION /CALL IN G SEQUENCE: JMS SDPRNT /SUBROUTINE CALLED / HIADDR /ADDRESS OF HIGH ORDER WORD / RETURN /RETURN WITH AC AND L CLEAR SDPRNT^ CLA CLL TAD I SDPRNT /PICK UP ADDRESS OF /HIGH-ORDER WORD DCA SDGET TAD I SDGET /PICK UP HIGH-ORER WORD SMA CLA /IS IT NEGATIVE? TAD SDPLUS /NO^ GENERATE CODE FOR SPACE TAD SDMNS /YES^ GENERATE CODE FOR "MINUS" JMS SDTYPE /TYPE IT OUT TAD I SDGET /PICK UP HIGH-ORDER WORD AGAIN SPA /IS IT POSITIVE? CMA CML /NO. COMPLEMENT IT. SET LINK DCA SDHIGH /STORE POSITIVE WORD FOR USE IN /SUBROUTINE ISZ SDGET TAD I SDGET /PICK UP LOW-ORDER WORD SZL /IS LINK SET? CMA CLL I AC /YES^ FORM TWO'S COMPLEMENT SZL /DID AC OVERFLOW FROM "lAC"? ISZ SDHIGH /YES^ CORRECT HIGH-ORDER WORD DCA SDLOW /STORE POSITIVE LOW-ORDER WORD TAD SDLOOP /INITIALIZE DIGIT COUNTER TO "7" DCA SDCNT TAD SDADDR /INITIALIZE POINTER TO TABLE OF /POWERS OF TEN DCA SDPTR ISZ SDPRNT /INDEX LINKAGE FOR CORRECT RETURN SDARND. TAD I SDPTR /PICK UP POWER OF TEN FOR USE IN /SUBTRACT ISZ SDPTR DCA SDHSUB TAD I SDPTR ISZ SDPTR DCA SDLSUB SDDO^ CLL /DOUBLE PRECISION SUBTRACTION TAD SDLSUB TAD SDLOW DCA SDTEML RAL TAD SDHSUB TAD SDHIGH SPA /DID IT UNDERFLOW? JMP SDOUT /N0:» COUNT IS DONE ISZ SDBOX /YES> COUNT NOT DONE. INDEX DIGIT ii^ 0200 0201 0000 7300 0202 1600 0203 0204 0205 0206 0207 0210 0211 0212 0213 0214 3307 0215 0216 0217 0220 0221 0222 0223 0224 0225 0226 1707 7700 1276 1277 42 64 1707 7510 7060 3301 2307 1707 7430 7141 7430 2301 3302 1273 3300 1274 0227 0230 0231 3310 2200 1710 0232 0233 0234 0235 0236 0237 0240 2310 3303 1710 2310 3304 7100 1304 1302 3306 7004 1303 0241 0242 0243 0244 0245 0246 0247 0250 1301 7510 5255 2305 16-4 251 3301 DCA SDHIGH 0252 1306 TAD SDTEML 0253 0254 0255 0256 0257 0260 0261 0262 0263 0264 0265 0266 0267 0270 3302 5237 7200 1305 4264 3305 2300 5231 5600 0000 DCA JMP CLA TAD JMS DCA 0271 0272 0273 0274 0275 0276 0277 0300 1275 6046 6041 5267 7300 5664 7771 031 1 0260 7763 7775 .qDnuT., ISZ JMP JMP SDTYPE:. 0302 0303 0304 0305 0306 0307 0310 SDLOW^ SDHSUB^ SDLSUB^ SDBOX^ 0312 0313 0314 0315 0316 0317 0320 0321 0322 0323 0324 0325 0326 /GO BACK AND SUBTRACT AGAIN /PICK UP RESULTING DIGIT SDBOX /TYPE IT OUT SDTYPE /INITIALIZE DIGIT TO "0" SDBOX /HAVE WE TYPED "7" DIGITS SDCNT /NO^ DETERMINE NEXT DIGIT SDARND /YES:» SUBROUTINE DONE. RETURN I SDPRNT /TYPEOU T ROUTINE SDTWO . SDHIGH;, 031 1 SDLOW SDDO TAD TLS TSF - 1 JMP CLA CLL JMP I SDTYPE /COUNT OF SEVEN DIGITS SDLOOP^ -7 SDADDR^ SDCONL /INITAL ADDRESS OF POWERS OF TEN /BASIC CODE FOR DIGITS SDTWO^r 2 60 /"SPACE ". TO TYPE " + 'S REPLACE BY "-2' SDPLUS:» -15 -3 /"MINUS" SDMNS:» /STORAGE LOCATIONS SDCNT^ 0301 0000 /DEPOSIT REMAINING HIGH-ORDER /PORTION /RESTORE REMAINING LOW-ORDER /PORTION SDTEML,' SDGET^ SDPTR:» 7413 6700 7747 4540 7775 4360 7777 6030 7777 7634 7777 7766 7777 7777 SDCONL^ 7413 6700 7747 4540 7775 4360 7777 6030 7777 7634 7777 7766 7777 7777 /TABLE OF POWERS OF TEN /-1^000^000 /-100^000 /-10^000 /-U000 /-100 /- 10 /-I 16-5 Formerly Digital- 8- 14-U-Sym CHAPTER 17 BINARY TO BCD CONVERSION CBinary to Binary Coded Decimal Conversion) 17.1 ABSTRACT This subroutine provides the basic means of converting binary data to binary-coded-decimal (BCD) data for printing, magnetic tape recording, etc. 17.2 REQUIREMENTS This subroutine uses 33, q (41g) storage locations and runs on any standard PDP-8 family computer with a 33-ASR Teletype console. The source tape provided is labeled Binary to Binary Coded Decimal Conversion, Digital-8-14-U-ASCII 17.3 CALLING SEQUENCE The subroutine is called by the JMS instruction. When called, the binary number to be converted must be in the accumulator (AC) The subroutine returns to the instruction immediately following the calling JMS with the BCD result in the AC. 17.4 DESCRIPTION Reference to the Flow Chart (Figure 17.1) illustrates this dis- cussion. On input the binary number is stored, a pointer is initialized, the link is cleared, and a counter to control the number of passes through the computation loop proper is properly set. The loop is now entered, and is repeated eight times. The binary equivalents of 800, 400, 200, 100, 80, 40, 20, and 10 are subtracted successively from the original binary number. 17-1 After each subtraction, a test on the link is made. If the result of the test shows the link to be 0, the next lower equivalent is subtracted from the same quantity after the contents of the links are shifted into the developing BCD number (Location NUMBER) If the subtraction leaves a negative link, (0) the contents of the accumulator replace the binary representation currently being processed after the contents of the link (1) have been shifted into the growing BCD number. After eight passes through the basic loop, the developed BCD representation is shifted left four bits and the "residual" least significant digit is added before exit. 17.5 EXAMPLE As an example consider the conversion of the binary equivalent of 512 decimal: Link Addition 001 000 000 000 110 Oil 100 000 111 Oil 100 000 -800 001 000 000 000 111 001 110 000 000 001 110 000 -400 000 001 110 000 111 110 001 000 111 111 111 000 200 000 001 110 000 111 110 oil 100 000 000 001 100 -100 Notice that the remainder is the binary representation of 12 decimal. Writing the link bits in the order they are developed gives 0101 the BCD character denoting 17.6 5. SCALING The original binary number must be no larger than 999 (decimal) The binary point is assumed to which is equivalent to 1747 (octal) be at the extreme right end of the word (to the right of bit position . 11) and the decimal point is also so positioned. 17-2 In other words, this subroutine converts binary integers to BCD integers. Note that the subroutine is designed for positive input only DATA-*. INPUT (CONTROL)-* POINTER (COUNT)-* AC (AC)-*NUMBER TAD INPUT POINTER TAD TABLE (L) = (L)=1 (AC)-* INPUT RETURN Figure 17.1 FLOW CHART 17-3 I FKUbKAM iilb'illNHa 1 / . / A listing of the program with BCD located in 0200 appears as follows /BINARY TO BCD CONVERSION 3/6/6 5-HB-DEC /ENTER WITH BINARY NUMBER C<999(10)) /IN ACCUMULATOR.; EXIT WITH THREE CHARACTER /BCD NUMBER IN ACCUMULATOR /AC 0-3J AC 4-7; AC 8-11 WILL CONTAIN /THE BCD CHARACTER ON EXIT /WEIGHTING: AC 0-3 100 AC 4-7 AC 8-11 / / 1 1 /STORAGE 33(10) REGISTERS /TIME=216 0-235.2 MICRO-SECONDS PDP-8 /IF INPUT >999 (10) RESULT IS UNSPECIFIED 0200 020 1 0202 0203 0204 020 5 0206 0203 322 6 1225 3210 7 100 0207 1230 322 7 1226 02 10 1231 021 7430 322 6 7200 1 0212 0213 02 14 122 7 0215 0216 7004 2210 7420 5206 7106 7006 1226 5600 0217 0220 0221 0222 223 022 4 22 5 0226 0227 0230 0231 0232 0233 0234 0235 0236 0237 0240 BCD, 1231 0000 0000 0020 6340 7160 7470 7634 7660 7730 7754 7766 POINTR, DCA TAD DCA CLL TAD DCA TAD TAD INPUT CONTRL POINTR /STORE BINARY /SET UP TABLE /POINTERS COUNT NUMBER INPUT TABLE /SET BIT 7= l; 8RAL 'S /WILL PUT IT IN LINK /OR TABLE+1, TABLE+2, ETC SZL /IF C(L)=1, INPUT>-TABLE /IF SO: INPUT=INPUT+TABLE DCA INPUT CLA TAD NUMBER RAL I CONTRL INPUT* NUMBER COUNT TABLE, /PUT THIS BIT IN ANSWER /UPDATE TABLE POINTER /IF LINK=1, ALL DONE SZ POINTR SNL JMP CLL RTL TAD JMP TAD POINTR-2 /CONVERTED 2 BCD /CHARACTERS /SHIFT LEFT AND Ann /THE THIRD RTL INPUT BCD TABLE I 0020 - 1440 -0620 -0310 -0144 -0120 -0050 -0024 -0012 /EXAMPLE: INPUT 0726 (8) / OUTPUT 0100/01 17-4 /-800( 10) /--400 /-200 /- 100 //--40 /--20 /- 10 - 80 1 1/0000 - Al(d ( 10) Formerly Digital- 8-15-U-Syin CHAPTER 18 BINARY TO BCD CONVERSION (4-DIGIT) (Binary to Binary Coded Decimal Conversion, 4-Digit) ABSTRACT 18.1 This subroutine extends the method used in Chapter 17 so that binary integers from to 4095 contained in a single computer word may be converted to four binary-coded-decimal characters packed in two computer words REQUIREMENTS 18.2 This subroutine uses 53^^ ^^^s^ storage locations and runs on any standard PDP-8 family computer with 33-ASR Teletype Console. The source tape provided is labeled Binary to Binary-Coded-Decimal Conversion (Four Digit) , Digital- 8-15-U-ASCII CALLING SEQUENCE 18.3 This subroutine is called by the JMS instruction with the binary number to be converted in the accumulator (AC) This subroutine returns to the location immediately following The format of the result is discussed that containing the calling JMS. below. 18.4 DESCRIPTION This program is essentially Digital-8-14-U-ASCII (described in Chapter 17) extended to allow for integers in the range of 1000 to 4095. 18.5 CORE DATA Results appear in core as: Word TWO Word ONE 012. .5678. .11 12 .5678 10 10 ~BA , BA RA 18-1 10 BA 11 The decimal coding for 2048 is illustrated. 18.6 IBM COMPATIBILITY Note that bits 0, 1 and 6, 7 are set so that they can be regarded as zone B and zone A bits required for IBM BCD mode compatible 6-bit numerical characters. In this mode of recording, the character 1010 is used for zero instead of code 000 which this subroutine produces. Therefore, to use this routine in conjunction with IBM-compatible mag tape recording, it is necessary to write a short auxiliary routine to make this sub- stitution. It may also be necessary to generate the even parity required by such recording if this is not accomplished in the tape control hardware 18.7 PROGRAM LISTING /CO^YrilGHT 1971 DIGITAL E.2 Jl >^>^ZS^T COr^POxA FI /MAy,NiA:iJD> >1ASSACHJSErrs /BINARY TO BCD CONVERSION 3/7/65-HB-DEC /ENTER WITH BINARY NUMBER IN ACCUMULATOR /EXIT WITH A SIX-BIT BCD CHARACTERS /PACKED TWO TO A WORD IN REGISTERS /ONE AND TWO OR IN A BUFFER. /USED FOR WRITING MAG-TAPE IN BCD FORMAT /IN ADDITION TO BCD PARITY /OUTPUT FORMAT: / ONE 0-1 A,B BITS / ONE 2-5 1000 DECADE / ONE 6-7 A^B BITS / ONE 8100 DECADE / 0TWO A^B BITS / TWO 2-5 10 DECADE 6-7 / TWO A^B BITS / TWO 8DECADE -53 /STORAGE 10 lEGl STEPS /TIME 324.8-350.4 MI CRO- SECONDS PDP-8 1 1 1 1 C 18-2 M 0200 0201 0202 0000 3223 20 3 20 4 3240 020 5 20 6 0207 02 10 02 0212 4234 7106 4234 0213 4234 7106 7006 7006 1 1 021 4 02 15 0216 0217 0220 0221 0222 0223 0224 0225 0226 0227 0230 0231 0232 0233 023 4 0235 0236 023 7 02 40 0241 0242 024 3 0244 02 4 5 2246 02 4 7 02 50 251 BCD. DCA TAD DCA TAD JMS CLL 122 5 1226 RTL STEP TAD BITSl DCA ONE TAD C0UNT2 JMS STEP CLL RTL RTL RTL TAD INPUT TAD BITS2 DCA TWO JMP I BCD 3230 1227 1223 1233 3231 5600 1010 0400 0000 0000 0000 0000 0000 7100 3224 1223 1252 7430 3223 7 200 1224 7004 2240 7430 5634 5236 1 /CONVERT NEXT /A.B BIT PATTERNS /OR DCA I AUTO (10-17) /SET-UP COUNT jy\s 1232 0000 0000 1252 /STORE BINARY /SET UP TABLE /POINTER /SET COUNT /CONVERT INPUT CONTRL POINTR COUNT STEP INPUT. NUMBER, CONTRL, COUNT 1. C0UNT2. /LEAST SIGNIFICANT BITS /A.B BIT PATTERMS /OR DCA I AUTO ( 10- 17) /EXIT TAD TABLE 1010 0400 ONE. TWO. BITSl. BITS2. STEP. POINTR. /OR ANY BIT PATTERN /OR ANY BIT PATTERN /ACTUAL CONVERSION /SUBROUTINE CLL DCA NUMBER TAD INPUT TAD TABLE /OR TABLE+1. TABLE+2. ETC SZL / DCA INPUT CLA TAD NUMBER /IF SO: RAL ISZ POINTR SZL JMP I STEP JMP POINTR- 18-3 IF CCL)=U INPUT>-TABLE INPUT=INPUT+TABLE /ROTATES WILL BRING /COUNT BIT INTO LINK /ctTTP nnMfT 0252 0253 0254 0255 0256 0257 0260 0261 0262 0263 0264 0140 4060 6030 6340 7160 7470 7634 7660 7730 7754 7766 TABLE. -7640 -3720 /-4000 ( 10) - 1750 - 1440 -0620 -0310 -0144 -0120 -0050 -0024 -0012 /EXAMPLE: INPUT / OUTPUT: ONE / TWO 7777 18-4 (8) 00 0100/ 00 1001/ 00 0101 =4095 ( 10) HOW TO OBTAIN SOFTWARE INFORMATION SOFTWARE NEWSLETTERS, MAILING LIST The Software Communications Group, located at corporate headquarters in Maynard, publishes newsletters and Software Performance Summaries (SPS) Newsletters are f^ublished m.onthlv. for the various Di'^ital '•Products and contain announcements of new and revised software, programming notes, software problems and solutions, and documentation corrections. Software Performance Summaries are a collection of existing problems and solutions for a given software system, and are published periodiFor infoiTmation on the distribution of these documents and how cally. to get on the software newsletter mailing list, write to: ^ Software Communications 0. Box F Maynard, Massachusetts 01754 P. SOFTWARE PROBLEMS Questions or problems relating to Digital s software should be reported A specialist is located in each to a Software Support Specialist. In Europe, software problem Digital Sales Office in the United States. reporting centers are in the following cities. ' Reading, England Paris, France The Hague, Holland Tel Aviv, Israel Milan, Italy Solna, Sweden Geneva, Switzerland Munich, West Germany Software Problem Report (SPR) forms ar6 available from the specialists or from the Software Distribution Centers cited below. PROGRAMS AND MANUALS In Software and manuals should be ordered by title and order number. the United States, send orders to the nearest distribution center. Digital Equipment Corporation Software Distribution Center 146 Main Street Maynard, Massachusetts 01754 Digital Equipment Corporation Software Distribution Center 1400 Terra Bella Mountain View, California 94043 Outside of the United States, orders should be directed to the nearest Digital Field Sales Office or representative. USERS SOCIETY DECUS, Digital Equipment Computer Users Society, maintains a user exchange center for user-written programs and technical application inThe society formation. A catalog of existing programs is available. publishes a periodical, DECUSCOPE, and holds technical seminars in the United States, Canada, Europe, and Australia. For information on the society and membership application forms, write to: DECUS Digital Equipment Corporation 146 Main Street Maynard, Massachusetts 01754 DECUS Digital Equipment, S.A. 81 Route de I'Aire 1211 Geneva 26 Switzerland READER'S COMMENTS NOTE: This form is for document comments only. Problems with software should be reported on a Software Problem Report (SPR) form (see the HOW TO OBTAIN SOFTWARE INFORMATION page) Did you find errors in this manual? If so, specify by page. Did you find this manual understandable, usable, and well-organized? Please make suggestions for improvement. Is there sufficient documentation on associated system programs required for use of the software described in this manual? If not, what material is missing and where should it be placed? Please indicate the type of user/reader that you most nearly represent. I I Assembly language programmer I I Higher-level language programmer I I Occasional programmer (experienced) [ I User with little programming experience I I Student programmer i i Non- programmer interested in computer concepts and capabilities Date Name Organization ^__ -. Street City State Zip Code or Country If you do not require a written reply, please check here. Q Fold Here- -- Do Not Tear - Fold Here and Staple FIRST CLASS PERMIT NO. 33 MAYNARD, MASS. BUSINESS REPLY MAIL NO POSTAGE STAMP NECESSARY IF MAILED IN THE UNITED STATES Postage will be paid by: SOSDGID Software Coiranunications P.O. Box F •Maynard, Massachusetts 01754
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies