Saturday, July 18, 2020

HP 41C and HP 42S (also Free42/DM42): Random Tone Generator

HP 41C and HP 42S (also Free42/DM42): Random Tone Generator

Tones

The program RTONE generates a set of random tones (0 through 9).   Since the HP 41C (without additional modules) does not have a pseudo random number generator, a simple generator is included, particularly (π + x0)^5 = x1.

The HP 42S has a random number generator and it is used in its program.  Performance of RTONE is increased, and is really fast on the Free42 and Swiss Micros DM42. 

The command TONE can refer to indirect registers (stack X for this program) and accepts real numbers between 0 to 9.9999999.  TONE ignores the fractional part.

HP 41C Program: RTONE

01 LBL^T RTONE
02 ^T N?
03 PROMPT
04 INT
05 STO 03
06 ^T SEED?
07 PROMPT
08 LBL 00
09 PI
10 +
11 5
12 Y↑X
13 10
14 MOD
15 TONE IND X
16 DSE 03
17 GTO 00
*END*

HP 42S/Free42/DM42 Program:  RTONE

00 {37-Byte Prgm}
01 LBL "RTONE"
02 "SEED?"
03 PROMPT
04 SEED
05 "N?"
06 PROMPT
07 IP
08 STO 03
09 LBL 00
10 RAN
11 10
12 *
13 TONE IND ST X
14 DSE 03
15 GTO 00
16 END

A fun, little musical program.

Eddie

All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

  Casio fx-7000G vs Casio fx-CG 50: A Comparison of Generating Statistical Graphs Today’s blog entry is a comparison of how a hist...