Re: HP 33S Program question Message #2 Posted by Paul Brogger on 12 May 2004, 10:07 a.m., in response to message #1 by Mike
The obvious thing to do is make the repetitive die rolls into a single subroutine, and execute them via XEQ:
D0001 LBL D Label D for Dice
D0002 RANDOM Generate Random number for seed
D0003 SEED
D0004 XEQ R Roll one die
D0005 XEQ R Roll the other
D0006 RTN (Like STOP when executed from kbd)
R0001 LBL R Roll Die
R0002 RANDOM Generate random number for die
R0003 6
R0004 *
R0005 1
R0006 +
R0007 IP
R0008 RTN
This is a good technique in general, and has many applications.
Remember, however, that on the 33s an unusual set of tradeoffs may be at play. Its most limited resource is LBL values -- you've only got 26 of 'em. So in this particular case, saving a few bytes may not be worth the cost of a label. (That is, if you plan to fill your calculator with programs and will use as many labels as possible.)
|