HP Forums

Full Version: (SR-52) Binary-to-Decimal conversion
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
  Binary-to-decimal number conversion, often needed when working with digital equipment, can require laborious raising to powers and addition. This program, designed for an SR-52 calculator, provides a convenient method of converting 8-, 16-, 24-, and 32-bit words to their decimal equivalents.
  To use the program, binary words are entered into the calculator eight bits at a time, most significant bit first. (Since the SR-52 has a 10-digit mantissa, the program ignores the first two digits entered and only operates on the last eight binary digits.) The user then presses the SR-52's user-defined key A, and the program displays the decimal.
  Here's a typical 8 -bit conversion:

ignored
┌┐
1 1 1 1 1 0 1 0 1 0 ← 1) Enter binary number in display
      └────────┘
            8-bits         ← 2) Press A Key

                    2 3 4  ← 3) Calculator Displays decimal equivalent

  To obtain 16-, 24-, and 32-bit conversions, do the above operation for the first eight bits, but for each additional eight bits entered, press the user-defined key B, which will sum that 8-bit conversion with all previous conversions, to a maximum of 32 bits.
  The conversion algorithm is shown here in flowchart
[attachment=8020]
and SR-52 program-listing form.
 Location        Codes                    Keys
000 - 003  46 11 42 00    *LBL   A        STO    0
004 - 007  00 00 42 00    0        0        STO    0
008 - 011  03 42 00 04    3        STO    0        4
012 - 015  42 00 05 08    STO    0        5        8
016 - 019  44 00 05 01    SUM    0        5        1
020 - 023  94 44 00 04    +/-      SUM   0        4
024 - 027  46 79 01 44    *LBL   *6      1         SUM
028 - 031  00 04 43 00    0        4        RCL     0
032 - 035  00 55 01 00    0        ÷        1        0
036 - 039  95 42 00 01    =        STO    0        1
040 - 043  51 78 43 00    SBR    *5       RCL     0
044 - 047  04 75 43 00    4        -        RCL     0
048 - 051  05 95 42 00    5        =        STO    0
052 - 055  06 43 00 01    6        RCL     0        1
056 - 059  75 43 00 02    -        RCL     0        2
060 - 063  95 90 68 43    =        *if0    *8       RCL
064 - 067  00 06 90 67    0        6        *if0     *7
068 - 071  02 45 43 00    2        y"       RCL     0
072 - 075  04 95 44 00    4        =        SUM    0
076 - 079  03 43 00 02    3        RCL     0        2
080 - 083  42 00 00 41    STO     0       0        GTO
084 - 087  79 46 67 43    *6      *LBL    *7      RCL
088 - 091  00 03 81 46    0        3        HLT     *LBL
092 - 095  68 43 00 06    *8      RCL     0        6
096 - 099  90 67 43 00    *if0    *7       RCL     0
100 - 103  02 42 00 00    2        STO    0        0
104 - 107  41 79 46 78    GTO    *6      *LBL    *5
108 - 111  75 93 05 54    -        .         5        )
112 - 115  57 00 52 22    *fix     0        EE      INV
116 - 119  52 22 57 42    EE       INV     *fix    STO
120 - 123  00 02 56 46    0        2        *rtn    *LBL
124 - 127  12 42 00 00    B        STO    0        0
128 - 131  41 00 01 05    GTO    0        1        5
  It works by performing repeated divisions by 10, splitting the dividend into integral and fractional parts, and then looking to see if the fractional part is a 1 or 0. If it is a 1, the program raises 2 to appropriate power and sums it into register 03. After the program has looped through eight bits, it recalls register 03 and halts.

source: RCA Engineer, Engineering and Research Notes, Binary-to-decimal conversion program for a programmable calculator, 1977-08/09, pg.76, A.R. Campbell

BEST!
SlideRule
Reference URL's