Hi!
As owner of a new DM15 I proudly present my first program, which converts one number from one base to another. This could give the DM15 a little bit of the HP-16C features. Unfortunately the calculator doesn't support figures >9 (ie. letters A ... F). So involving number bases >10 (ie HEX) doesn't work properly.
Example:
To convert 1101 from base 2 to base 8 simple enter 1101, 2 and 8 to the stack and start the program. The outputs on the stack are the original number (Z: 1101), the number converted to decimal (Y: 13) and the number converted to octal (X: 15).
The program source code - as output of Thorsten Manz' great HP15C-Simulator - is:
Code:
# ------------------------------------------------------------------------------
# HEWLETT·PACKARD 15C Simulator program
# Created with version 4.3.00
# ------------------------------------------------------------------------------
#T:Base Conversion
#D:Converts a number from one base to another.
#D:
#D:INPUT:
#D: Z: Number
#D: Y: FromBase
#D: X: ToBase
#D:
#D:OUTPUT:
#D: Z: Number
#D: Y: NumberInDecimal
#D: X: NumberConverted
#D:
#D:Example: [1101 2 8] -> [1101 13 15]
#D:
#D:Uses STO 1...9 and LBL 6...9
#D:
#L6:Convert
#L9:Modulo
#R1:Number
#R2:ToBase
# ------------------------------------------------------------------------------
000 { }
001 { 42 21 12 } f LBL B
002 { 44 2 } STO 2
003 { 33 } R⬇
004 { 33 } R⬇
005 { 44 1 } STO 1
006 { 43 33 } g R⬆
007 { 1 } 1
008 { 0 } 0
009 { 32 6 } GSB 6
010 { 33 } R⬇
011 { 45 2 } RCL 2
012 { 36 } ENTER
013 { 32 6 } GSB 6
014 { 45 1 } RCL 1
015 { 36 } ENTER
016 { 33 } R⬇
017 { 33 } R⬇
018 { 43 32 } g RTN
019 { 42 21 6 } f LBL 6
020 { 44 5 } STO 5
021 { 33 } R⬇
022 { 44 4 } STO 4
023 { 33 } R⬇
024 { 44 3 } STO 3
025 { 0 } 0
026 { 44 9 } STO 9
027 { 44 8 } STO 8
028 { 44 7 } STO 7
029 { 1 } 1
030 { 44 6 } STO 6
031 { 45 3 } RCL 3
032 { 45 5 } RCL 5
033 { 42 21 8 } f LBL 8
034 { 32 9 } GSB 9
035 { 44 40 8 } STO + 8
036 { 1 } 1
037 { 0 } 0
038 { 44 10 8 } STO ÷ 8
039 { 33 } R⬇
040 { 1 } 1
041 { 44 40 7 } STO + 7
042 { 33 } R⬇
043 { 45 6 } RCL 6
044 { 20 } ×
045 { 44 40 9 } STO + 9
046 { 45 4 } RCL 4
047 { 44 20 6 } STO × 6
048 { 33 } R⬇
049 { 33 } R⬇
050 { 45 5 } RCL 5
051 { 34 } x↔y
052 { 43 20 } g x=0
053 { 22 7 } GTO 7
054 { 34 } x↔y
055 { 22 8 } GTO 8
056 { 42 21 7 } f LBL 7
057 { 34 } x↔y
058 { 1 } 1
059 { 0 } 0
060 { 45 7 } RCL 7
061 { 14 } yˣ
062 { 44 20 8 } STO × 8
063 { 45 3 } RCL 3
064 { 45 9 } RCL 9
065 { 45 8 } RCL 8
066 { 43 32 } g RTN
067 { 42 21 9 } f LBL 9
068 { 36 } ENTER
069 { 36 } ENTER
070 { 43 33 } g R⬆
071 { 36 } ENTER
072 { 33 } R⬇
073 { 34 } x↔y
074 { 10 } ÷
075 { 43 44 } g INT
076 { 36 } ENTER
077 { 33 } R⬇
078 { 20 } ×
079 { 30 } −
080 { 43 32 } g RTN
# ------------------------------------------------------------------------------
Probably the code can be optimized - but so far I'm happy that it works.
Regards
deetee