Post Reply 
(41C) Decimal Bitwise Operations
07-04-2022, 06:04 AM
Post: #2
RE: (41C) Decimal Bitwise Operations
Binary to Decimal Conversions

These programs are based on: (11C) Base Conversion
Only from-base and to-base are replaced by constant values.
An explanation can be found here and there.

Binary to Decimal:
Code:
  01 LBL "B-D"
  02 STO 00
  03 8
  04 X<>Y
  05 LBL 00
  06 2
  07 X<>Y
  08 10
  09 /
  10 INT
  11 X=0?
  12 GTO 01
  13 RDN
  14 *
  15 RDN
  16 *
  17 ST- 00
  18 RDN
  19 GTO 00
  20 LBL 01
  21 RCL 00
  22 END

Decimal to Binary:
Code:
  01 LBL "D-B"
  02 STO 00
  03 8
  04 X<>Y
  05 LBL 00
  06 10
  07 X<>Y
  08 2
  09 /
  10 INT
  11 X=0?
  12 GTO 01
  13 RDN
  14 *
  15 RDN
  16 *
  17 ST+ 00
  18 RDN
  19 GTO 00
  20 LBL 01
  21 RCL 00
  22 END

Examples

11011
XEQ B-D

27


110
XEQ D-B

1101110


This variant based on a program for the HP-25 saves one byte:
Code:
  01 LBL "B-D"
  02 STO 00
  03 8
  04 X<>Y
  05 LBL 00
  06 10
  07 /
  08 INT
  09 X=0?
  10 GTO 01
  11 X<>Y
  12 ENTER^
  13 ENTER^
  14 +
  15 RDN
  16 *
  17 ST- 00
  18 RDN
  19 GTO 00
  20 LBL 01
  21 RCL 00
  22 END
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (41C) Decimal Bitwise Operations - Thomas Klemm - 07-04-2022 06:04 AM



User(s) browsing this thread: 1 Guest(s)