The Museum of HP Calculators


Blackjack for the HP-41

This program is Copyright © 2007 by Jean-Marc Baillard and is used here by permission.

This program is supplied without representation or warranty of any kind. Jean-Marc Baillard and The Museum of HP Calculators therefore assume 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.

Overview

-This program allows you to play Blackjack against your HP-41
-The calculator is always the bank.

-Place your bet in X-register and XEQ "BLJ"
-The HP-41 deals 2 cards for you and 1 for itself.
-If you have 21 points with these 2 cards, you win 1.5 times your bet ( unless the HP-41 has also 21 points in 2 cards ), otherwise:

   -Press the SIGMA+ key to double your bet ( line 74 ): in this case, you receive one card only.
   -Press ENTER^  to hit ( line 65 ): you can receive as many cards as you want ( provided your points do not exceed 21 - otherwise, you lose )
   -Press any other key to stand.

-If you have no Blackjack and if your total does not exceed 21,
  the HP-41 deals cards for itself until its total exceeds 16

-Then, the 2 hands are compared and your new cash is displayed.

-Place another bet and R/S to continue the game
 or simply press R/S without any digit entry to place the same bet.

-Ace = 1 or 11 points
-2 = 2 , 3 = 3 , ....... , 9 = 9 points
-T = J = Q = K = 10 points

-So the possible Blackjacks are  AT  AJ  AQ  AK

Notes:

-"Split" and "Insurance" are not covered by this program.
-A deck of an infinite number of one-suit cards is used.
  ( In other words, the probability of each card = 1/13 )
-The GETKEY function of the X-functions module is used.
 

Program Listing
 

Data Registers:           •  R00 = random numbers               ( Registers R00 & R01 are to be initialized before executing "BLJ" )
                                      •  R01 = your cash

                                          R02 thru R09: temp
Flags:  F22  F29
Subroutines: /
 

  01  LBL "BLJ"
  02  FS?C 22
  03  STO 09
  04  21
  05  STO 02
  06  STO 03
  07  CLA
  08  ASTO 04
  09  ASTO 05
  10  2
  11  STO 06
  12  CLX
  13  STO 07
  14  STO 08
  15  FIX 0
  16  CF 29
  17  XEQ 05
  18  XEQ 06
  19  XEQ 05
  20  RCL 07
  21  *
  22  X#Y?
  23  GTO 02
  24  CHS
  25  STO 02
  26  1.5
  27  STO 06
  28  GTO 04
  29  LBL 01
  30  RCL 00
  31  R-D
  32  FRC
  33  STO 00
  34  9
  35  +
  36  10^X
  37  13
  38  MOD
  39  X=0?
  40  LASTX
  41  CLA
  42  ARCL X
  43  LASTX
  44  X=Y?
  45  "K"
  46  DSE X
  47  X=Y?
  48  "Q"
  49  DSE X
  50  X=Y?
  51  "J"
  52  DSE X
  53  X=Y?
  54  "T"
  55  X<Y?
  56  X<>Y
  57  SIGN
  58  X=Y?
  59  "A"
  60  X<>Y
  61  ASTO Z
  62  CLA
  63  RTN
  64  LBL 02
  65  41
  66  GETKEY
  67  X#Y?
  68  GTO 03
  69  XEQ 05
  70  CLX
  71  X<Y?
  72  GTO 02
  73  LBL 03
  74  11
  75  X#Y?
  76  DSE 06
  77  X=Y?
  78  XEQ 05
  79  RCL 02
  80  10
  81  RCL 07
  82  *
  83  X>Y?
  84  CLX
  85  -
  86  X<0?
  87  21
  88  STO 02
  89  LBL 04
  90  XEQ 06
  91  RCL 08
  92  *
  93  X#Y?
  94  GTO 09
  95  CHS
  96  STO 03
  97  GTO 10
  98  LBL 05
  99  XEQ 01
100  ST- 02
101  X=Y?
102  STO 07
103  ARCL 04
104  ARCL Z
105  ASTO 04
106  RCL 02
107  GTO 07
108  LBL 06
109  XEQ 01
110  ST- 03
111  X=Y?
112  STO 08
113  ARCL 05
114  ARCL Z
115  ASTO 05
116  RCL 03
117  LBL 07
118  " "                                   one space
119  ARCL 04
120  "~/"                                 append  /
121  ARCL 05
122  AVIEW
123  10
124  RTN
125  LBL 08
126  XEQ 06
127  LBL 09
128  RCL 08
129  *
130  X>Y?
131  CLX
132  -
133  21
134  RCL 02
135  X#Y?
136  X<0?
137  GTO 10
138  4
139  R^
140  X>Y?
141  GTO 08
142  X<0?
143  R^
144  STO 03
145  LBL 10
146  RCL 03
147  RCL 02
148  -
149  X#0?
150  SIGN
151  RCL 06
152  *
153  RCL 09
154  *
155  ST+ 01
156  RCL 01
157  "  "                                   2 spaces
158  X>0?
159  "~+"                                 append +
160  ARCL 01
161  "~ $"                                append space $
162  FIX 4
163  SF 29
164  AVIEW
165  END

( 251 bytes / SIZE 010 )
 

Example:      7  STO 00     CLX  STO 01

-Place you bet, for instance  12000$ , in X-register

    12000    XEQ "BLJ"                       " 6/"
                                                           " 6/5"
                                                           " 62/5"
-Press  ENTER^ to hit                        " 62A/5"
-You have 19 points,
  so you stand: press any key
  except ENTER^  and  SIGMA+       " 62A/5K"              the HP-41 continues until its points exceed 16
                                                           " 62A/5KK"          Busted! HP-41 exceeds 21: you win
                                                           "  +12000 $"
-----------------------------------------------------------------------------------------------------
-Simply press R/S for the same bet      " 5/"
                                                           " 5/3"
                                                           " 56/3"
-Press the SIGMA+ key
  to double your bet                             " 56A/3"
                                                           " 56A/3J"
                                                           " 56A/3JA"
                                                           " 56A/3JA9"           Busted again: you win 24000 $ and your cash is:
                                                           "  +36000 $"
 

Remarks:

-Do not store PI in register R00, the "random" numbers wouldn't be randomized at all...

-The display is very minimalist!
-You could for example:

       add    " TIE-PUSH"  X=Y?   AVIEW   after line  147
       add    " BLACKJACK"  AVIEW  after line 96  and after line 27

-One register only is used to store each hand so the HP-41 will not display all the cards if you ( or the HP-41 ) have more than 6 cards.
-To overcome this limitation:
       add  ARCL 11 after line 121
       add  ARCL 10 after line 119
       replace line 113 to 115 by  ARCL 05  ARCL 11  ARCL Z  ASTO 05  ASHF  ASTO 11
       -----------  103 to 105 by  ARCL 04  ARCL 10  ARCL Z  ASTO 04  ASHF  ASTO 10
       add  ASTO 10  ASTO 11  after line 09
 
 
 
 

Go back to the HP-41 software library
Go back to the general software library
Go back to the main exhibit hall