Post Reply 
(42S) Roman to Arabic Representation
06-16-2014, 12:00 PM (This post was last modified: 06-15-2017 01:48 PM by Gene.)
Post: #1
(42S) Roman to Arabic Representation
Given a valid Roman number in the alpha register the prog returns the value in Arabic form in the X register.

0. { 78-Byte Prgm }
1. LBL “R→A”
2. CLST
3. ALENG
4. X<> ST Z
5. LBL 09
6. ATOX
7. XTOA
8. R↓
9. XEQ IND ST T
10. X<>Y
11. X<Y?
12. +/-
13. STO+ ST Z
14. R↓
15. DSE ST Z
16. GTO 09
17. GTO 00
18. LBL 77
19. 1000
20. RTN
21. LBL 68
22. 500
23. RTN
24. LBL 67
25. 100
26. RTN
27. LBL 76
28. 50
29. RTN
30. LBL 88
31. 10
32. RTN
33. LBL 86
34. 5
35. RTN
36. LBL 73
37. 1
38. RTN
39. LBL 00
40. +
41. END

Improvements welcome.
Find all posts by this user
Quote this message in a reply
06-16-2014, 12:19 PM
Post: #2
RE: HP 42S Roman to Arabic Representation
All I need now is a 42S in mint condition to check your work Wink

It ain't OVER 'till it's 2 PICK
Find all posts by this user
Quote this message in a reply
06-16-2014, 12:27 PM
Post: #3
RE: HP 42S Roman to Arabic Representation
(06-16-2014 12:19 PM)HP67 Wrote:  All I need now is a 42S in mint condition to check your work Wink

Why mint and why not this? Wink

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
06-16-2014, 12:37 PM
Post: #4
RE: HP 42S Roman to Arabic Representation
(06-16-2014 12:27 PM)Massimo Gnerucci Wrote:  
(06-16-2014 12:19 PM)HP67 Wrote:  All I need now is a 42S in mint condition to check your work Wink

Why mint and why not this? Wink

Because the build quality, great keyboard, and pride of ownership just aren't there for me Wink

It ain't OVER 'till it's 2 PICK
Find all posts by this user
Quote this message in a reply
06-16-2014, 12:53 PM
Post: #5
RE: HP 42S Roman to Arabic Representation
(06-16-2014 12:37 PM)HP67 Wrote:  
(06-16-2014 12:27 PM)Massimo Gnerucci Wrote:  Why mint and why not this? Wink

Because the build quality, great keyboard, and pride of ownership just aren't there for me Wink

Oh, almost forgot those sensations...
This evening I'll handle my mint one then. Or one of the others.

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
06-16-2014, 01:02 PM
Post: #6
RE: HP 42S Roman to Arabic Representation
(06-16-2014 12:53 PM)Massimo Gnerucci Wrote:  This evening I'll handle my mint one then. Or one of the others.

What a guy!! Smile Smile

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
06-16-2014, 01:06 PM
Post: #7
RE: HP 42S Roman to Arabic Representation
(06-16-2014 01:02 PM)rprosperi Wrote:  
(06-16-2014 12:53 PM)Massimo Gnerucci Wrote:  This evening I'll handle my mint one then. Or one of the others.

What a guy!! Smile Smile

Sorry if I sounded a little braggart.
Eheheheh... Big Grin

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
06-16-2014, 01:22 PM
Post: #8
RE: HP 42S Roman to Arabic Representation
To posts #2 to #7:

The sensual nature of the HP 42S is undeniable but not a propos the topic.

Perhaps start a new thread on sensuality grading of various models?
Find all posts by this user
Quote this message in a reply
05-13-2020, 08:57 PM
Post: #9
RE: (42S) Roman to Arabic Representation
Nicely done, it works very well !
Find all posts by this user
Quote this message in a reply
05-14-2020, 08:56 AM
Post: #10
RE: (42S) Roman to Arabic Representation
Making use of a 13x2 matrix "RN":
[[ 1000 77 ]
[ 900 "CM" ]
[ 500 68 ]
[ 400 "CD" ]
[ 100 67 ]
[ 90 "XC" ]
[ 50 76 ]
[ 40 "XL" ]
[ 10 88 ]
[ 9 "IX" ]
[ 5 86 ]
[ 4 "IV" ]
[ 1 73 ]]

Both encodings can be written as follows:

Code:
00 { 82-Byte Prgm }
01▸LBL "→ROM"
02 ENTER
03 EDITN "RN"
04▸LBL 02
05 X>Y?
06 GTO 00
07 STO- ST Y
08 →
09 XTOA
10 ←
11 GTO 02
12▸LBL 00
13 ↓
14 FC? 76
15 GTO 02
16 EXITALL
17 RTN
18▸LBL "→ARB"
19 INDEX "RN"
20 CLST
21 ALENG
22 X<> ST Z
23▸LBL 03
24 ATOX
25 XTOA
26 [FIND]
27 X=0?
28 ASTO ST Z
29 J-
30 CLX
31 RCLEL
32 X<>Y
33 X<Y?
34 +/-
35 STO+ ST Z
36 R↓
37 DSE ST Z
38 GTO 03
39 +
40 EXITALL
41 END

