MAS

Display

(HP-41CX, Hewlett Packard 1983 and DM41X, SwissMicros 2020)
 

Overview
Programs MASD and MASA are mastermind code-breaking games. The user must find a code which consists of either 4 or 5 digits, representing colours from the original game invented in 1970 by Mordecai Meirowitz, an Israeli postmaster and telecommunications expert. In these programs the user is first prompted to find a 4-digit or a 5-digit code. In the first case, digits are randomly selected from a range 1-6 and in the second case from 1-8. Duplicate digits are not allowed.
When the user makes the first guess, e.g. 5216, the calculator will determine the match and display the following information:
         5216 3.2 1

in which
         5216 = the code entered by the user
         3.2 = 3 digits are OK, 2 of these are on the right position
         1 = the number of guesses the user has made

Program MASD uses decimal calculation to determine the match of an user-given guess of the secret code. This version is a bit faster than the alpha-digit based version MASA.
Program MASA checks digits in the alpha register to determine the match.
Both programs have a similar way of creating and storing a secret code. The method makes use of the registers R01-R06 or R01-R08 for a 4-digits respectively 5-digits code. If a digit is randomly chosen, its position in the secret code is stored in the register. If the digit is not present in the secret code, the corresponding register value remains 0. The example code 5216 is stored in the registers as follows:
R01: 3, R02: 2, R03: 0, R04: 0, R05: 1, R06: 4

After entering 4 or 5 for the type of game to run, the startup of the programs shows the initial display consisting of zeroes:
         0000 0.0 0

which is to have consistency and ease of use. The user can now enter the first guess.
 

Example 1, MASD

 

Example 2, MASA

 

Program Listing
The listing of the programs is given below with 2 XROM functions SEED and RNDM on lines 3 and 13 resp. 3 and 15. These can be taken as explicit calls to other programs in memory or to XROM functions, for example the CCD module. If replaced by these XROM functions (as in the RAW and TXT file) the total number of byte savings is 8. So, program MASD would be 148 instead of 156 bytes and program MASA would be 152 instead of 160 bytes. If not available, programs must be in place for these functions.

The listing of program MASD (“decimal” based) is given below:

 
and for MASA (“alpha” based) shown here:

 

Registers, Labels and Flags

 

Downloads
PDF format of program MAS.
RAW/TXT format of program MAS (in zip file).
 

This program is copyright and is supplied without representation or warranty of any kind. The author assumes no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof

© 1999-2023 by Auke Hoekstra

 
Don`t copy text!