Post Reply 
HP-67 Base Conversion from HP Key Notes
10-19-2015, 06:32 PM
Post: #4
RE: HP-67 Base Conversion from HP Key Notes
This variant uses some stackrobatic so we need only 4 registers instead of 6:

Code:
001 *LBL A
002  STO 3   ; new base
003  RDN     ; old base
004  STO 1   ; from
005  ENTER
006  GSB 3   ; 10^m base
007  GSB 0   ; convert n from old base to 10^m base
008  RCL 3   ; new base
009  GSB 3   ; 10^k base
010  STO 1   ; from
011  RCL 3   ; new base
012 *LBL 0   ; convert ( n_from from to -- n_to )
013  STO 2   ; to
014  -       ; p = from - to
015  X<>Y    ; n_from
016  STO 0   ; n_to
017 *LBL 1   ; begin loop
018  RCL 1   ; from
019  x<>y
020  RCL 2   ; to
021  /
022  INT     ; n' = n >> 1
023  x=0
024  GTO 2   ; exit loop
025  RDN
026  *       ; p' = p * from
027  RDN
028  *       ; n' * p'
029  STO+ 0  ; n_to = n_to + n' * p'
030  RDN
031  GTO 1   ; end loop
032 *LBL 2   ; exit
033  RCL 0   ; n_to
034  RTN
035 *LBL 3   ; find power of 10 base
036  1
037  -
038  LOG
039  INT
040  1
041  +
042  10^x
043  RTN

And it's even a little shorter.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP-67 Base Conversion from HP Key Notes - Thomas Klemm - 10-19-2015 06:32 PM



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