The →ROM routine appends the Roman numerals to the Alpha register; just add a CLA at the beginning and an AVIEW at the end if you want to see single results.
The →ARB routine (a copy of yours, Gerald, but using the RN matrix instead) has a rudimentary error check: when it encounters an unknown character it produces an "Alpha Data is Invalid" message.

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
05-16-2020, 10:19 AM
Post: #11
RE: (42S) Roman to Arabic Representation
Werner - How do you put alpha data in a matrix?
Find all posts by this user
Quote this message in a reply
05-16-2020, 02:18 PM
Post: #12
RE: (42S) Roman to Arabic Representation
with ASTO ST X while editing.
or run the following program to create the matrix:
Code:
00 { 164-Byte Prgm }
01▸LBL "MRN"
02 13
03 2
04 NEWMAT
05 EDIT
06 1000
07 →
08 77
09 →
10 900
11 →
12 "CM"
13 ASTO ST X
14 →
15 500
16 →
17 68
18 →
19 400
20 →
21 "CD"
22 ASTO ST X
23 →
24 100
25 →
26 67
27 →
28 90
29 →
30 "XC"
31 ASTO ST X
32 →
33 50
34 →
35 76
36 →
37 40
38 →
39 "XL"
40 ASTO ST X
41 →
42 10
43 →
44 88
45 →
46 9
47 →
48 "IX"
49 ASTO ST X
50 →
51 5
52 →
53 86
54 →
55 4
56 →
57 "IV"
58 ASTO ST X
59 →
60 1
61 →
62 73
63 EXITALL
64 STO "RN"
65 END

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
05-17-2020, 07:07 AM
Post: #13
RE: (42S) Roman to Arabic Representation
Thank you, Werner, for the advice on entering alpha data into a matrix, I couldn't find this explicitly in the manual, do you have a reference?

I had for some time (6 years?) thought there should be an equally economical algorithm for ->ROM as for ->ARB but never found/invented one, so your programme is much appreciated.

The matrix RN occupies 230 Bytes of memory, so total for programme & matrix is 312 Bytes.

The programme below is my previous best attempt & is a little faster than yours.

Code:
0.    { 245-Byte Prgm }
1.    LBL “R→A”
2.    CLST
3.    ALENG
4.    X<> ST Z
5.    LBL 09
6.    ATOX
7.    XTOA
8.    R↓
9.    XEQ IND ST T
10.    X<>Y
11.    X<Y?
12.    +/-
13.    STO+ ST Z
14.    R↓
15.    DSE ST Z
16.    GTO 09
17.    GTO 00
18.    LBL 77
19.    1000
20.    RTN
21.    LBL 68
22.    500
23.    RTN
24.    LBL 67
25.    100
26.    RTN
27.    LBL 76
28.    50
29.    RTN
30.    LBL 88
31.    10
32.    RTN
33.    LBL 86
34.    5
35.    RTN
36.    LBL 73
37.    1
38.    RTN
39.    LBL 00
40.    +
41.    RTN
42.    LBL “A→R”
43.    STO 00
44.    CLA
45.    LBL 01
46.    1E3
47.    X>Y?
48.    GTO 00
49.    –
50.    ├”M”
51.    GTO 01
52.    LBL 00
53.    CLX
54.    900
55.    X≤Y?
56.    ├”CM”
57.    X>Y?
58.    CLX
59.    –
60.    500
61.    X≤Y?
62.    ├”D”
63.    X>Y?
64.    CLX
65.    –
66.    400
67.    X≤Y?
68.    ├”CD”
69.    X>Y?
70.    CLX
71.    –
72.    LBL 02
73.    1E2
74.    X>Y?
75.    GTO 00
76.    –
77.    ├”C”
78.    GTO 02
79.    LBL 00
80.    CLX
81.    90
82.    X≤Y?
83.    ├”XC”
84.    X>Y?
85.    CLX
86.    –
87.    50
88.    X≤Y?
89.    ├”L”
90.    X>Y?
91.    CLX
92.    –
93.    40
94.    X≤Y?
95.    ├”XL”
96.    X>Y?
97.    CLX
98.    –
99.    LBL 03
100.    10
101.    X>Y?
102.    GTO 00
103.    –
104.    ├”X”
105.    GTO 03
106.    LBL 00
107.    DSE ST X
108.    X≤Y?
109.    ├”IX”
110.    X>Y?
111.    CLX
112.    –
113.    5
114.    X≤Y?
115.    ├”V”
116.    X>Y?
117.    CLX
118.    –
119.    4
120.    X≤Y?
121.    ├”IV”
122.    X>Y?
123.    CLX
124.    –
125.    LBL 04
126.    1
127.    X>Y?
128.    GTO 00
129.    –
130.    ├”I”
131.    GTO 04
132.    LBL 00
133.    AVIEW
134.    RCL 00
135.    END
Find all posts by this user
Quote this message in a reply
05-17-2020, 08:11 AM
Post: #14
RE: (42S) Roman to Arabic Representation
Hi Gerald,
no I don't have a reference, I just tried it once and it worked ;-)
And the >ROM algorithm is not mine.. I just made it matrix-based.
Roman Numerals for the 41
And that looks eerily like yours -)

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
05-17-2020, 08:58 AM (This post was last modified: 05-17-2020 02:01 PM by Gerald H.)
Post: #15
RE: (42S) Roman to Arabic Representation
2020-05-2020 15:54 Vienna time Edit:

the original posting

Yes, I'm fairly sure I copied Jean-Marc Baillard's programme in the first place, all credit to him.

is incorrect.

In fact it's a copy of Didier Lachieze' programme as referenced here:

https://www.hpmuseum.org/forum/thread-55...ght=arabic
Find all posts by this user
Quote this message in a reply
05-17-2020, 09:12 AM
Post: #16
RE: (42S) Roman to Arabic Representation
The handbook "HP-42S RPN Scientific Programming Examples and Techniques" exemplifies storing alpha data in a matrix on page 147.
Find all posts by this user
Quote this message in a reply
Post Reply 




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