Digital PDFs
Documents
Guest
Register
Log In
DIGITAL-8-28-U
December 1966
10 pages
Original
0.3MB
view
download
Document:
digital-8-28-u-d
Order Number:
DIGITAL-8-28-U
Revision:
Pages:
10
Original Filename:
https://svn.so-much-stuff.com/svn/trunk/pdp8/src/dec/digital-8-28-u/digital-8-28-u-d.pdf
OCR Text
IDENTIFICATION Product Code: DIGITAL-S-2S-U-SYM. Product Name: Single Precision Decimal-to-Binary Conversion and Input ASR 33, Signed or Unsigned Date Created: January 14, 1966 Maintainer: Software Service Group PDP-B LIBRARY DIGIT AL-8-28-U-SYM 1. 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 may 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. 2. PRELIMINARY REQUIREMENTS 2.1 Storage This subroutine requires 74 core locations. 2.2 Equipment Basic PDP-8 with ASR 33 3. LOADING OR CALLING PROCEDURE 3.1 Loading The symbolic tape provided may be assembled with the user's main program by either PAL III or MACRO-8. The symbolic tape has neither an origin setting nor a terminating "$", but does have a PAUSE pseudo-instruction at the end. 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 AC (accumulator). 4. USING THE ROUTINE 4. 1 Errors in Usage If a sign (+, -, or space) precedes the string of decimal digits, the maximum decimal number correctly accepted is 2047 (2 11 _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). 4.2 Recovery from Suc h Errors If either of these maxima is exceeded, the results are unspecified. 5. RESTRICTIONS 5.1 Status Active Registers The status of the AC and I ink is not preserved. 5.2 Status Hardware This subroutine should not be used when the interrupt is on. 5.3 Miscellaneous The magnitude restrictions on numbers are described in section 4.1 . DIGIT Al-8-28-U-SYM 6. DESCRIPTION 6.1 Discussion This subroutine converts to the binary equivalent a signed or unsigned string of decimal numbers read from the console keyboard of the PDP-8. 2's complement negative form. If a minus sign is specified, the results are in The first character is examined and, if it is a sign (+, -, 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 rub out 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 178 . 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 true for a decimal number of any arbitrary length. 6.2 Example and/or Application Since the PDP-8 can add and shift easily, the multiplication by 10 can be accomplished in three instructions. Since a shift left is equivalent to a multiplication by 2, a double shift left is equivalent to a multiplication by 4. 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 Comment Contents of AC TAD STORE /load C(STORE) into AC 000 000 000 101 Cll RTL /Multiply C(STORE) by 4 000 000 a1a 100 TAD STORE / Add STORE giving C(STORE) by 5 000 000 all 001 Cll RAl /Multiply by 2 giving C(STORE) by 10 000 000 110 010 TAD HOLD / Add in the next number 000 000 11 a all DCA STORE /Store back into STORE and return to wait for next character 000 000 000 000 ClA The number residing in location STORE is 00638 or 0051 10 . 2 DIGIT AL-8-28-U-SYM If the next number to come in were "9," using the same sequence and conditions, the result would be 001 000000 111, the binary equivalent of 519. 6.3 Scaling This subroutine assumes an integral decimal number (signed or unsigned) and yields an integral binary equivalent (signed or unsigned respectively). 7. METHOD The algorithm used is illustrated above (6.2) with details shown in the listing (I 0.1). 8. FORMAT 8. 1 Input The input string mayor may not contain a sign (+, -, or space). Any character other than a sign, 0 - 9, or back arro~ causes the subroutine to terminate, as does a sign in any but the first position. 8.2 Core Data The terminating character is found in location SISAVE. 8.3 Output Spacing, tabulation, carriage return, etc., are not provided for in this subroutine. See DIGITAL-8-19-U-Sym which contains short subroutines for the latter purposes. 9. EXECUTION TIME 9.1 Average This subroutine is input limited at a maximum of 10 hz. 10. PROGRAM 3 DIGITAl-8-28-U-SVM 10.1 Program listi ng ISINGlE PRECISION DECIMAL INPUT FROM KEVBOARD ICAlLING SEQUENCE: JMS SICONV IACC IGNORED, RETURN WITH BINARV WORD IN ACC 0200 0201 0202 0203 0204 0205 0206 0207 0210 0211 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 0000 7300 1274 3232 1274 3224 3310 3311 5257 3307 1307 1301 7450 5201 1302 7510 5232 1303 7740 5232 7300 1231 3224 1245 3232 5246 7300 1307 1304 7450 5274 1305 7450 5274 1306 7650 5273 5264 1310 7106 1310 7004 3310 1307 0300 1310 SICONV, 0 ClA Cll TAD SISETl + 1 DCA SICTRl TAD SISETl + 1 DCA SIXSWI DCA SIHOlD DCA SINEGI JMP SINPUT SIPROC, DCA SISAVE TAD SISAVE TAD SIRBUT SNA JMP SICONV + 1 TAD SIM260 SPA JMP SICTRl TAD SIM271 SMA SZA ClA JMP SICTRl SIXSW1, ClA Cll TAD .+4 DCA .-2 TAD SINMBR -1 DCA SICTRl JMP SINMBR SICTRl, ClA Cll TAD SISAVE TAD SIMSPC SNA JMP SISETl + 1 TAD SIMPlS SNA JMP SISETl + 1 TAD SIMMNS SNA ClA JMP SISETl JMP SIEND SINMBR, TAD SIHOlD Cll RTL TAD SIHOlD RAl DCA SIHOlD TAD SISAVE AND SIMASK TAD SIHOlD IINITIALIZE PROGRAM SWITCHES IClEAR NEGATIVE SWITCH ISTORE AND THE PROCESS CHARACTER liS IT A "BACK-ARROW" (IE. ERASE) KEV IVES, REINITIALIZE lIS IT lESS THAN 260 (IE. "0") IVES. TRANSFER TO SEE WHAT CHAR. IT IS liS IT GREATER THAN 271 (IE. "9")? IVES, TRANSFER TO SEE WHAT CHARACTER IT INO, FIRST CHARACTER WAS A DECIMAL DIGIT IClOSE SWITCH TO GO TO "SINMBR" NEXT ISET SWITCH TO SENSE TERMINATING CHAR. ICONTINUE CHECKING liS IT A SPACE? IVES, SET SWITCH TO SENSE TERM. CHAR. liS IT A "PLUS"? IVES, SET SW TO SENSE TERM. CHAR. liS IT A MINUS? IVES, SET NEGATIVE X SWITCH AND TERM SW. INO, IT WAS A TERMINATING CHAR. IMUlTIPlV CURRENT ASSEMBLED NUMBER BV 10 IPIC K UP CURRENT DIGIT IMASK OFF THE HIGH ORDER BITD I ADD TO ASSEMBLED NUMBER 4 DIGITAL-S-2S-U-SYM 0256 3310 DCA SIHOlD 0257 6031 SIN PUT , KSF 0260 5257 JMP .-1 0261 6036 KRB 0262 6046 TlS 5211 JMP SIPROC 0263 /TERMINATING ROUTINE 0264 7300 SIEND, CLA Cll 0265 1311 TADSINEGl 0266 7010 RAR 0267 131 0 TAD SIHOlD SZl 0270 7430 0271 7041 CMA lAC 0272 5600 JMP I SOCONV 0273 2311 SISETl, ISZ SIN EG 1 0274 7300 ClA Cll 0275 1245 TAD SINMBR -1 0276 3232 DCA SICTRl 0277 5257 JMP SINPUT /CONSTANTS AND VARIABLES 0300 0017 SIMASK, 17 0301 7441 SIRBUT, -337 0302 0057 SIM260, 57 0303 7767 SIM271, -11 0304 7540 SIMSPC, -240 0305 7765 SIMPlS, -13 0306 7776 SIMMNS, -2 0307 0000 SISAVE, 0 0310 0000 SIHOlD, 0 0311 0000 SINEG1, 0 /STORE BAC K IN SIHOlD /INPUT ROUTINE /PUT NEGATIVE SWITCH INTO LINK /IS THE LINK "1"? /YES, NUMBER NEGATIVE. COMPLEMENT /RETURN. /SET NEGATIVE SWITCH /ClOSE SW TO TRANSFER TO TERM. /CODE FOR ERASE /NUMBER USED TO GENERATE CODE "260" /NUMBER USED TO GENERATE CODE "271" /CODE FOR SPACE /NUMBER USED TO GENERATE CODE "253" (+) /NUMBER USED TO GENERATE CODE "255" (-) /STORAGE lOCATIONS 5 DIGITAL-S-2S-U-SYM 11 . DIAGRAMS 11 . 1 Flow Chart INITIALIZE a ZERO ASSEMBLY LOCATIONS WAIT FOR INPUT FROM KEYBOARD SET SIGN INDICATOR TO NEGATIVE MULTIPLY PARTIALLY ASSEMBLED NUMBER BY 10 6 DIGITAL-S-2S-U-SYM 12. REFERENCES 12. 1 Other Li brary Programs DIGITAL-S-19-U-Sym 7
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies