HP-67 Chess Playing Program

Back to main page | Email me at: Gene!


This program first appeared in the V7N6P18 (July/Aug 1980) issue of PPC Journal by Valentin Albillo. Thanks to Valentin wherever he is today!

This program allows you to play chess against the HP-67. The HP-67 controls the 16 white pieces and you control only the black king. The HP will try to checkmate you in 6 moves or less. Your goal is to survive longer than 6 moves. If you do, you are considered the winner. If you don't.....

The Board: The initial position is the standard chess layout with the white pieces where they would normally be and the black king where he would normally start a game. The numbering convention for the squares is illustrated below:

  _ _ _ _ _ _ _ _
8|_|_|_|_|_|_|_|_|
7|_|_|_|_|_|_|_|_|
6|_|_|_|_|_|_|_|_|
5|_|_|_|_|_|_|_|_|
4|_|_|_|_|_|_|_|_|
3|_|_|_|_|_|_|_|_|
2|_|_|_|_|_|_|_|_|
1|_|_|_|_|_|_|_|_|
  1 2 3 4 5 6 7 8
In this scheme, the black king would start at 58, using the coordinates as XY (horizontal, vertical).

How white moves: When white moves, it identifies its piece being moved using this code:

Piece  Code 
King    6
Queen   5
Rook    4
Bishop  3
Knight  2
Pawn    1
The calculator's output for a white move is of the form: XYZ.N, where X is the code of the piece white has just moved, Y is the code of the piece in whose column the moved piece now resides (which can be two digits, identifying whether it is on the king's side or queen's side), and Z indicates the row of the column they moved piece resides (counting up from the bottom), and N indicates the number of moves white has made.

Examples of white moves: If that's confusing (and it is complicated), here's an example: 5627.4 would be decoded to mean 5 = Queen moved, 62 = 6 for King, 2 for Knight, and 7 would mean to the seventh row of the column. The .4 means it is the fourth move made. (Q- KN7 in chess parlance)

Another example: 2533.1 would mean 2 = Knight, 53 would indicated moved to the Queen Bishop column, 3 would mean the third row, and 1 would mean the first move. (N-QB3 in chess talk)

Output: There are three kinds of output: Normal: XZY.N, Check: -XYZ.N (note, it is displayed as a negative value), and Checkmate: -XYZ.00000N (note that this is negative as well).

How black moves: Black inputs his move by entering the XY coordinate being moved to using the board drawn above. If, somehow, the black king CAPTURES a white piece on his move, the XY coordinate MUST be entered as a negative value.

HP-67 Data Card needed: Load the following values into the data registers on the HP-67. They are only needed the first time you load the program. Successive games may be played without needing to reload the game.

Memory  Value
 0       164
 1       524
 2       527
 3       154
 4       557
 5       525
 6      3634
 7       537
 8       155
 9       336
S0      3525
S1      5527
S2       565
S3       325
S4         0
S5       346
S6      3534
S7       567
S8      5627
S9       353
 A      1523
 B       322
 C       334
 D        10
 E       0.8
 I         0

Running the program:
1) Start the game by pressing A. Display shows white's first move.
2) Input your move by entering the XY coordinate and press R/S.
3) Continue until you either are checkmated or reach the 6th move being shown without being checkmated and win the game. The program will not indicate that you have won.

Sample Game: This is a very poorly played game. Perhaps you can do better?
Press A to start.
White's move is 164.1 (P-K4)
68 R/S
524.2 (Q-KN4)
67 R/S
557.3 (Q-Q7)
68 R/S
1523.4 (P-QN3)
78 R/S
-334.5 (B-B4 Check!)
68 R/S
-322.0000006 (B-KN2 Checkmate!)

Program Listing: Most instructions should be self-evident. If you have any questions, email me.

Line      Instruction
01         LBL A
02         DSP 1
03         0
04         ST I
05         RCL 0
06         GSB 2
07         RCL 1
08         GSB 7
09         INT
10         6
11         X = Y?
12         GTO C
13         RCL 2
14         GSB 7
15         FRAC
16         RCL E
17         X = Y?
18         GTO D
19         RCL 3
20         GSB 2
21         2
22         6
23         X NE Y?
24         GTO 0
25         RCL 4
26         LBL 8
27         GSB 2
28         RCL 5
29         LBL 9
30         CHS
31         DSP 9
32         ISZ
33         RC I
34         EEX
35         7
36         /
37         -
38         RTN
39         LBL 0
40         GSB 6
41         X NE Y?
42         GTO 0
43         RCL 6
44         GSB 2
45         GTO 5
46         LBL 0
47         GSB 6
48         X NE Y?
49         GTO 0
50         RCL 6
51         CHS
52         GSB 2
53         5
54         6
55         X NE Y?
56         GTO 5
57         RCL 8
58         GTO 9
59         LBL 0
60         GSB 6
61         X NE Y?
62         GTO 0
63         P <> S
64         RCL 0
65         P <> S
66         GSB 2
67         LBL 4
68         RCL 4
69         GTO 9
70         LBL 0
71         RDN
72         1
73         5
74         X NE Y?
75         GTO 0
76         P <> S
77         RCL 1
78         P <> S
79         GTO 8
80         LBL 0
81         P <> S
82         RCL 2
83         P <> S
84         GTO 8
85         LBL D
86         P <> S
87         RCL 3
88         P <> S
89         GSB 2
90         1
91         8
92         X NE Y?
93         GTO 0
94         RCL 9
95         CHS
96         GTO 3
97         LBL 0
98         GSB 6
99         X NE Y?
100        GTO 0
101        P <> S
102        RCL 5
103        P <> S
104        GTO 3
105        LBL 0
106        GSB 6
107        X NE Y?
108        GTO 4
109        RCL 9
110        GSB 2
111        2
112        8
113        X NE Y?
114        GTO 4
115        RCL 2
116        GTO 9
117        LBL C
118        RCL 4
119        GSB 7
120        FRAC
121        RCL E
122        X = Y?
123        GTO B
124        RCL 3
125        GSB 2
126        6
127        6
128        X NE Y?
129        GTO 0
130        P <> S
131        RCL 6
132        P <> S
133        GSB 2
134        LBL 5
135        RCL 7
136        GTO 9
137        LBL 0
138        GSB 6
139        X NE Y?
140        GTO 0
141        P <> S
142        RCL 7
143        P <> S
144        GTO 8
145        LBL 0
146        RDN
147        X > 0?
148        GTO 0
149        P <> S
150        RCL 9
151        P <> S
152        GTO 9
153        LBL 0
154        P <> S
155        RCL 8
156        P <> S
157        GTO 8
158        LBL B
159        RCL A
160        GSB 2
161        6
162        8
163        X NE Y?
164        GTO 0
165        RCL B
166        GTO 3
167        LBL 0
168        GSB 6
169        X NE Y?
170        GTO 0
171        RCL C
172        CHS
173        GSB 2
174        6
175        8
176        X = Y?
177        GTO 5
178        RCL B
179        GTO 9
180        LBL 0
181        RCL B
182        CHS
183        LBL 3
184        GSB 2
185        RCL 2
186        GTO 9
187        LBL 6
188        RCL D
189        +
190        RTN
191        LBL 7
192        GSB 2
193        RCL D
194        /
195        RTN
196        LBL 2
197        X < 0?
198        SF 2
199        ABS
200        ISZ
201        RC I
202        RCL D
203        /
204        +
205        F? 2
206        CHS
207        R/S
208        RTN
That's it. Enjoy!