Blackjack for the HP-41
Overview
1°) Standard Rules
2°) Modified Rules
a) Program#1
b) Program#2
Latest Update: paragraph 2b)
1°) Standard Rules
-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 )
Data Registers: ( Registers R00 & R01 are to be initialized before executing "BLJ" )
• R00 = random numbers
• R01 = your cash
R02 thru R09: temp
Flags: F22 F29
Subroutines: /
-Line 118 = one space
-Line 157 = two spaces
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 " " 119 ARCL 04 120 >"/" 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 " " 158 X>0? 159 >"+" 160 ARCL 01 161 >" $" 162 FIX 4 163 SF 29 164 AVIEW 165 END |
( 251 bytes / SIZE 010 )
STACK | INPUT | OUTPUT |
X | / | Cash |
Example: 7 STO 00
CLX STO 01
-Place you bet, for instance 12000$ , in X-register
12000 XEQ "BLJ" the HP-41 displays:
" 6/"
" 6/5"
" 62/5"
-Press ENTER^ to hit, you get: " 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 to continue with 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 lines 113 to 115
by ARCL 05 ARCL 11 ARCL Z ASTO 05 ASHF
ASTO 11
replace lines 103 to 105
by ARCL 04 ARCL 10 ARCL Z ASTO 04 ASHF
ASTO 10
add ASTO 10 ASTO
11 after line 09
-If flag F07 is clear, the rules are identical to those used in "BLJ"
-If flag F07 is set, there is no BUST.
-The winner is the one who is the closest to 21 ( for example, you
win with "K2Q" against "T8" ).
Data Registers:
• R00 = random numbers
( Registers R00 & R01 are to be initialized before executing
"BLJ" )
• R01 = your cash
R02 thru R09: temp
Flags: F29 F07 F08 F09
CF 07 = Standard rules
SF 07 = No Bust
Subroutines: /
01 LBL "BLJ" 02 CF 08 03 CF 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 SF 08 29 GTO 04 30 LBL 01 31 RCL 00 32 R-D 33 FRC |
34 STO 00 35 13 36 * 37 INT 38 1 39 + 40 CLA 41 ARCL X 42 13 43 X=Y? 44 "K" 45 DSE X 46 X=Y? 47 "Q" 48 DSE X 49 X=Y? 50 "J" 51 DSE X 52 X=Y? 53 "T" 54 X<Y? 55 X<>Y 56 SIGN 57 X=Y? 58 "A" 59 X<>Y 60 ASTO Z 61 CLA 62 RTN 63 LBL 02 64 41 65 GETKEY 66 X#Y? |
67 GTO 03 68 XEQ 05 69 CLX 70 X<Y? 71 GTO 02 72 LBL 03 73 11 74 X#Y? 75 DSE 06 76 X=Y? 77 XEQ 05 78 RCL 02 79 FS? 07 80 ST+ X 81 10 82 X>Y? 83 0 84 RCL 07 85 * 86 ST- 02 87 RCL 02 88 X<0? 89 FS? 07 90 FS? 30 91 21 92 STO 02 93 LBL 04 94 XEQ 06 95 RCL 08 96 * 97 X#Y? 98 GTO 09 99 CHS |
100 STO 03 101 1.5 102 FS? 07 103 STO 06 104 SF 09 105 GTO 10 106 LBL 05 107 XEQ 01 108 ST- 02 109 X=Y? 110 STO 07 111 ARCL 04 112 ARCL Z 113 ASTO 04 114 RCL 02 115 GTO 07 116 LBL 06 117 XEQ 01 118 ST- 03 119 X=Y? 120 STO 08 121 ARCL 05 122 ARCL Z 123 ASTO 05 124 RCL 03 125 LBL 07 126 " " 127 ARCL 04 128 >"/" 129 ARCL 05 130 AVIEW 131 10 132 RTN |
133 LBL 08 134 XEQ 06 135 LBL 09 136 3 137 RCL 03 138 STO 09 139 FS? 07 140 + 141 10 142 X>Y? 143 0 144 RCL 08 145 * 146 ST- 09 147 21 148 RCL 02 149 X#Y? 150 FS? 08 151 GTO 10 152 4 153 FS? 07 154 DSE X 155 RCL 09 156 X>Y? 157 GTO 08 158 X<0? 159 FS? 07 160 FS? 30 161 R^ 162 STO 03 163 LBL 10 164 RCL 03 165 FS? 07 |
166 ABS 167 FS? 09 168 LASTX 169 RCL 02 170 FS? 07 171 FS? 08 172 FS? 30 173 ABS 174 - 175 X#0? 176 SIGN 177 RCL 06 178 * 179 RCL 00 180 7 181 / 182 4 183 + 184 10^X 185 * 186 ST+ 01 187 RCL 01 188 " " 189 X>0? 190 >"+" 191 ARCL 01 192 >" $" 193 FIX 4 194 SF 29 195 AVIEW 196 END |
( 307 bytes / SIZE 010 )
STACK | INPUT | OUTPUT |
X | / | Cash |
Notes:
-Here, the bets are randomly choosen by the HP-41 ( lines 179 to 184 )
between 10000 $ and ~ 13900 $
-If you want to place your own bets, replace these lines by
RCL 10 and add FS?C 22 STO 10
after line 01.
-When F07 is set, the HP-41 deals cards for itself until its total exceeds
17 ( lines 153-154 ).
-And if the calculator has blackjack, you lose 1.5 time your
bet, unless you have blacjack too ( lines 101 to 103 ).
b) Program#2
-This version only employs the modified rules: no bust.
-"AA" may give 22 points.
-The HP41 deals cards for itself until its total exceeds the player's
total ( lines 139-140-141 )
Data Registers:
• R00 = random numbers
( Registers R00 & R01 are to be initialized before executing
"BLJ" )
• R01 = your cash
R02 thru R10: temp
Flags: F29 F09 F10
Subroutines: /
-Line 87 = TEXT0 , it may be replaced by any NOP instruction: STO X for example.
-Line 08 = STO d is also a synthetic function: it may be replaced by CF 09 CF 10 CF 29
01 LBL "BLJ" 02 21 03 STO 02 04 STO 03 05 CLX 06 STO 08 07 STO 09 08 STO d 09 SIGN 10 STO 10 11 CLA 12 ASTO 04 13 ASTO 05 14 FIX 0 15 XEQ 04 16 XEQ 05 17 XEQ 04 18 RCL 09 19 * 20 X#Y? 21 GTO 02 22 CHS 23 STO 07 24 SF 09 25 GTO 06 26 LBL 00 27 ABS 28 ISG Y 29 LBL 10 |
30 DSE Y 31 X<0? 32 RTN 33 LASTX 34 10 35 - 36 ABS 37 X<Y? 38 X<>Y 39 RDN 40 GTO 10 41 LBL 01 42 RCL 00 43 R-D 44 FRC 45 STO 00 46 13 47 * 48 INT 49 1 50 + 51 CLA 52 ARCL X 53 13 54 X=Y? 55 "K" 56 DSE X 57 X=Y? 58 "Q" |
59 DSE X 60 X=Y? 61 "J" 62 DSE X 63 X=Y? 64 "T" 65 X<Y? 66 X<>Y 67 SIGN 68 X=Y? 69 "A" 70 X<>Y 71 ASTO Z 72 CLA 73 RTN 74 LBL 02 75 41 76 GETKEY 77 X#Y? 78 GTO 03 79 XEQ 04 80 CLX 81 X<Y? 82 GTO 02 83 LBL 03 84 11 85 X=Y? 86 ISG 10 87 "" |
88 X=Y? 89 XEQ 04 90 RCL 09 91 RCL 03 92 XEQ 00 93 STO 07 94 LBL 06 95 XEQ 05 96 RCL 08 97 * 98 X#Y? 99 GTO 08 100 CHS 101 STO 06 102 SF 10 103 GTO 09 104 LBL 04 105 XEQ 01 106 ST- 03 107 X=Y? 108 ST+ 09 109 ARCL 05 110 ARCL Z 111 ASTO 05 112 RCL 03 113 GTO 06 114 LBL 05 115 XEQ 01 116 ST- 02 |
117 X=Y? 118 ST+ 08 119 ARCL 04 120 ARCL Z 121 ASTO 04 122 RCL 02 123 LBL 06 124 " " 125 ARCL 05 126 >"/" 127 ARCL 04 128 AVIEW 129 10 130 RTN 131 LBL 07 132 RCL 02 133 X<0? 134 GTO 09 135 XEQ 05 136 LBL 08 137 RCL 08 138 RCL 02 139 XEQ 00 140 STO 06 141 RCL 07 142 X<Y? 143 FS? 09 144 FS? 30 145 GTO 07 |
146 LBL 09 147 1.5 148 RCL 06 149 RCL 07 150 - 151 X#0? 152 SIGN 153 FC? 09 154 FS? 10 155 * 156 RCL 10 157 * 158 RCL 00 159 7 160 / 161 4 162 + 163 10^X 164 * 165 ST+ 01 166 RCL 01 167 " " 168 X>0? 169 >"+" 170 ARCL 01 171 >" $" 172 FIX 4 173 AVIEW 174 END |
( 272 bytes / SIZE 011 )
STACK | INPUT | OUTPUT |
X | / | Cash |
Notes:
-Here, the bets are randomly choosen by the HP-41 ( lines 157 to 162 )
between 10000 $ and ~ 13900 $
-If you want to place your own bets, replace these lines by
RCL 11 and add FS?C 22 STO 11 after
line 01.
-A deck of an infinite number of one-suit cards is also used.
( In other words, the probability of each card = 1/13 )
-Press ENTER^ to hit: you can receive as many cards as you want ( until your points reach or exceed 21 )
-Press any other key to stand.