HHC 2021 Programming Contests - Surprise !
|
10-03-2021, 11:35 PM
(This post was last modified: 10-05-2021 07:51 PM by Didier Lachieze.)
Post: #4
|
|||
|
|||
RE: HHC 2021 Programming Contests - Surprise !
[Edited according to the comments from Gene, here]
My RPN solution in 35 bytes (31 bytes if the 41 is configured with FIX 0 and CF 29, and you remove these two instructions before LBL 01): Code: 00 { 35-Byte Prgm } There are two synthetic instructions at step 12 and 13 that I've entered with the Zenrom module as this is one of the simplest way to enter synthetic instructions. This program is pretty slow as for each loop there is a search for a non existent label but it works for input numbers less than 10^7 as specified for the contest. It is based on the REV program in the Q-loader section of Wickes' Synthetic Programming book, page 57, where I've saved a few bytes by using PASN instead of GTO IND M. Code: 01 LBL "REV" The program REV uses the fact that the Q register is used as a scratch register by the 41 OS to store - in reverse order - strings that are usually entered by the user, for example as functions names. The program REV uses 'GTO IND M' to avoid having the user entering the string, but this GTO IND requires the label name to be first ASTO'ed in a register (here M is used, the first register of Alpha), so only strings of 6 characters can be used as the first byte in the register is used to indicate that the register contains a string and not a number. To be able to reverse 7 digits numbers I initially used ATOX and XTOA: Code: 01 LBL "REV" Then I looked at the different functions of the 41CX that use a user-entered string, and found that with PASN which uses a string in Alpha the Q register was directly loaded with 7 digits from the Alpha register in reverse order, so no more need for ASTO, nor ATOX and XTOA. Reference: Sections 4B. THE ALPHA REGISTER, p31, 4C. REGISTER Q, p33 and 5I. The Q-LOADER, p55 in Synthetic Programming on the HP-41C by W.C. Wickes. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 9 Guest(s)