Home
The First Book of KIM
Contents
1. Multimaze is 5 amp 0200 DO 20 40 1F DO F9 A2 07 26 DO 90 17 BC 08 05 0210 BD 10 05 59 DE 02 99 DE 02 C8 C8 BD 18 03 59 DE 0220 02 99 DE 02 CA 10 2 A2 02 08 30 D4 BD DB 02 95 0230 D2 10 F8 0 B1 D2 99 08 00 88 10 F8 A2 0 0240 D4 Ag FF 38 36 09 36 D8 2A 88 DO F7 29 07 8 0250 B9 C6 02 95 D8 CA CA 10 E7 C6 D5 10 0A A9 05 85 0260 05 A5 DE 49 40 85 DE 7F 8D 41 17 0 09 A2 OA 0270 BS 08 8D 40 17 8C 42 17 06 DO FC C8 C8 CA 7 2 0280010 20 40 1F 20 C5 D7 FO CD 85 07 2 04 0290 00 02 05 10 F8 30 CA 30 8D BC D3 02 02 0 89 08 00 b 07 02 00 B1 CA 10 04 C6 D4 00 85 DO 8 did 0280 04 04 DO F8 CA 06 C6 02 C6 02 DO EF 02 02 0 02 E9 FO F2 00 08 80 48 01 09 41 49 43 09 0200 01 06 04 06 06 0 08 01 08 40 840 DA 02 08 FF FF 02 0 04 00 F5 7F 15 00 41 FE SF 04 51 7D 50 04 51 B6 E 0220 54 14 F7 05 04 54 7F 5E 01 00 FD FF 00 00 00 00 4 0300 00 00 00 00 00 00 00 00 05 OB 10 10 14 18 17 10 P AE 0510 01 04 80 10 80 02 40 40 02 02 40 01 10 05 80 10 90 t MUSIC BOX DESCRIPTION THIS PROGRAM PLAYS ONE OR SEVERAL TUNES VIA THE AUDIO OUT INTERFACE OF KIM 1 USE THE SAME CONNECTION AS THAT FOR RECORDING ON CASSETTE TAPE IF YOUR TAPE RECORDER HAS MONITOR FEATURE YOU CAN LISTEN TO THE TUNE AS WELL AS RECORD
2. c 0316 A9 00 SURVEY 0 0318 85 STA FLASHR un flash 031A A2 06 LDX 6 for all piles 8 0310 05 03 REVUE VALUE 1 X 031 BO 06 BCS SMALL 0320 B5 03 LDA VALUE 1 X 0322 85 03 STA TEMP 0324 86 01 STX PILE 0326 CA SMALL DEX 0327 DO F3 BNE REVUE 0329 C6 03 DEC TEMP 032B test 0320 60 RTS 0320 95 03 SEG STA VALUE 1 X store value 032F FO 0 BEQ NIL blank digit 0331 A8 TAY 0332 B9 E7 1F LDA TABLE Y 0335 95 OA NIL STA FLASHR X segments to wndw 0337 9 00 LDA 0 4 0339 60 RTS 033A FF 06 BE 00 B8 BF ED F9 DATA 2 0342 4940424 HEX DUMP KIM 0200 20 40 1F 20 6A 1F C9 13 DO 3A AD 04 17 A2 02 A8 0210 29 07 FO 03 18 69 02 95 04 98 4A 4A 4A CA 10 EF 0220 20 40 1F DO FB AD 04 17 A2 02 A8 29 07 95 07 98 0230 4A 4A CA 10 F4 85 01 85 02 A2 06 B5 03 20 2D 0240 05 CA DO F8 02 DO 3D C9 10 BO 39 C9 00 FO 35 0250 C9 90 12 38 E9 09 01 DO 2A AA B5 25 0260 86 01 85 0A BO 1 01 F0 1B 85 03 B5 03 C5 05 0270 90 13 E5 03 20 2D 03 E6 02 20 16 03 DO 07 20 05 0280 03 85 08 46 00 01 A5 55 95 OA 9 7F 8D 0290 41 17 AO 13 A2 05 B5 8D HO 17 8C 42 17 E6 11 02A0 DO FC 88 88 CA 10 EF E6 12 00 E7 A9 F8 85 12 0280 02 FO HE DO 2B AQ 00 A2 05 55 08 CA 10 FB 85 02 0 0A A2 06 B5 03 45 05 03 90 05 CA DO F5 FO 08 0200 A4 00 CC 04 17 BO 0 85 03 86 01 0
3. ROSA Adela cu d N salah baa detta foc fiai C siad d 0222 B1 LDA WORK 4 Y get parameter 0224 INC WORK 4 0226 95 EO STA WORK X store in work table 0228 BO EO BCS GO unconditional branch Set up for timing note 022A A EO NOTE LDX WORK timing 0220 86 E7 STX LIMIT 1 022 1 LDX WORK 1 long note factor 0230 A8 TAY test accumulator 0231 30 02 BMI OVER long note 0233 A2 01 LDX 1 nope set short note 0235 86 E6 OVER STX LIMIT Store length factor 0237 29 7F AND 7F remove short long flag 0239 85 E9 STA VAL2 023B FO 02 BEQ HUSH is it a pause 023D 85 EA STA VAL1 no Set pitch 023F A5 E9 HUSH LDA VAL2 get timing and 0241 25 E3 AND WORK 3 bypass if muted 0243 FO 0 BEQ ON 0245 EA INC VAL1 else fade the 0247 C6 E9 DEC VAL2 note 0249 E9 ON LDX VAL2 024829 LDA A7 bit 7 6n 0240 20 5D 02 JSR SOUND delay half cycle 0250 30 B8 BMI GO 0252 EA LDX VAL1 0254 A9 27 LDA 27 bit 7 off 0256 20 5D 02 JSR SOUND delay the other half 0259 30 AF BMI GO end of note 025B 10 E2 wBPL HUSH no more cycles subroutine to send a bit 0250 A E2 SOUND LDY WORK 2 octave flag 025F 84 EB STY TIMER 0261 86 EC STX XSAV bit timing 0263 EO 00 SLOOP CPX 0 end of timing 0265 DO 08 BNE CONT no continue 0267 LDX XSAV restore timing 0269 C6 EB DEC TIMER in case of 026B DO F6 BNE SLOOP anot
4. sure your interrupt vector at 17FE and 17FF is set to KIM address 1000 so that you get a valid halt RELOCATE Jim Butterfield 3 following addresses must be initialized 3 by user prior to run OOE7 PAGLIM 1 limit above which kill relocn 00 8 ADJST 2 adjustment distance signed OOEA POINT 2 Start of program OOEC BOUND 2 lower boundary for adjustment Main program starts here 0110 D8 START CLD 0111 AO OO LDY 0 2 0113 Bl EA LDA POINT Y get op code k 0115 A8 TAY cache in Y 0116 A2 07 LDX 7 0118 98 LOOP restore op code 0119 3D 8 01 1 1 remove unwanted bits 011 5D 95 Ol EOR 2 1 amp test the rest f OllF FO 05 BEQ FOUND 131 in T 0121 0122 DO Fh 0124 BC 9D 01 0127 30 OD 0129 FO 22 12 E EA O12D DO 02 012 E6 0121 88 0132 DO 0134 FO DA 0136 C8 0157 50 D9 0139 C8 013A Bl O13C AA 013D C8 O13E Bl EA 0140 20 79 0143 91 EA 0145 88 0146 8A 0147 91 EA 0189 03 0188 10 DE 0140 08 0138 A6 0150 5 0152 20 0155 86 0157 2 0159 1 0158 18 015C 69 02 015 30 01 0160 0161 86 5 0163 18 0164 65 EA 0166 AA 0167 A5 E3 0169 65 EB 016 20 79 O16E CA 016 CA 0170 8A 0171 38 0172 E5 0174 91 0176 C8 0177 10 B2 58 01 01 01 FOUND SKIP INEX TRIP BRAN OVER DEX on to the next test BNE LOOP 1 any TAB3 X length or flag BMI
5. 06 LOWF 00DF 00DF 8500 00DE 00DE A 00DF 00DF A 00DE 506 _ 104 0 NOT VALID 1 9 STORE IT CONVERT TO SEGMENTS DISPLAY LEFT DIGIT GET STAR TEST BIT TEST KEY 4 1 5 SKIP 6 9 TEST HI FIELD IT S A STAR IT S A HOLE 1 5 TEST LO FIELD IT S A STAR IT S A HOLE LOAD DISPLAY LEFT DIGIT UNCOND JUMP UPDATE COUNT BY ADDING ONE STORE IT UNPACK CONVERT g TO SEGMENTS AND DISPLAY IN DIGITS 5 AND 6 SET MODE TO 1 MAIN LOOP AGAIN MODE 1 DELAY ABOUT 8 SEC WHILE DISPLAYING KEY AS INDEX GET SHOT PATTERN SAVE IN Y REGISTER KEY OVER 5 NO GQ TO LOW FIELD UPDATE HI FIELD 6 9 RECALL PATTERN 6 9 NO SHOT 3RD TIME ALIGN WITH LO FIELD UPDATE LO FIELD RECALL PATTERN 1 5 ALIGN WITH HI FIELD UPDATE HI FIELD 1 5 BLANK SHOT IF 6 9 SHIFT 9 TO CARRY GET REST OF FIELD STAR DISPLAY 0294 2A DLOP ROL ALIGN WITH DISPLAY 0295 48 PHA SAVE IT FOR NEXT TIME 0296 29 49 AND 8549 MASK TO HORIZ SEGS 0298 95 DO STA 00D0 X INTO DISPLAY WINDOW 029A 68 m PLA RECALL FIELD 0298 DEX SHIFT TO NEXT 029C CA DEX DISPLAY DIGIT 029D DO F5 BNE DLOP REPEAT TILL DONE 029F 2A ROL BIT FOR 5 TO CARRY 02A0 BO OE BCS MODE 5 IS STAR CONTINUE 02A2 FO 08 BEQ LOSE 5 IS HOLE ALL HOLES 02A amp C9 FF FF ALL THE REST STARS 02A6 00 08 BNE MODE NO 02A8 AQ 71 71 YES LOAD 02 00 08 BNE FRST AND SKIP 02 AQ 38 LOSE LDA 38 LOAD L C
6. 10 FB 02B0 68 85 95 7A 20 6D 03 20 92 03 20 28 03 AS 9 j 02 0 C9 22 BO 29 65 9B 91 DO 18 C9 22 90 02 A5 9A 0200 C9 17 BO 2C 20 8F 03 DO E2 20 28 03 20 55 03 20 02 0 28 03 5 77 F8 38 5 79 85 77 4C 17 02 20 55 03 02 0 20 28 03 A5 77 F8 18 65 79 0 99 90 01 98 DO E8 0300 2 03 20 03 A5 9A C5 97 FO DF BO 05 90 B5 0310 97 F8 18 75 98 C9 22 BO 02 95 97 D8 B5 97 48 0 0320 E2 20 57 03 68 20 03 AD 80 20 30 03 88 DO FA 0350 84 7F A0 13 A2 05 A9 7F 8D 41 17 B5 90 8D 40 17 0340 8C 42 17 E6 7B DO FC 88 88 CA 10 EF 20 40 IF 20 0350 1F A4 7F 60 0 84 74 0 05 74 99 90 00 0360 88 10 F8 60 76 C6 76 BS 40 4A 4A AA 18 DO 01 0370 38 BD BE 03 BC CB 03 60 20 64 03 96 96 94 0380 8F AO 10 90 02 84 98 18 F8 65 97 85 97 08 60 20 0390 6 03 C6 99 99 94 96 0 10 90 02 84 9B 18 F8 03A0 65 9A 85 9A D8 60 48 A8 B9 E7 85 0380 94 68 29 OF A8 B9 E7 IF 85 95 60 03 00 20 01 02 03 0 03 0 05 06 07 08 09 10 10 10 10 F7 DB CF E6 ED 0300 FD 87 FF EF F1 F1 Fl Fl ED F6 BE F1 F1 B8 FC F9 05 0 F8 D3 F8 DC F8 CO FC BE ED 87 F9 DE i wee umane 45 BLACK MATCH modified b the editors Description There are 21 matches Each player must take 1 2 or 3 matches per turn The player who winds up with the last match loses player plays against the computer and goes first Starting address 0200 press GO Player e
7. 16 7 PB6 Not accessible 7 8 PB7 15 To assign any of the above connector pins to either input or output mode we have to store a magic number in location 1701 to control port A or in location 1703 to control port B 1 stored in specific bit position makes the corresponding port into an output into an input For example to assign PA7 to output and PAO through PA6 to input requires storing 10000000 or 80hex in location 1701 the following example although we deal only with port A all the remarks apply equally to the port B Example Burglar Alarm Let s suppose that we want to design a system under KIM control such that PAO through PA6 are connected to seven normally closed burglar alarm switches while PA7 should control a warning bell We want the bell to start ringing as soon as one of the contacts opens The bell should keep ringing even if the contact closes again We will first describe the software or the programming part of the problem and then will show you the actual circuit assume that by now you scanned through the KIM software chapters and are familiar with its basic instruction set 158 Burglar Alarm Program Loc Code Mnemonic Comments 00 A9 80 LDA 80 Set PAO through PA6 to 02 8D 01 17 STA 1701 Wai and PA7 to output 05 A9 OO LDA 00 Set output to 0 207 8 OO 17 STA 1700 Will affect PA7 only OA AD OO 17 LDA 1700 Read 1700 to find
8. Description KIM uses a 1 deck of cards in this game So when you ve seen four aces going by you know that there will be no more until the next shuffle BLACKJACK starts at address 0200 You ll see the cards being shuffled the word SHUFFL appears on the display and then KIM will ask how much you want to bet You ll start with an initial amount of 20 Your balance is always shown to the right of the BET question so on the first hand you ll see BET 20 on the display You may bet from 1 to 9 which is the house limit The instant you hit key 1 to 9 to signal your bet KIM will deal Of course you can t bet more money than you have and KIM ignores freeloaders who try to bet a zero amount After the deal you ll see both your cards on the left of the display and one of KIM s cards on the right KIM s other card is a hole card and you won t see it until it s KIM s turn to play Aces are shown letter A face cards and tens as letter F and other cards as their value two to nine always Aces count value 1 or 11 and face cards count 10 You call for a third card by hitting the 3 button then the fourth card with the 4 button and so on If your total goes over 21 points KIM will ungrammatically say BUSTED and you ll lose If you get five cards without exceeding 21 points you ll win automatically If you don t want any more cards hit key 0 will report yo
9. The irst Book of EL Jim Butterfield Stan Ockers and Eric Rehnke HAYDEN The First Book of KIM Edited by JIM BUTTERFIELD STAN OCKERS ERIC REHNKE HAYDEN BOOK COMPANY INC Rochelle Park New Jersey g Dedicated to the person who just purchased a KIM 1 and doesn t know what to do with Individual programs in this book were contributed by the various authors without copyright restrictions These programs may be used or copied without restriction It is how ever common courtesy to quote author and source when copying and a copy of any published material should be sent directly to the author In general program authors welcome comments suggestions or revi sions to their programs Depending on circumstances they may not find it possible to reply to all correspondence If you develop a program that you d like to share with other KIM users send it in to KIM 6502 User Notes 109 Centre Avenue W Norriton Penn sylvania 19401 It might appear in User Notes and even in a future Book of KIM ISBN 0 8104 5119 0 Library of Congress Catalog Card Number 78 53963 Copyright 1977 1978 by J Butterfield All rights reserved Except as noted above no part of this book may be reprinted or reproduced or utilized in any form or by any electronic mechanical or other means now known or hereafter invented including photocopying and recording or in any information storage and
10. You never need to hit the key during entry and the display will show the last value you have entered 0110 D8 0111 A9 13 0113 85 FE 0115 A9 O0 0117 85 FA 0119 85 FB 011B C6 F3 011D DO OE AS FD 0121 FO OA 0123 10 69 0125 AS FA 0127 DO 02 0129 C6 0128 C6 012 20 19 0130 20 0133 C5 FE 0135 FO El 0137 85 FE 0139 C9 15 013B FO DE 013D A2 00 013 86 FD START CLD DOWN LDA STA LA STA 13 CHAR 0 POINTL POINTH WAIT 1 UP POINTL DOWN POINTH DEC POINTL JSR SCAND JSR GETKEY CMP CHAR BEQ LOOP STA CHAR 15 BEQ LOOP LDX 0 STX TMPX DEC 116 clear decimal mode GO key image value zero to address pointer main program loop pause 1 second up or down neither down decreme nt next page light display check keys same key as last time note new key input no key yes skip clear up down flag Olhl C9 0113 90 0145 86 0117 C9 0149 FO E8 OlhC 86 C9 0150 DO 0152 015 C9 0156 DO 0158 C6 015A C9 015C DO 015 0161 0163 0165 85 0167 2 0169 016B DO 016D C 016 10 0171 20 0171 E6 0176 0178 B1 017 06 017 2 0170 91 O17F 0180 DO 0182 018 0185 0187 0189 018A 018C 26 26 DO FO 018 0191 0192 019 10 10 10 Fh 11 01 FF 12 02 FD 1 02 FD 13 CF C8 F8
11. 02 02 LOSE FIRST WIN WINX LIGHT NOINC LITE PAWS DOBUX JSR LDA LDA LDA INC BPL STA LDY STY STY LIGHT no bread CLC DIE add other die POINT get the point WIN eyup POINT point zero FIRST first roll 7 seven you lose LIGHT nope aa BUX 4 LOSX nough dough i SED decimal 0 neg one DOBUX put in window LIGHT unconditional WINDOW copy point WINDOW 2 8 WINDOW 1 WINDOW 3 POINT i point value ORB 2 X win table LIGHT point LOSE Says craps BUX Says win 99 maximum bucks WINX yes skip add decimally add 1 one DOBUX make segments FLAG still rolling NOINC nope WINDOW yup SO WINDOW 1 roll em 7F PADD 13 5 WINDOW X SAD SBD PAUSE PAWS DEY LITE START BUX 0 POINT clear point WINDOW 2 and 0281 0283 0285 0288 0289 02BC 02BE 02BF 02C1 02C2 02 5 0267 02C8 84 49 STY WINDOW 3 display A8 TAY LSRA HA HA LSRA LSRA LSRA AA TAX BD 7 1F LDA TABLE X 85 STA WINDOW 4 98 TYA 29 OF AND 0F AA TAX BD 7 1F LDA TABLE X 85 4B STA WINDOW 5 60 RTS FF FF 00 00 00 01 00 00 00 01 FF TAB 0200 D8 20 40 1F 20 6A F C5 40 FO 79 85 40 49 15 85 0210 41 C9 06 DO 05 9 1 20 9 02 AD 04 17 A2 CO 86 0220 HE A2 05 C5 HE 90 02 E5 HE 46 CA 10 F5 AA E8 0230 BD E7 1F A4 41 FO 06 86 42 85 43 DO 47 85 47 5 0240 43 85 46 A5 44 FO 3D 8A
12. DO ED FO B7 C9 0A 90 0280 05 49 OF 85 El 60 AA AS DD FO FA 86 DD AS DD 38 02 0 F8 9 05 85 DC 9 00 9 00 85 DB 60 45 01 00 99 0200 81 00 99 97 02 08 00 00 01 01 P ACKNOWLEDGEMENTS Ted Beach suggested the addition of the F flag when displaying fuel Chuck Eaton spotted the cause of an erratic bug in the original keyboard input subroutine Thanks to both 87 MULTI MAZE Description Find your way out of the maze You are the flashinq liqht in the centre of the display As you move up key 9 down 1 left 4 or riqht 6 KIM will keep you in the central display you ll see the walls of the maze movinq by as you travel Like walkinq throuqh a real maze you ll only see a small part of the maze as you pass through If you can get out you ll find yourself in a large open area that means you ve won Press GO at any time for a new maze Program starts at address 0200 Listing 0200 E6 DO START INC RND random seed 0202 20 40 JSR KEYIN 0205 DO F9 BNE START 0207 A2 07 LDX 7 patch the maze 0209 26 DO LP1 ROL 8 places 020B 90 17 BCC NXUP 020D BC 08 03 LDY PLACE X 0210 BD 10 03 LDA 1 0213 59 DE 02 EOR MAZE Y 0216 99 DE 02 STA MAZE Y 0219 C8 021A C8 INY 02YB BD 18 03 LDA POINT2 X 021E 59 DE 02 EOR MAZE Y 0221 99 DE 02 STA MAZE Y 0224 CA NXUP DEX 0225 10 E2 BPL LP1 0227 A2 02 LDX 2 0229 p8 CLD 022A 30 D4 SLINK BMI START 022C BD DB 02 SETUP LDA INIT
13. 00 IF CARRY SET 029C 85 FB STA 00FB 029E 60 02 JMP TIME LOOP XXXXX HEX DUMP CHESS CLOCK 3x 0200 9 00 AA 9D 00 00 ES DO 20 IF IF 20 9 0210 02 D F6 9 01 85 26 60 02 20 31 02 9 Be 85 0220 D4 20 60 02 18 AS F9 69 01 85 F9 20 31 08 13 0230 02 A9 02 C5 D4 D 11 AS FB 85 02 AS FA 85 D3 AS 0240 85 FB AS DI 85 FA 60 AS FE 85 D AS FA 85 Dl 0250 AS De 85 FB AS D3 85 FA 60 0260 F8 9 04 85 DS 9 F 8D 07 17 20 IF IF 20 0270 C5 D4 DO 01 60 2C 27 17 10 F C6 D5 D A9 0280 8D 06 17 2C 07 17 10 FB 18 5 FA 69 01 85 FA C9 0290 60 05 38 9 00 85 AS FE 69 00 85 FB 4C 60 024 0 02 51 CLOCK This clock routine uses KIM s built in interval timer with the interrupt option It works by loading Fh into the timer 1024 each time the Non Maskable Interrupt NMI occurs This theoretically pro duce a time of 249 856 microseconds or just under X second adjust ment to X second is done with the timer 1 in the interrupt routine A fine adjustment of the clock can be made by modifying the value in location 0366 Only two subroutines will be documented here ESCAPE TO KIM amp HOUR CHIME but many more can be added by simply replacing the NOP codes starting at 03DE with jumps to your own subroutines For instance a home control system could be set up using the clock program The escape to KIM allows KIM to run without stoppi
14. FO 9 FA FB F8 99 1D 1 20 63 1F 10 numeric BCC NUM yes branch STX DIGIT 4811 DA REQ OVER yes leave X 0 INX no set 1 OVER STX MODE 0 or 1 into MODE 812 BNE PASS no skip INC TMPX yes set browse PASS 1 PC BNE PASS skip DEC TMPX yes down browse PASS2 13 GO BNE 1 1 no loop JMP GOEXEC start program numeric hex entry comes here NUM ASLA ASLA position digit ASLA ASIA to left STA TEMP LDX h h bits to move LDY MODE AD or DA BNE ADDR branch if AD mode DEC DIGIT time to step BPL SAME no skip JSR INCPT yes step INC DIGIT and restore INC DIGIT digit count SAME LDA POINTL Y get data DADA ASL TEMP move a 1 ROL i into data STA POINTL Y DEX BNE DADA last bit BEQ LPL yes exit ADDR ASLA move bits ROL POINTL into address ROL POINTH DEX BNE ADDR BEQ 1 1 3 increment address for browsing UP JSR INCPT TAX BPL LPl end 117 61577 ee DIRECTORY Ever thought about the best way to organize your programs on tape I used to call the first program on each tape number Ol the next O2 etc Mostly I was afraid of forgetting the ID number and having trouble reading it in Program DIRECTORY below fixes up that part of the problem and liberates you to choose a better numbering scheme You ve got 254 program IDs to choose from enough fo
15. ORA FO plus F flag 025E A E1 LDY MODE 0260 FO 20 BEQ ST 0262 FO 9C GOLINK BEQ GO 0264 FO Ah CLINK BEQ CALC 0266 A2 FE LDX FE 0263 5A LDY 5 026A 13 CLC 026B A5 D9 LDA VEL 1 026D 69 05 ADC 5 026 5 D3 LDA VEL 0271 69 00 ADC 0 85 wwwwsY lt rmm 0273 BO 0 BCS GOOD 0275 A2 AD LDX 0277 AO DE LDY DE 0279 93 GOOD 027A E2 LDY DOWN 027C FO Oh BEQ ST 027E A5 D5 LDA ALT 0230 A6 D6 LDX ALT 1 0232 35 FB ST STA FOINTH 0234 36 STX POINTL Show rate of ascent descnt as absolute 0236 A5 D9 LDA 1 0239 D3 LDX VEL up or down 023A 10 05 BPL FLY up we re OK 023C 33 SEC 023D 9 00 LDA 40 2 023F E5 D9 SBC VEL 1 0291 35 F9 FLY STA INH 0293 A9 02 LDA 2 loop twice thru display 0295 35 E3 STA DECK 4 0297 D3 FLITE CLD display 4 test 0293 20 1F 1F JSR SCANDS light em up 029B 20 6A 1F JSR GETKEY check keys 029E C9 13 13 GO key 02A0 FO CO BEQ GOLINK 02A2 BO 03 BCS NOKEY if no key 02 206 AD 02 JSR DOKEY 02 7 C6 NOKEY DEC DECK 02 9 DO ED BNE FLITE 02AB FO B7 BEQ CLINK to CALC Subroutine to test keys O2AD C9 OA DOKEY 0 test numeric O2AF 90 05 BCC SUMBER 02B1 49 OF EOR 7 Fuel F gives 0 flag 0283 35 1 STA MODE 0285 60 RETRN RTS 0286 AA NUMBER TAX 0287 A5 DD LDA THRUST test is motor off 02B9 FO FA BEQ RETRN yes ignore key 02BB 36 DD STX THRUST no set thrust O2BD calculate acce
16. 02 60 88 90 40 28 DO 08 20 78 BO 48 EO AO FO 68 02 D8 50 10 CO 30 18 70 98 B8 C8 FC 7C 3C 1C OC 04 030B 84 C4 F4 56 CE 32 8C 1113 Display Characters kkkkkkkkkxk 0313 F7 FC B9 DE FO BD 84 9E FO B8 B7 D4 DC 0323 E7 DO ED F8 BE EA 9C 94 EE C9 BF 86 DB CF E6 ED 0333 FD 87 FF EF 90 84 D3 C8 Characters sent stored in 033B CHANGES The program sends and displays 5 groups of 5 characters each This may be changed although you may need to do some debugging along the way Important parameters are 0233 contains characters to be sent plus one 02 0 contains groups to be displayed after transmission 02 3 contains speed of transmission hex 33 gives about 16 groups min hex 66 gives 8 words min 02bE4 varies the tone 02 1 02 2 points at the block of characters to be sent 0222 controls the character set lA for letters only See Byte magazine October 1976 page 36 for details of morse character storage 58 C R P BY JIM BUTTERFIELD 4 DESCRIPTION SET ADDRESS 0200 THEN HOLD GO DOWN YOU LL SEE 2 DICE ROLLING ON THE LEFT 10 BALANCE ON THE RIGHT LET GO GO THE DICE WILL STOP ROLLING AND YOU LL GET A WIN ON A TOTAL OF 7 OR 11 YOU LL SEE YOUR DOLLAR BALANCE RISE OR A LOSS ON TOTALS OF 2 3 OR 12 YOUR DOLLAR BALANCE WILL DROP OR A POINT THE CENTER SEGMENTS WILL LIGHT WITH THE ROLL AND YOU MUST TRY TO ROLL THIS TOTAL AGAIN BEFORE YOU
17. 0293 0295 0296 0298 0299 029C 029E 02A0 02A2 02A5 02A8 02AA 02AB 02AD SET UP FOR NEXT CHAR INY 06 8506 6 CHAR DISPLAYED F3 BCC SIX NO 3D 1 JSR 1F3D KEY DOWN RTS EXIT MIU DEBOUNCE SUBROUTINE ANIM 8C 1E DEBO JSR INIT1 3E 02 JSR DISP WAIT FOR PREVIOUS KEY F8 BNE DEBO TO BE RELEASED 3E 02 SHOW JSR DISP WAIT FOR NEW KEY TO FB BEQ SHOW BE DEPRESSED 3E 02 JSR DISP CHECK AGAIN AFTER F6 BEQ SHOW SLIGHT DELAY 6A 1F JSR GETKEY GET A KEY 15 8515 VALID KEY E7 BPL DEBO NO RTS RANDOM NUMBER SUBROUTINE XxxX RAND TXA SAVE X REGISTER PHA CLD RANDOM ROUTINE FROM SEC J BUTTERFIELD KIM B 41 LDA 0041 USER NOTES 1 PAGE 4 44 ADC 0044 45 ADC 0045 40 STA 0040 04 LDX 04 40 NXTN LDA 0040 X 41 STA 0041 X DEX F9 BPL NXTN k STA 00 0 PLA RETURN X REGISTER TAX CO LDA 00 0 RTS XXX COMPARE SUBROUTINE 04 COMP LDX 504 COMPARE ROOM IN ACC CB HAZD CMP 00CB X WITH EACH HAZARD 03 BEQ OUT DEX F9 BPL HAZD X ON EXIT SHOWS MATCH OUT RTS XXX MOVE WUMPUS SUBROUTINE 72 02 JSR RAND A RANDOM OF AND 0 STRIP TO HEX DIGIT 04 CMP 504 CHANGE ROOMS 75 0 NOCH OF THE TIME B2 02 JSR NEXT ADJ ROOMS WUMPUS 06 17 1706 GET RANDOM 0 3 03 AND 8503 TAX USE AS INDEX C6 LDA 00C6 X GET AN ADJ ROOM CB STA OOCB PUT WUMPUS IN IT 111 02 5 CB NOCH LDA 00CB WUMPUS ROOM IN ACC 02B1 60 RTS XXX LOAD NEXT ROOMS SUBROU
18. 0490 0228 20 8D 02 LPB JSR DISPLY 0500 022B C6 08 DEC STALLA DISPLAY WHILE 0510 022D DO F9 BNE LPB 0520 022 06 LDX ARROW 0530 0231 09 LDA TUMBLE MAKE A 0540 0233 29 06 ANDIM 06 RESULT 0550 0235 09 40 ORAIM 40 0560 0570 0237 95 01 STAAX WINDOW 01 0580 0239 H6 09 LSR TUMBLE 0590 023B 46 09 LSR TUMBLE DO ALL 0600 023D C6 06 DEC ARROW 3 WINDOWS 0610 023F DO E7 BNE LPB 0620 0852 ALL WHEELS STOPPED COMPUTE PAYOFF 0650 0241 A5 OH LDA WINDOW 04 0660 0243 C5 03 WINDOW 03 CHECK FOR 0670 0245 DO 37 NOMAT A MATCH 0680 0247 C5 02 WINDOW 02 0690 0249 DO 33 BNE NOMAT 0700 0248 A2 10 LDXIM 10 0710 024D C9 40 CMPIM 40 PAY 15 FOR 3 BARS 0720 O24F FO OD BEQ PAY 0730 0251 A2 OB LDXIM 08 0730 0253 C9 42 CMPIM 42 PAY 10 FOR 3 UPS 0750 0255 FO 07 BEQ PAY 0760 0257 A2 06 LDXIM 06 0770 0259 C9 44 CMPIM 44 PAY 5 FOR 3 DOWNS 0780 025B FO 01 BEQ PAY 0790 025D CA DEX 35 0310 WIN PAY AMOUNT IN X 0820 0830 025 86 07 STX RWD HIDE REWARD 0840 0260 A9 80 PAX LDAIM 80 0850 0262 85 08 STA STALLA 0860 0264 20 8D 02 LPC JSR DISPLY DISPLAY 0870 0267 C6 08 DEC STALLA FOR A HALF 0380 0269 DO F9 BNE LPC A WHILE 0890 026B C6 07 DEC RWD 0900 026D FO 9C BEQ LPA 0910 026F 18 SLOWLY ADD 0920 0270 F8 SED THE PAYOFF 0930 0271 5 05 LDA TO THE AM T 0940 0273 69 01 ADCIM 01 0950 0275 94 BCS 0960 0277
19. 1 0199 B9 BF 01 LDA TIMG Y 019C 8D 44 17 STA 1 1 019F A5 F5 LDA GANG 01A1 49 80 EOR 8580 01A3 8D 42 17 STA SBD 01A6 85 F5 STA GANG 01A8 CA DEX 01A9 DO E9 BNE 70 1 01 68 PLA 01 C6 F3 DEC TRIB OlAE FO 05 SETZ 01B0 30 07 BMI ROUT 01B2 4A LSR A 01B3 90 DB BCC ZON 01B5 AO 00 SETZ LDY 0 01B7 FO D7 BEQ ZON 0189 C6 F2 ROUT DEC COUNT 01 10 CF BPL TRY 01 60 RTS frequency density controls OlBE 02 NPUL 02 O1BF 03 7E TIMG C3 03 7E Hex Dump Hypertape 0100 9 8D 17 20 32 19 A9 27 85 F5 A9 8D 43 0110 17 2 64 9 16 28 61 01 A9 2 20 88 01 AD FY 17 0120 20 70 01 AD F5 17 20 6D 01 AD F6 17 20 6D 01 29 0130 17 20 6D 01 22 EA 19 AD ED 17 CD F7 17 AD EE 0140 17 ED F8 17 90 9 9 2 20 88 01 AD 17 20 70 0150 01 AD 8 17 20 70 01 2 02 AD 04 20 61 01 4C SC 0160 18 86 48 20 88 01 68 C6 DO F7 60 20 AC 19 0172 48 4A 4A 4A 20 7D 01 68 20 7D 01 69 29 OF 9 0180 18 30 02 69 07 69 30 07 84 F2 A 02 84 F3 0190 01 48 2C 47 17 10 FB B9 01 8D 44 17 5 01 0 FS 49 80 8D 42 17 85 FS D E9 68 C6 F3 FB BS 01 0 30 07 4A 90 DB AS 00 FO D7 C6 F2 10 CF 60 02 C3 01 0 03 7 Thanks go to Julien Dub for his help in staging early versions of HYPERTAPE 121 J MEMORY TEST Testing RAM isn t just a question of storing a value and then checking it It s important to test for inter
20. BEQ BNE LDA STA LDX LDY STY LDA JSR INY CPY BCC JMP 00 00 NEWORD STEP 1 514 K UP SCAND K UP WINDOW 7F PADD 508 500 00FC 00E6 Y 1F4E SP 506 DISP1 1F3D PULL FB AND FA DISPLAY WORD 2 IS 9 PRESSED NO BRANCH PUSH FA AND FB FIND NEW LOCATION DISPLAY WORD IS PRESSED NO GET KEY DISPLAY LOCATION UNTIL KEY RELEASED THEN GET KEY SEGMENTS TO OUTPUT INITIALIZE GET CHARACTER DISPLAY CHARACTER NEXT CHARACTER DONE KEY DOWN HEX DUMP MINI DIS 08 A2 C9 20 19 FO 29 8F 01 FO 49 07 1F 95 E4 ED 0B DO 03 C9 FO EC 7F 8D C8 9A 3B 29 02 20 ED E8 EO BA DO F7 17 90 A2 FO 94 C9 2h E5 92 29 FF 30 E7 20 85 FB 19 FC CA F0 oc 8D EB 1F AF FB 48 1F B9 DO 1A C9 07 10 hA 95 03 68 20 FO E6 FA C9 98 29 8A E7 EE C9 04 EE 1F 24 ANOTHER move program This one moves anything anywhere No limit to number of bytes or locations in memory or overlapping of source and destination Use it to lift sections of code from other programs close in or open un gaps for altering programs moving programs to another location use Butterfield s RELOCATE to take care of the branch and address correction Locate it wherever you have Use is straight forward Old start address goes in 20 1 old end address in D2 3 new start address in D4 5 before run
21. CHNG 54F LOSE 565 LOSE 500 587 SCAN DEBO VALID 00D1 ROOM 00D1 00 0 00 0 00CB WIN 00 0 OUT 00CB NEXT MOVE 109 DEBOUNCE KEY PC PUSHED YES AN ADJACENT ROOM UPDATE YOUR ROOM IF X FF NOT VALID ROOM CHECK FOR GAS IN ROOM 5 POSSIBLE CEXPANSIOND GASSED ALL CHECKED NO CHECK YOUR NEW ROOM FOR HAZARDS NO MATCH NO HAZARDS BATS PIT MUST HAVE BUMPED WUMPUS DISPLAY MESSAGE SEE IF HE MOVES STILL IN YOUR ROOM NO YOU RE O K HE GOT YOU BAT MESSAGE e CHANGE YOUR ROOM FELL IN PIT GAS IN ROOM PITCH CAN AND SEE IF YOU GET HIM ROOM VALID ROOM IF X FF NOT VALID CANS OF GAS LEFT IS WUMPUS IN ROOM GASSED YES YOU GOT HIM DECREASE CAN COUNT GAS IS GONE WUMPUS TO AN ADJACENT ROOM HIM 03E9 05 03 03 2 03F4 03F6 03F9 03FB 03FD 0200 0202 0204 0206 0208 020A 020C 020E 0210 0212 0215 0215 0216 0217 0219 021A 021B 021C 021 0220 0223 0225 0228 022A 022C 022 0251 0234 0257 0239 0258 0230 023 0250 0255 0245 0247 025A 024C C5 F0 4C 0 9 20 F0 4C 4 4 4 owed 00CA 03A8 02DE 3501 580 SCAN WIN 8573 LOSE 00DE 00DD 8 07 0007 505 8505 C00DD Y 500 00E8 X CHAR 00DF 00DC 0228 OODC CONT SUBROUTINE 850A 0008 552 1707 DISP 1707 LITE 00DB TIME 157 PADD 500 509 00 8 00FC 1F4
22. DUMP BAGELS 3999 0200 16 20 40 1F DO F9 08 AQ 85 18 A9 03 85 10 0210 38 A5 13 65 16 65 17 85 12 A2 05 B5 12 95 13 CA 0220 10 F9 A6 10 A0 CO 85 11 A0 06 C5 11 90 02 E5 11 0230 46 11 88 00 F5 18 69 95 00 C6 10 10 D2 C6 18 0240 30 7A A9 00 A2 OC 95 04 CA 10 FB 20 CE 02 FO FB 0250 20 CE 02 FO F6 A5 08 FO 08 29 60 49 60 FO A9 DO 0260 DD 20 6A 1F C9 10 BO E3 C9 90 DF 8 10 E6 0270 10 B9 E7 1F 95 04 98 05 00 DO 03 E6 OE 8A 95 0A 0280 A5 07 FO 31 AO 03 BY 00 29 18 FO 12 B9 00 00 0290 A2 03 D5 FO 05 CA 10 F9 30 08 E6 OF 16 88 02 0 10 E4 A2 01 B4 OE B9 E7 95 08 10 F6 20 CE 02B0 02 E6 OF 00 F9 20 CE 02 00 FB FO 8F A2 03 B 00 02 0 B9 E7 95 04 CA 10 F6 9 85 08 DO EO 0 15 0200 2 05 9 7F 8D 41 17 BS 04 8D 40 17 8C 42 17 E6 02 0 11 DO FC 88 88 CA 10 EF 20 40 1F 60 32 Label Table for Program BAGELS ADDRESS LABEL WHERE USED 02B5 BUTT 0282 02B8 0018 COUNT 020A 023E 02AE DELAY 02B3 02CC 000E EXACT 027 02A4 02BE FIN2 02C6 02BC FINISH 0240 lF6A GETKEY 0261 0200 GO 0205 029B GOT 0294 023E GUESS 025F 000A INPUT 027 0286 0292 029D 1F40 0202 02E8 0207 LITE 02 0292 LOOK 0297 000F MATCH 029B 0281 0011 MOD 0226 022A 022 0230 020 0208 NEW 025D 027E NOTEX 0279 029F ON 0299 1741 PADD 02D4 0230 PASS 022C 0010 POINTR 020E 0222 023A 026D 026F 02DF POZ 02 1 0210 RAND 023C 0261 RESUME 0257 021B RLP 0220 0012 RND 0200 0211 0213
23. Dis Assemblers A disassembler works in reverse from an assembler If you have a program in KIM machine language the disassembler will print it out in the more easily readable assembly language Very handy for investigating a working program if you don t have the listing For example if you have coding starting at address 020F that reads 10 F8 AD 04 17 85 80 the disassembler would print something like this 020F CA DEX 0210 10 F8 BPL 020A 0212 AD 04 17 LDA 1704 0215 85 80 STA 0080 As you can see this is much more readable Interpreters BASIC FOCAL etc There are several high level languages that are much easier 4 M for writing programs than KIM 6502 machine language k With the proper software package KIM can translate these yi high level instructions and perform the desired actions 1 The translation job takes time so KIM will run many times slower than its normal machine speed Programming convenience is so great however that most users don t mind the loss of speed Interpreters can take up quite a bit of memory anywhere from 2K to 16K locations so you ll have to be fitted with the appropriate amount of memory expansion If you hear of an 8K Basic interpreter you ll know that means 8 000 locations for the program and of course you ll need to provide extra memory to fit your own programs in A brief example will show how simple a language like BASIC can be for programming To input
24. 00 15 00 39 00 OD 00 21 00 0305 10 00 00 XXXXX DUMP ASTEROID a 1 2108 lt 0200 9 00 85 F9 85 FA 85 FB A2 06 amp C 02 95 gr 0210 10 F8 A5 E8 49 FF 85 E8 2 05 20 48 02 20 97 02 0220 DO F7 20 40 1F 20 6A IF C9 15 10 E5 C9 00 FO 02302 06 C9 03 FO DO DB 06 E7 9 40 C5 E7 DO D3 46 0240 7 DO CF 38 26 E7 DO CA AQ 7F 8D 41 17 9 09 8D 0250 42 17 A9 20 85 EO 0 02 00 85 El Bl E2 25 EO 0260 FO 07 5 El 19 E4 00 85 El 88 10 FO A5 El Ch 0270 DO 08 EO Ch E7 DO 02 09 08 8D 40 17 9 30 8D 0280 06 17 AD 07 17 FO FB AQ 00 8D 40 17 EE 42 17 EE 0290 42 17 46 DO CO 60 C6 E9 DO 1A A9 30 85 E9 8A 02A0 48 A2 FD F8 38 B5 FC 69 00 95 FC E8 DO F7 08 68 0280 E2 A5 E2 C9 30 FO 09 0 00 5 E7 31 E2 00 02C0 07 60 A9 00 85 E2 FO Fl 20 1F 1F 4C C8 02 05 02 0200 08 40 01 04 FF 00 00 00 04 00 08 00 06 12 00 11 02 0 00 05 00 2C 00 16 00 29 00 16 00 2B 00 26 00 19 02F0 00 17 00 38 00 2E 00 09 00 1B 00 24 00 15 00 39 0300 00 0D 00 21 00 10 00 00 1 5 YOU MAKE YOUR OWN ASTEROID FIELD STARTING 0205 THE GROUP COUNT 0286 WILL HAVE TO BE CHANGED IF THE FIELD SIZE DIFFERS THE SPEED OF THE CRAFT MOVING THROUGH THE FIELD IS CONTROLLED BY 027E WHAT ABOUT A VARYING SPEED SLOW AT FIRST AND SPEEDING UP AS YOU GET INTO THE FIELD WHAT ABOUT A FINAL DESTINATION COUNT AND A SIGNAL TO INDICATE YOU HAVE REACHED YOUR DESTINATION HOW ABOUT A
25. 0056 20 62 00 DOWN JSR DISP DISPLAY C8C 91 0059 DO FB BNE K DOWN UNTIL KEY UP 0058 20 62 00 JSR DISP DISPLAY C8C 91 005E B4 BNE NEWCRD UNTIL KEY DOWN 0060 FO F9 BEQ K UP 0062 A9 7F DISP LDA 7F SEGMENTS TO OUTPUT 0064 8D 41 17 STA 1741 0067 A0 00 LDY 00 INITIALIZE 0069 A2 08 LDX 08 0068 B9 8C 00 DISP 1 LDA 008C Y GET CHARACTER 006 84 FC STY OOFC 0070 20 IF JSR 1F4E DISPLAY CHARACTER 0073 C8 INY NEXT CHARACTER 0074 06 CPY 06 0076 90 F3 BCC DISP 1 0078 4C 3D IF JMP 1F3D DONE KEY DOWN TABLES 0078 77 VALTBL AM 007C 5B 0070 HF jn 007E 66 007F 6D 0080 7D g 0081 07 nn 0082 7F gn 0083 6F 0084 78 0085 1E gn 0086 67 0087 70 e 0088 6D SUI TBL ngr 00 89 76 008A 5E 0088 39 DUMP CARD DEALER XXXXX 0000 A2 06 AO 00 94 8B DO FB 08 A2 34 86 92 C8 94 0010 92 DO FB 5 92 DO 03 HC 1C AD 04 17 DO 0020 AD 44 17 DO 06 A5 92 5A 18 69 01 C5 92 90 07 FO 0050 05 E5 92 HC 2B 00 A2 33 38 F5 93 FO 03 CA 10 F8 0040 95 93 C6 92 4A 8 B9 7B 00 85 90 8A 29 03 0050 A8 B9 88 00 85 91 20 62 00 DO FB 20 62 00 00 B 0060 FO F9 9 7 8D 41 17 0 00 A2 08 B9 8C 00 84 FC 0070 20 1F C8 CO 06 90 F3 4C 3D 1F 77 5B 4F 66 6D 0080 7D 07 7F 6F 78 1E 67 70 6D 76 5E 39 CHESS CLOCK DESCRIPTION THE PROGRAM STARTS AT LOCATION 0200 TWO INDEPENDENT CLOCKS ARE OPERATED BY THE TW
26. 0215 0217 021B 021D 1740 SAD 02D9 1742 SBD 02DC 0000 SECRET 0238 0277 028D O2BE 022A SET 0233 02CE SHOW 024B 0250 02 0285 0286 STEP 02A0 lFE7 TABLE 0271 02A6 02 0 02A4 TRANS 02AC 024B WAIT 024B 0253 0266 026A 02BA 0246 WIPE 0249 0004 WINDOW 0246 0255 0274 0280 02A9 02C3 02CA 02D7 Label tables when available are often useful for studying a program For each label alphabetically arranged you can see on the left the address belonging to the label and on the right where the label is used in the program 33 BANDIT Start the program at 0200 and on the right you ll see the 25 that KIM has given you to play with The funny symbols on the left are your wheels hit any key and see them spin Every time you spin the wheels by hitting a key it costs you 1 When the wheels stop you might have a winning combination in which case you ll see money being added to your total on the right Most of the time you ll get nothing but that s the luck of the game The biggest jackpot is 15 that s three bars across the disolay Other combinations pay off too you ll soon learn to recognize the cherry symbol which pays 2 every time it shows in the left hand window There s no house percentage so you can go a long time on your beginning 25 The most you can make is 99 and if you run out f money too bad KIM doesn t give credit dev 444 9e 777 5740 14 1 BANDIT MICRO WARE A
27. 0283 0284 02B6 02B3 O2BA 02BC O2BD O2BF 0201 0203 0205 02C7 02C9 02CB 02CC 02 02100 0202 0205 0207 0209 02DB 02 02DF 02 1 02E3 02 5 02 7 02 9 02 02 0228 0229 02FB 02FD 02FF 0301 0302 0305 0307 0309 0308 030D 0310 0312 0313 0315 3B 0A F8 MERGE LOOP FOUND 17 MOVE TRY 03 03 05 KEEP 02 MESSAG 03 MLOOP LDA STA LDX BEQ DEX BNE LDA LDX EOR DEX BPL STA LDX LDA EOR CMP BCC DEX BEQ LDY CPY BCS STA STX LDX LDA STA INC LDA CMP BCC LDX LDA JSR JSR BNE JSR SEC ROL LDA STA STA CLD LDA STA STA LDX LDA STA DEX BPL RTS F3 WAIT MOVE whose move EXIT not computer s first step no skip stratgy 0 5 merge all piles VALUE X by EOR ing them MERGE FLASHR Save EOR product 6 re examine piles VALUE 1 X FLASHR VALUE 1 X FOUND LOOP MOVE IQ IQ high enuff TIMER randomly MOVE no move dumb TEMP amount PILE pile number PILE FLASHR X flash mask FLASHR Flash MOVE but don t make MOVE the move till 10 time has passed EXIT PILE time to move TEMP SEG make move SURVEY end of game KEEP nope keep goin MESSAG U LOSE dummy up IQ the computer 0 MOVE it s your move PILE un flash START 0 MOVE end of play PILE no flashing 6 move 7 digits DATA X pick em up FLASHR X put em down MLOOP 75
28. 0305 you and Wumpus are placed at random in the rooms Also placed at random are two bottomless pits they don t bother Wumpus he has sucker type feet and two rooms with Super bats also no trouble to Wumpus he s too heavy If you enter a bat s room you are picked up and flown at random to another room You will be warned when bats pits or Wumpus are nearby If you enter the room with Wumpus he wakes and either moves to an adjacent room or just eats you up you lose In order to capture Wumpus you have three cans of mood change gas When thrown into room containing Wumpus the gas causes him to turn from a vicious snarling beast into a meek and loveable creature He will even come out and give you a hug Beware though once you toss a can of gas in the room it is contaminated and you cannot enter or the gas will turn you into a beast you lose If you lose and want everything to stay the same for another try start at 0316 The byte at 0229 controls the speed of the display Once you get used to the characters you can speed things up by putting in a lower number The message normally given tellg you what room you are in and what the choices are for the next room In order to fire the mood gas press PC pitch can when the rooms to be selected are displayed Then indicate the room into which you want to pitch the can It takes a fresh can to get Wumpus he may move into a room already gassed and he will hear you and change rooms wh
29. 04 OA 26 F9 26 FA 26 FB CA DO F6 FO A2 NOTE WHENEVER SPACE PERMITS A HEX DUMP OF THE PROGRAMS LISTED WILL BE GIVEN THESE DUMPS WERE TAKEN FROM ACTUAL RUNNING PROGRAMS SO IF THERE IS A DISCREPANCY BETWEEN THE LISTING AND THE DUMP THE LISTING IS MOST PROBABLY IN ERROR 25 ASTEROID YOU PILOTING YOUR SPACECRAFT BETWEEN MARS AND JUPITER WHEN YOU ENCOUNTER A DENSE PORTION OF THE ASTEROID BELT PRESS KEY ZERO TO MOVE LEFT THREE TO MOVE RIGHT WHEN YOUR CRAFT IS HIT THE DISPLAY WILL GIVE A NUMBER TO INDICATE HOW SUCESSFUL YOU THE PROGRAM STARTS AT 0200 WERE 0200 0202 0204 0206 0208 020A 020D 020F 0210 0212 0215 0216 0218 021A 021D 0220 0221 0225 0226 0229 022B 022D 022F 0231 0233 0235 0237 0239 0238 023D 023F 0241 0243 0244 0246 0248 025A 0280 024F 0252 0254 0256 0258 025A A9 85 85 85 A2 BD 95 CA 10 00 F9 FA FB 06 CE E2 F8 E8 FF E8 05 48 97 02 02 02 1 1 17 17 INIT TOGG LITE LEFT RT DISP BIT LDA 00 INITIALIZE COUNTER STA 00 9 STA 00FA STA 00 LDX 06 INITIALIZE 00 2 00 8 LDA 02CE X STA 00E2 X DEX BPL INIT LDA 00E8 TOGGLE 00 8 EOR STA 00 8 CFLASHER FLAG LDX 05 DELAY BETWEEN FLASHES JSR DISP DISPLAY AND JSR CHEK CHECK FOR MATCH DEX BNE LITE JSR KEYIN SET DIRECTIONAL REGS JSR GETKEY GET KEYBOARD ENTRY CMP 15 A VALID KEY BPL TOGG NO CMP 00 KEY 0
30. 08 OE 05 06 OF 08 09 OF 0B OC OD OE OE OF 00 OD 2 112 0090 00A0 0080 0100 0110 0120 0130 0140 0150 0160 0170 0180 0190 01A0 0200 0210 0220 0230 0240 0250 0260 0270 0280 0290 02A0 02B0 02C0 02D0 02 0 02 0 0500 0510 0520 0550 0340 0350 0360 0370 0380 0390 03A0 03B0 03C0 03D0 03E0 03F0 80 80 80 Messages kkkk B7 84 ED B9 DL B8 DC ED 9C BE B7 F8 80 B9 DC ED F9 BE ED 80 F9 00 FC 84 84 84 F8 80 80 00 80 80 80 80 F9 F8 80 B7 F3 BE ED ED FS F9 80 80 BE DC 00 DC F8 F9 80 BE BD 80 80 DE B8 00 80 F9 80 80 F9 F6 80 ED 80 F7 80 F9 BE CO 80 F1 F8 DO DC B9 B8 00 80 F7 80 EE DC 04 F7 F1 F9 ED 80 DC Fi F7 F8 BD 80 DC D4 B8 80 00 80 DC B7 D3 DC ED F9 FC F7 F8 F6 F7 80 BE 80 00 F8 B9 F6 B8 B8 80 84 D4 80 80 BD F7 CO 80 EE Fi DO DC Hex Dump Main Program DE 85 DD 01 60 95 28 02 4 20 3E 02 41 17 0 06 90 F3 02 FO 60 8A 58 40 95 41 05 CB FO 0D 20 B2 60 A6 CA 80 85 C9 20 00 02 E7 1F 85 BD 80 F1 EA EA EA 0 05 FO F5 84 El B9 19 10 OA 00 02 C6 03 B4 C6 02 20 58 A5 CA A2 9A EO 05 20 99 02 20 00 02 A0 00 A9 30 EE A5 CB 20 EA A0 01 A9 Wumpus 07 88 4C 07 A2 3D 20 38 10 A0 05 F3 D8 A2 03 F8 C6 E8 00 20 8C F0 F6 65 44 CO 68 60 20 29 03 B5 60 C6 FO 20 00 90 20 9C BE 0E 95 A2 05 00 88 02 8A A9 0E D
31. 1 022 5 2 LAST i 022F FO F2 BEQ GUESS same key f wc 0233 0235 0237 0239 023A 023B 023C 023D 023F 0240 0242 0243 0245 0247 0249 024B 024D 024F 0251 0253 0255 0257 0259 025B 025D 025F 0261 0263 0264 0266 0268 0200 0210 0220 0230 0240 0250 0260 F8 40 F9 F2 26 D2 FA A5 1F 86 85 FQ 85 LOOP EVAL OVRI OVR2 P CMP 0A A key BEQ EVAL yes evaluate guess BCS GUESS no key ASL A roll character ASL A into ASL A position ASL LDX 3 ASL A then ROL INH into DEX display BPL LOOP BMI GUESS LDA INH guess lower CMP RND than number OVRI yes skip POINTH check hi BCS GUESS out of range STA POINTH LDX RND number lower CPX INH than guess BCC OVR2 yes Skip LDX no check lo CPX INH 2 BCS GUESS out of range STA POINTL LDX NGUESS guess number lt INX plus 1 CPX SAA past limit BEQ RSET yes reset BNE NSET HEX DUMP HI LO 25 EO 38 69 00 A2 01 C9 99 DO 01 8A 85 EO 20 20 ED El 20 E2 C9 CA 10 FB A6 El E8 08 A9 99 85 FB 9 00 85 2 0 86 1F 1F 20 6A 1F C9 13 FO D3 C5 E2 FO FO 10 BO EA A2 03 OA FA 30 DC A5 F9 C5 EO 90 06 C5 FB BO E4 F9 90 08 F9 BO Ch 85 EO AA F0 B5 00 B5 68 HORSERACE DESCRIPTION THIS IS AN EIGHT LAP HORSE RACE AND YOU
32. 20 40 1F ZIP JSR KEYIN IF YOU CHEAT BY KEYING 030C DO FB BNE ZIP PROGRAM WAITS YOU OUT 030E E6 FA INC POINTL 0310 DO F7 BNE ZIP COUNT DOWN FOR 0312 INC POINTH RANDOM DELAY 0314 00 F3 BNE ZIP E 0316 85 F9 STA INH SET TO ZERO 221 0318 2 FD RUN LDX FD NEGATIVE THREE 1 031A F8 SED COUNT IN DECIMAL 0318 38 SEC ADD VALUE 1 B ozic Bs FC DIGIT LDA POINTH 1 031 6400 ADC 00 ADD IT IN 0320 95 STA POINTH41 X 0322 INX MOVE ON TO NEXT DIGITS 0323 DO F7 BNE DIGIT 0325 D8 CLD 0326 20 1F 1F JSR SCANDS LIGHT UP COUNT 0329 FO ED BEQ RUN AND KEEP COUNTING 032B 20 1F 1F STAND JSR SCANDS 032E 20 1 JSR GETKEY 0331 C9 13 13 GO KEY DEPRESSED 0333 DO F6 BNE STAND NOPE HOLD IT 0335 F0 C9 BEQ START YUP START OVER Hex Dump Quick n 9 2 L m AL i 42 0300 AS F9 2A 65 F9 29 7F 85 FE 20 40 IF 0310 F7 D 85 F9 A FD 38 BS 69 020 0320 95 8 DO F7 D8 20 IF IF F EL 20 IF IF 20 6A 0330 IF 13 DO F6 FO 9 100 REVERSE By Jim Butterfield Start at 0200 the display will show a combination of 6 letters such as CDBAFF Hit a number from 2 to six to flip letters For example if you hit 2 with the previous example the first two letters will flip over to give DCBAEF Now if you hit 4 you ll get the winning combination ABCDEF and the display will
33. 4 Can you change the program so that only the last digit of the display changes with the keyboard 21 IPO EAE CONCLUSION You ve reached the end of our little Beginner s Guide But you ve only started on the road towards understanding programming Use the tools we have given you here to forge your own path KIM is a very rich machine You have 56 Op Codes to choose from and many powerful addressing combinations You don t need to learn them all right away but when you need them they ll be there The KIM Programming Manual makes good reading Don t try to go through the whole thing at one sitting Stop and try a few things you have the Single Step feature to help you understand what each instruction really does Try leafing through or stepping through other people s programs to understand what makes them tick Change the coding if you like to see what happens When you see a program that does something you want to do borrow the coding you don t need to re invent the wheel Don t be discouraged when your program doesn t work on the first try Even experts have to spend time getting the bugs out of their coding It s part of the game Think of yourself as Sherlock Holmes methodically tracking down the elusive villains A proverb says that a journey of a thousand miles starts with the first step In the same way the biggest programs still operate one step at a time So forge ahead
34. 5 05 LDA 02C6 4A LSRA 02 7 LSRA 02 8 4A LSRA 02C9 LSRA O2CA 02 E7 1F LDAAX TABLE 02 85 01 STA WINDOW 01 02D0 60 RTS SYMBOL TABLE 3000 30A2 AMT 0005 ARROW 0006 BANDIT 0200 CVAMT O2BA DISPLY 028D GO 0200 INDIS 0293 KEYIN 1 10 LITE 029F LOK 0284 LPA 0208 LPB 0228 LPC 0264 NOMAT O27E OVER 0291 PADD 1741 0260 PAY 025E ROLL 0210 RWD 0007 SAD 1740 SBD 1742 STALLA 0008 TABLE 1 TUMBLE 0009 WINDOW 0000 ZIP 2 You ll notice that the listing for BANDIT looks a little different from others in this book That s because it is the output of a resident assembler operating in an expanded KIM system See the section on expansion for a further discussion of assemblers You might like to change the payouts so that there is a house percentage That way visitors will eventually run out of money if they play long enough This has two possible advantages it will teach them the evils of gambling and they won t hog your KIM all day playing this game 37 BITZ A teaching program which drills you on binary and BY JIM BUTTERFIELD hexadecimal numbering schemes just as a speed test Start the program at 0200 and you ll see eight bits on the left side of the display are in the lower position meaning off or zero Others will be in the top row where they mean on or logic one All you have to do is translate those bits into hexadecimal notation
35. 85 05 STA 0970 0279 20 02 JSR CVAMT 0980 027C DO E2 BNE PAX 0990 1000 WHEELS NOT ALL THE SAME CHECK FOR SMALL PAYOF 1010 f i 1020 027E A2 03 NOMAT LDXIM 03 1030 0280 C9 46 CMPIM 46 A CHERRY 1040 0282 FO DA BEQ PAY 1050 0284 20 8D O2 LOK JSR DISPLY 1060 0287 5 05 LDA AMT CAN T PLAY 1070 0289 DO 80 BNE LPA WITH NO DOUGH 1080 028B FO F7 BEQ LOK 1090 1100 1110 1120 1130 DISPLAY SUBROUTINE 1140 1150 0280 A6 06 DISPLY LDX ARROW 1160 028F 10 02 BPL INDIS ROLL 1170 0291 F6 02 OVER WINDOW 02 THE DRUM 1180 0293 CA INDIS DEX 1190 0294 10 FB BPL OVER 1200 0296 A9 7F LDAIM 7F 1210 0298 8D 41 17 STA PADD 1220 029B AO OB LDYIM 08 1230 029D A2 O4 LDXIM 04 1240 029F B5 00 LITE LDAAX WINDOW LIGHT 1250 02A1 8C 42 17 STY SBD ALL THE 1260 02A 8 HO 17 STA SAD WINDOWS 1270 0217 D8 CLD 3 1280 0218 9 LDAIM 7 E 1290 O2AA E9 01 ZIP SBCIM 01 1300 O2AC DO FC BNE ZIP 1310 O2AE 8D 42 17 STA SBD 1320 02B1 C8 INY 1330 0282 C8 INY 36 1340 1350 1360 1370 1380 1390 1400 1410 1420 1830 1440 1450 1460 1470 1480 1490 1500 1510 1520 1530 1540 02B3 CA DEX 02BH 10 E9 BPL LITE 0286 20 40 1F JSR KEYIN 0289 60 RTS AMOUNT CONVERSION 02BA A5 05 CVAMT LDA 02 29 OF ANDIM 0F TRANSLATE 2 AMOUNT 2 BD 1 LDAAX TABLE TO LED 02C2 85 00 STA WINDOW CODE 02C4
36. ADDRESS 00 0 0 You ve just entered the address of memory cell 0000 the lowest numbered one in memory The display will show 0000 the number you entered on the left On the right you ll see the contents of cell 0000 it will be a two digit number That number might be anything to start with let s change it Press key DA for DATA you re ready to change the contents of cell 0000 Key in 44 for example and you ll see that the cell contents have changed to 44 Hit the button and KIM will go to the next address As you might have guessed the address following 0000 is 0001 You re still in DATA mode you hit the DA key remember so you can change the contents of this cell This time put in your lucky number if you have one Check to see that it shows on the right hand part of the display This kind of memory the kind you can put information into is called RAM which stands for Random Access Memory Random access means this you can go to any part of memory you like directly without having to start at the lowest address and working your way through Check this by going Straight up to address 0123 and looking at its contents key AD 0 1 2 3 then address 0000 key AD 0 0 00 which should still contain the value 44 that we put there Hexadecimal Numbers Now that you re back at address 0000 let s step through several locations using the key Don t worry about contents too much 0001 will still contain you
37. As soon as the write occurs counting at the specified rate begins The timer counts down at the clock frequency divided by the divide rate The current timer count may be read at any time At the user s option the timer may be programmed to generate an interrupt when the counter counts down past zero When a count of zero is passed the divide rate is automatically set to 1 and the counter continues to count down at the clock rate starting at a count of FF 1 in two s comple ment arithmetic This allows the user to determine how many clock cycles have passed since the timer reached a count of zero Since the counter never stops continued counting down will reach OO again then FF and the count will continue 2 Operation Loading the timer The divide rate and interrupt option enable disable are programmed by decoding the least significant address bits The Starting count for the timer is determined by the value written to that address Writing to Address Sets Divide Ratio To Interrupt Capability Is 170h 1 Disabled 1705 8 Disabled 1706 64 Disabled 1707 1024 a Disabled 170C 1 Enabled 170D 8 Enabled 170E 64 Enabled 170F 1024 Enabled b Determining the timer status After timing has begun reading address location 1707 will provide the timer status If the counter has passed the count of zero bit 7 will be set to 1 otherwise bit 7 and all other bits in location 1707 will be zero This allows a program to watch
38. BEQ LEFT YES GO LEFT CMP 03 KEY 3 i BEQ RT YES GO RIGHT BNE TOGG NOT A VALID KEY ASL 00 7 SHIFT CRAFT LEFT LDA 40 LEFT HAND EDGE 00E7 BNE TOGG NO RETURN LSR 00E7 SHIFT RIGHT BNE TOGG NOT RIGHT SIDE RETURN SEC OFF EDGE RETURN TO ROL 00E7 RIGHT SIDE BNE TOGG RETURN XXX DISPLAY SUBROUTINE 7 PORT TO OUTPUT STA 1741 LDA 09 INIT DIGIT STA 1742 LDA 20 BIT POSITION TO STA 00 0 6TH BIT LDY 02 3 BYTES LDA 00 ZERO CHARACTER STA 00 1 26 025C B1 E2 BYTE LDA 00 2 BYTE 025 25 EO AND 00E0 NTH BIT 1 0260 FO 07 BEQ NOBT NO SKIP 0262 A5 El LDA 00 1 YES UPDATE 0264 19 E4 00 ORA 00E5 Y CHARACTER 0267 85 El STA 00 1 0269 88 DEY 026A 10 FO BPL BYTE NEXT BYTE 026C AS El LDA 00 1 CHAR IN ACCUM 026E C4 E8 00 SHIP ON 0270 00 08 BNE DIGT NO SKIP 0272 EO LDY 00 0 IS THIS SHIP 0274 Ch E7 CPY 00E7 DIGIT 0276 00 02 BNE DIGT NO SKIP 0278 09 08 ORA 508 ADD IN SHIP 027A 8D 40 17 DIGT STA 1750 LIGHT DIGIT 0270 9 30 530 DELAY CDIGIT 027F 80 06 17 STA 1706 0282 AD 07 17 DELA LDA 1707 TIME UP 0285 0 FB BEQ DELA NO 0287 9 00 LDA 500 TURN OFF SEGMENTS 0289 8D 40 17 STA 1740 028C EE 42 17 INC 1742 SHIFT TO NEXT DIGIT 028F EE 42 17 INC 1742 0292 46 EO LSR 00 0 SHIFT TO NEXT BIT 0294 DO CO BNE BIT MORE BITS 0296 60 i RTS KAKE CHECK SUBROUTINE 0297 C6 E9 CHEK DEC 00E9 DEC TIMES THRU COUNT 0299 DO BNE MORE SKIP IF NOT 48TH
39. BVC 2NDC UNCOND JUMP 63 FARMER BROWN by Jim Butterfield You are farmer Brown You are growing a beautiful crop of corn A But the following animals try to come and steal your corn SUCH 3 Ces Ant Bird Cow Dog Elephant Fox As soon as you see one of these animals coming for your corn you can scare it away by calling its name Press the button with the first letter of the animal s name So you would press A to shoo away an ant B to shoo away a bird and so on If you press the right button the animal will go back If you press the wrong button it will think you mean somebody else and keep coming for your corn And when all your corn is gone KIM will show and the game over The animal won t shoo unless it has completely entered the display Speed of the animals can be adjusted by changing the contents of location 026A a 0200 A2 OD START LIX 13 0202 86 6E STX CORN bushels of corn to start 020 9 00 LDA 0 clear the window 0206 95 60 SLOOP STA WINDOW X 0208 DEX 0209 10 FB BPL SLOOP 0208 A2 OB TEST IDX 11 is window empty 020D B5 60 TLOOP LDA WINDOW X 020 DO 3B BNE CONTIN no keep going 0211 CA DEX 0212 10 F9 BPL TLOOP 021 6 6D INC GOT yes make new animal 0216 A5 6C LDA FLAG 0218 FO 09 BEQ MORE did last animal get in 021A C6 6D DEC 021C C6 6E DEC CORN take away some corn 021E DO 03 BNE MORE any left 0220 hC 25 19 JMP DONE no end of game 0223 AD Ol 17
40. JUMP TO START LOCATION EA EA EA NOP S XXXXX SUBROUTINE LOAD BLINK 9 20 LDA 5520 BLINK FLAG 15 BF ORA 505 ADD IT TO THE 95 BF STA SQST X INDEXED BYTE 60 RTS EA EA NOP S TABLE SEGMENTS 77 08 08 08 40 40 40 01 01 01 TABLE ROWS 01 04 07 01 02 03 01 03 02 05 08 04 05 06 05 05 03 06 09 07 08 09 09 07 XXX SUBROUTINE PLAY 2 85 D9 GPLA STA TEMP SAVE THE ACCUMULATOR A2 09 LDX 09 FOR TESTING A5 09 GET IT BACK 35 DB AND PS X MASK THE STATUS BYTE 24 D9 BIT TEMP CHECK FOR BIT ON 00 03 BNE OUT GOT IT DONE CA DEX DO F5 BNE GPLP NOPE KEEP TRYING 60 OUT RTS SQUARE VALUE IN X 0 NO MATCH SUBROUTINE TEST AND INCREMENT 2 B5 BF LDA SS X DO 02 BNE OUT COUNT OPEN SQUARES F6 DB INC PS X ONLY 60 OUT RTS 77 5 SUBROUTINE UPDATE 0147 95 UPDA STA SS X FLAG THE SQUARE 0149 AO 08 LDY 08 024B 9 00 UPLP LDA 5500 CLEAR THE REGISTER 0140 99 C8 00 STA RS Y 0150 BE 17 01 LDX SQ1 Y THEN LOAD 0153 20 8A 03 JSR RSADD CURRENT STATUS 0156 BE 1F 01 LDX SQ2 Y VALUES 0159 20 8 03 JSR RSADD 015C 27 01 LDX SQ3 Y 015F 20 8A 03 JSR RSADD 0162 88 DEY 0163 DO E6 BNE UPLP LOOP TILL DONE 0165 60 RTS 0200 9 00 NEW LDA 00 0202 A2 1D LDX 1D CLEAR REGISTERS 0204 95 B4 INLP STA 00B4 X P 0206 CA DEX b 0207 00 FB BNE INLP 0209 A9 05 LDA 8505 INITALIZE ORDER OF 0208 85 STA 0
41. LDA 00E2 LAST CHARACTER 0232 C9 1A CMP 1A 0234 F0 20 BEQ DEBO YES GO READOUT 0236 BD EB 02 LDA 02EB X GET CODE CHARACTER 0239 85 DF STA 00DF TEMPORARY STORE 023B 06 DF BITS ASL 00DF SHIFT 023D FO D4 BEQ CHAR EMPTY GET NEXT CHAR 023F BO OD BCS DASH IF CARRY SET SEND DASH 0241 A2 01 LOX 8501 ELSE SEND DOT 0243 20 82 02 JSR MARK 0246 A2 01 SPAC LDX 01 THEN SPACE 0248 20 A0 02 JSR SPACE 0248 18 CLC 024C 90 ED BITS UNCOND JUMP 024 A2 03 DASH LDX 8503 LENGTH 0250 20 82 02 JSR MARK SEND A DASH 0253 18 CLC 0254 90 FO BCC SPAC UNCOND JUMP 0256 20 8E 1E DEBO JSR DEBOUNCE KEY 0259 20 B1 02 JSR DISP 025C 00 F8 BNE DEBO WAIT FOR KEY RELEASE 025E 20 B1 02 WAIT JSR DISP 0261 FO FB BEQ WAIT WAIT FOR KEY DOWN 0263 18 CLC 0264 5 LDA 00E4 UPDATE POINTER 0266 69 05 ADC 8505 POINT AT NEXT GROUP 0268 85 E4 STA 00E4 026A 0 04 LDY 4504 LOAD WINDOWS 00 8 026C B1 WIND LDA CO0E4 Y 00 WITH CONVERSIONS 026E 99 E8 00 STA 00E8 Y FOR DISPLAY 0271 88 DEY 0272 10 F8 BPL WIND 0274 C6 DEC 00E3 LAST GROUP 0276 DO DE BNE DEBO NO GET ANOTHER I 0278 A9 36 LDA 8536 REINITILIZE POINTER 027A 85 E4 STA 00E4 TO RUN THRU GROUPS AGAIN 027C A9 05 LDA 05 Ge c 85 STA 00E3 0280 D4 BNE DEBO UNCOND JUMP ANNAM MARK SUBROUT INE 0282 86 DD STX 0000 TEMP STORE 0284 E6 TIMM LDA 00 SPEED BYTE 0286 8 07 17 STA 1707 START TIMER 0289 AQ 01 LDA 8501
42. MAY BECOME UNPOOPED DEPENDING ON RANDOM NUMBER NOT POOPED BUT MAY BECOME POOPED DEPENDING ON RANDOM NUMBER IF POOPED SET POOP FLAG KEY FROM KEYBOARD INIT Y TO MAX HORSE INDEX IN X MASK CIS HORSE WHIPPED NO NOT BEING WHIPPED WHIPPED Y MADE SMALLER CHANGE SIGN IF POOPED EXC OR WITH 00 OR FF SAVE SPEED UPDATE GET A RANDOM NUMBER e LOWEST BIT OF COMBINE WHIP UPDATE RAND 0 OR 1 amp CARRY HORSE INDEX IN X HORSES SPEED ADDED IN SAVE NEW SPEED ALSO IN WINDOW COUNTER LOOP t RANDOM NUMBER SUBROUTINE 02C5 38 RAND SEC 02C6 92 LDA 0092 FROM J BUTTERFIELD 02C8 65 95 ADC 0095 KIM USER NOTES 51 02CA 65 96 ADC 0096 PAGE 4 02cc 85 91 STA 0091 02 2 04 LDX 504 0200 B5 91 LDA 0091 X 02D2 95 92 STA 0092 X 02D4 CA DEX 02D5 10 F9 BPL MOVE 0207 60 RTS gt TABLES HORSERACE 0208 00 80 80 80 80 80 80 80 02 0 FF FF FF 80 80 80 00 00 00 80 80 80 08 FE BF F7 02F0 01 02 04 0200 08 A2 13 BD D9 02 95 7C CA 10 F8 AQ 7F 8D 41 17 0210 0 00 A2 09 B9 7C 00 84 FC 20 C8 CO 06 90 0220 F3 20 3D 1F 8F 30 E3 A2 03 CA 30 DE 06 86 00 0230 F9 86 99 99 B6 83 BG ED 02 35 7C 95 7C E8 96 ME 0240 83 B9 ED 02 49 FF 15 7C 95 7C EO 05 30 2B DO 06 0250 A5 8F FO 1B DO 23 A2 02 38 B5 83 9 06 95 83 CA 0260 10 F6 A2 06 B5 7C 95 76 A9 80 95 7C CA DO F5 C6 0270 8F DO 06 81 09 06 85 81 B9 89 00 FO 20 C5 0280 0
43. MORE LDA TIMER random value 0226 ISRA ISRA LSRA 0 generate 0229 hA hA LSRA ISRA new random animal 022B C9 06 6 6 types of animal 022D 90 02 BCC MAKE 022F 29 03 AND 903 0231 18 MAKE CIC 0232 animal type to X 0233 69 OA ADC 0A key type A to F 64 0235 6F STA KEY 0237 BD 02 LDA INDEX X animal picture address 023A 85 70 STA POINL to indirect pointer 023C A9 02 LDA 2 0235 85 71 STA POINH 0240 AO 05 LDY 45 six locations to move 9 0242 Bl 70 ALOOP LDA POINL Y from picture 02 99 66 00 STA WINGS wings 0217 88 DEY 0248 10 F8 BPL ALOOP O2hA 8 6C STY FIAG flag FF animal coming O2hC 2 05 CONTIN LDX 5 test 024 BS 66 CLOOP LDA WINGS X is animal out of wings 0250 DO 13 BNE NOKEY no ignore keyboard 0252 CA DEX 0253 10 F9 BPL CLOOP 0255 20 ho 1F JSR KEYIN 4 0258 20 6A 1F JSR GETKEY 025B C5 6F CMP KEY right anim al named 025D DO 06 BNE NOKEY no ignore key 025 5 6C LDA FLAG 0261 10 02 BPL NOKEY animal retreating 0263 E6 6C INC FLAG make animal retreat 0265 C6 72 NOKEY DEC DELAY wait a while 0267 DO 1 BNE NOMOVE before moving animal 0269 A9 20 LDA 20 speed control value 026B 85 72 STA DEIAY 2059 026 A5 6C LDA FIAG move animal which way 026 30 OD BMI COMING left 0271 A LDX 10 right 0273 BS SA RLOOP LDA WINDOW 6 X 0275 95 5B STA WINDOW 5 X 0277 CA DEX 0278 DO F9 BNE RLOOP 027A 86 SA ST
44. PAO TO OUTPUT 0288 8D 01 17 STA 1701 028E EE 00 17 TOGG INC 1700 TOGGLE PAO 0291 E7 LDX 00E7 DETERMINE FREQ 0293 CA FREQ DEX 0294 DO FD BNE FREQ 0296 2C 07 17 BIT 1707 TIME UP 7 0299 10 F3 BPL TOGG NO 029B C6 DD DEC 00DD DETERMINE MARK LENGTH 0290 00 E5 BNE TIMM 029F 60 RTS SPACE SUBROUTINE XX 02A0 86 DD DISP STX 0600 TEMP STORE 02 2 A5 E6 TIMS LDA 00 SPEED BYTE 02A4 8007 17 STA 1707 START TIMER 02 7 2 07 17 HOLD BIT 1707 DONE 02AA 10 FB BPL HOLD NO 02AC C6 DD DEC 0000 FULL TIME UP 02 DO F2 BNE TIMS NO 0280 60 RTS 57 Display Subroutine 0281 A9 7 DISP LDA 7F change segments 02B3 8D 41 17 STA PADD to outputs 02B6 AO 00 LDY 0 init recall index 02B8 A2 09 LDX 9 init digit number 02BA B9 E8 00 SIX LDA 00 8 get character 02BD 84 FC STY YSAV save Y O2BF 20 4E 1 JSR DISPL display character Q2C2 C8 INY set up for next char 02C3 CO 06 CPY 6 6 chars displayed 02C5 90 F3 BCC SIX no do more 02C7 20 3D IF JSR KEYTS key down 02CA 60 RTS Random Number Subroutine 02 38 DS8 RAND SEC CLD 02CD A5 Dl LDA 1 from Kim User Notes 02 65 D4 ADC RND 3 vol 1 1 0201 65 D5 ADC RND 4 J Butterfield 02D3 85 DO STA RND 02D5 A2 04 LDX 4 02D7 B5 DO ROLL LDA RND X 02D9 95 Dl STA RND 1 X 02DB CA DEX 02DC 10 F9 BPL ROLL 02DE 60 RTS Initialization Values 02DF 00 05 36 03 33 64 CO CO CO CO CO 00 Morse Code Characters
45. STA LDA STA LDA STA LDX LDA INH 16 sync SYN RDCHT INH TST 52 TST RDBYT INH SFE neg 2 RDBYT 1 ADDR 2 RDCHT S2F eot WIND PACKT ELNK error DUBL POINT X CHK POINT OVER POINT 1 BYTE RDBYT CHKHI ELNK error RDBYT CHKSUM START 65 SCANDS FLSH display SA ID GETKEY GANG A START NPUL GANG TIMG 1 27 register mask GANG SBF PBDD 64 16 sync 0080 A2 64 LDX 8564 send 100 008F A9 16 LDA 16 sync 0091 20 61 01 JSR HIC 0094 A9 2A 2 start char 0096 20 88 01 JSR OUTCHT 0099 A5 F9 LDA INH write ID 009B 20 70 01 JSR OUTBT 009E A5 FA LDA POINTL start adds 00A0 20 70 01 JSR OUTBT 00A3 A5 FB LDA POINTH 00A5 20 70 01 JSR OUTBT 00A8 AO 00 DATA LDY 0 00AA Bl E2 LDA POINT2 Y 00AC 20 70 01 JSR OUTBT write data 00AF E6 E2 INC POINT2 0081 DO 02 BNE SAMP next addrs 00B3 E6 INC 2 00B5 A5 E2 SAMP LDA POINT2 00B7 C5 EO CMP POINT 00B9 A5 E3 LDA 2 1 00 E5 El SBC 1 OOBD 90 E9 BCC DATA more data O0BF A9 2F LDA 2 eot 00 1 20 88 01 JSR OUTCHT 00C4 A5 F7 LDA CHKHI checksum 00C6 20 70 0 JSR OUTBT 00C9 5 F6 LDA CHKSUM 00CB 4C 54 01 JMP EXIT EE 00DO 4C 29 19 JMP LOADT9 FFFF option 00E2 00 02 00 02 data area set as desired kkkkkk Hox Dump Super Dupe ooog 2 03 BS E2 95 CA 10 FO A9 00 85 F6 85 F7 DS 0010 9 07 8D 42 17 20 41 1A 46 F9 05 F9 85
46. STARTED AT 0200 THE PROGRAM WILL SEND 5 LETTER CODE GROUPS CINTERNATIONAL MORSE OVER THE SPEAKER THE CODE GROUPS WILL CONSIST OF RANDOM CHARACTERS INCLUDING A Z 0 9 A PERIOD COMMA QUESTION MARK AND EQUAL SIGN AFTER THIS TRANSMISSION YOUR RECEPTION CAN BE CHECKED BECAUSE THE GROUPS SENT WILL BE SHOWN ON THE DISPLAY PRESSING ANY KEY WILL CAUSE THE NEXT GROUP TO BE DISPLAYED LIMITATIONS IMPOSED BY THE 7 SEGMENT DISPLAYS MAKE SOME CHARACTERS PRETTY STRANGE AND THERE IS SOME REDUNDANCY BUT BY SLOWING THE TRANSMISSION YOU SHOULD BE ABLE TO FIGURE OUT WHAT EACH CHARACTER IS 0200 2 0C LDX 0C INITIALIZATION 0202 BD DF 02 INIT LDA 02DF X 12 VALUES ARE LOADED 0205 95 STA 00E2 X FROM 00E2 ON UP 0207 CA DEX 0208 10 8 BPL INIT 020A A2 ut GRUP LDX 04 CSPACE LENGTH 020C 20 0 02 JSR SPACE SPACE FOR ANOTHER GROUP 020F 9 06 LDA 06 GROUP SIZE 5 CHAR 0211 85 EO STA 00E0 0213 C6 EO CHAR DEC 00E0 NEXT CHAR IN GROUP 0215 FO BEQ GRUP FINISHED GET NEW GROUP 0217 A2 03 LDX 4503 CSPACE LENGTH 0219 20 AO 02 JSR SPACE SPACE BETWEEN CHAR 021C 20 CB 02 NUMB JSR RAND GET A RANDOM 021F 29 3F AND 3F MAKE SURE POSITIVE 0221 C9 28 28 LESS THAN 41 DECIMAL 0223 10 F7 BPL NUMB NO GET ANOTHER 0225 AA TAX USE AS INDEX 0226 BD 13 03 LDA 0313 X GET DISPLAY CONVERSION 0229 E2 LDY 00E2 CHAR INDEX IN Y 0228 99 38 03 STA 023B Y STORE CONVERSION 022E E6 E2 INC 00E2 INDEX UP ONE 0230 A5 E2
47. TEST KEYBOARD O2CE AO 13 SHOW 13 02DO A2 05 LDX 5 0202 A9 7 LDA 7 0204 8D 41 17 STA PADD 02D7 B5 Ok LITE LDA WINDOW X 0209 8D 40 17 STA SAD O2DC 8C 42 17 STY SBD O2DF E6 11 P02 INC MOD pause loop 02 1 DO FC BNE POZ 02 88 DEY O2E4 88 DEY O2E5 CA DEX 02 10 EF BPL LITE 02 8 20 40 1 JSR KEYIN 02 60 RTS END Program notes 3 Program enforces a pause of about h seconds after displaying counts or answer This guards against display being missed due to bounce hasty keying 2 After count displayed or at end of game s user can blank display if desired by pressing GO or any numeric key Game operation is not affected but user may feel it separates games better 31 3 When digit from the user s guess is matched it is destroyed so that it will not be matched again There are two significantly different types of destruction however at 27D and 29D the test at label STEP is sensitive to which one is used LINKAGES TO KIM MONITOR KEYIN 1F40 GETKEY 1F6A TABLE 1FE7 PADD 1741 SBD 1742 SAD 1740 WORK AREAS 0000 SECRET 4 computer s secret code 0004 WINDOW 6 display window 000A INPUT 4 layer s input area 000 EXACT 1 of exact matches 000 MATCH 1 of other matches 0010 POINTR 1 digit being input 0011 MOD 1 divisor delay flag 0012 RND 6 random number series 0018 COUNT 1 number of guesses left
48. TIME 0298 9 30 520 TIMES THRU COUNT 029D 85 E9 STA 00 9 029F TXA SAVE X 0240 48 X PHA 02A1 A2 FD LDX FD NEGATIVE 3 IN X 02A3 F8 SED DECIMAL MODE 02A4 38 SEC ADD ONE 02A5 B5 FC NXTB LDA 00 INCREMENT COUNTER 02A7 69 00 ADC 8500 WHICH IS MADE OF BYTES 02A9 95 FC STA 00 IN DISPLAY AREA 00 9 02AB 8 INX 00 02 00 F7 02 08 CLD 02AF 68 PLA RETURN X 02B0 TAX 0281 E6 E2 INC 00E2 SET UP FOR NEXT GROUP 0283 E2 LDA 00 2 BYTES 0285 C9 30 MORE 530 ALL GROUPS FINISHED 0287 FO 09 BEQ RECY YES RECYCLE ASTR FIELD 0289 0 00 MATCH LDY 500 SHIP ASTEROID MATCH 02BB AS E7 LDA 00E7 LOAD CRAFT POSITION 0280 31 E2 AND 00E2 Y AND WITH ASTEROID BYTE 02BF DO 07 FIN IF MATCH YOU VE HAD IT 02Cl 60 RTS EXIT MATCH SUBROUTINE eee 02C2 AQ 00 RECY LDA 8500 GO THRU ASTEROID FIELD 02C4 85 STA 00 2 AGAIN 02C6 FO F1 BEQ MATCH UNCONDITIONAL BRANCH 4 0268 20 1F FIN JSR SCANDS DISPLAY COUNT 02CB 4C C8 02 JMP FIN CONTINUOUSLY 02 05 LOW POINTER ASTEROID BELT 02CF 02 HIGH POINTER ASTEROID BELT 02D0 08 MASK BOTTOM SEGMENT 02D1 40 MASK MIDDLE SEGMENT 0202 01 MASK TOP SEGMENT 0203 04 CRAFT POSITION 0204 FF FLAG CSHIP ON ASTEROID FIELD 0205 00 00 00 04 00 08 00 06 12 00 11 00 05 00 2C 00 1 02 5 16 00 29 00 16 00 28 00 26 00 19 00 17 00 38 00 02F5 2 00 09 00 18 00 24
49. TRIP triple length BEQ BRAN branch INC POINT mving right along BNE INEX esto next op code INC POINT 1 DEY BNE SKIP BEQ START length 3 or illegal INY START 2 illegal end to BRK halt INY set Y to 1 LDA POINT Y lo order operand TAX essinto X reg INY 2 LDA POINT Y hi order operand JSR ADJUST change address maybe STA POINT Y eeeand put it back DEY Y 1 TXA STA POINT Y eeealso hi order LDY 3 Y 3 BPL SKIP branch check to and from address INY 1 LDX POINT from addrs lo order LDA POINT 1 eoe amp hi order JSR ADJUST change maybe STX ALOC save lo order only LDX FF flag for back branches LDA POINT Y get relative branch CLC ADC 2 adjust the offset BMI OVER backwards branch INX nope STX LIMIT CLC ADC POINT calculate to lo order TAX ee sand put in X LDA LIMIT or FF ADC POINT 1 to hi order JSR ADJUST change maybe DEX readjust the offset DEX TXA SEC SBC ALOC recalculate relative branch STA and re insert INY Y 2 BPL SKIP 132 examine address and adjust maybe 0179 C5 E7 ADJUST CMP PAGLIM 017B BO l1 BCS OUT too high 017D C5 ED BOUND 1 17 DO 02 BNE TES2 hi order i 0181 Eh EC CPX BOUND lo order 0183 90 09 TES BCC OUT too low 0185 48 PHA stack hi order 0186 8A 0187 18 CLC 0188 65 ADC ADJUST adjust lo order O18A AA TAX 0188 68 PLA unstack hi order 018C 65 E9 ADC ADJST 1 and adjust 018 60 OUT RTS t
50. a Computer but If you re set up at location 0200 and your SST switch is on hit the GO button once The display will show 0202 That means instruction at 0200 completed ready to do the one at 0202 Okay let s check everything in sight The first instruction was to load the A register right Enter address 00F3 and check that its contents which correspond to the contents of A are indeed the value from address 0010 If you like look at 0010 and confirm that it hasn t changed Now for a clever KIM touch If you re ready to proceed with the next instruction hit PC for Program Counter and you ll find yourself back at address 0202 ready to perform the next instruction You ve executed one instruction performed one program Step Remember this No matter how complex the program it always operates one simple step at a time And now you know how to check out each step individually Hit GO and execute one more instruction Check it out remember that you ll find X at address 00 5 4 From this point find your own way through the last two instructions Don t bother about the BRK Break it just stops the program As the two registers are stored you ll want to check that the memory addresses have been changed as expected Summary The most important things that you ve learned about coding are the BRK code 00 command stops the program the SST switch causes a single instruction to be executed the
51. addressing mode called RELATIVE addressing All branches use it it s worth reading up on Exercises l Can you change the program to place value 55 in the above locations 2 Can you change the program to place value 00 in locations 0030 to 0037 3 Can you change the program to place value FF in locations 00 0 to OOBF 15 INTERLUDE PROGRAM TESTING You ve met one very powerful tool for checking out programs the Single Step mode of operation Let s review it and talk about a few others The SST mode is especially useful because you can pause between instructions and look at memory or registers The register values are copied into memory locations from OOEF to 00 5 and while they are not real registers just copies they are just as good for testing purposes Not only can you look at them you can change them to new values This ability to change a register can be handy in solving the what if type of question or shortening testing of a loop For example if you are single stepping through mini program B and you don t want to go around the loop a full ten times you might use this trick Go around a couple of times to get the loop started and then change X 00F5 to a much lower value say 1 or 2 Go back to single stepping couple more turns around the loop and you re out Using this method you won t have set the whole ten locations to zero of course But you will see that the loop itsel
52. if PAO OD 29 7F AND 7F through PA6 contain all OF C9 7F CMP 7F 1 s closed switches 11 FO F7 BEQ OA All are closed go to OA 13 A9 80 LDA 80 At least one switch open 15 8D OO 17 STA 1700 alarm 18 4C 13 OO JMP 0013 Stay in the loop Now let s look at the simple circuit to operate our burglar alarm We connect PAO through PA6 pins directly to the switches a switch is closed then the voltage at that port is O Volts ground as soon as the switch opens an internal resistor located on the KIM board pulls the port to the positive voltage of 5 Volts All ports except PB7 are equipped with built in resis tors called pull up resistors connected to which set voltage at a port to Vog when the port is in the input mode and is not connected to ground the output port PA7 is connected to the base of an amplifying tran sistor which drives a relay to operate an alarm bell The transistor is necessary because the maximum availa bie current of each KIM port is only on the order of 1 mA This current would not be sufficient to drive a relay directly 159 ALARM BURG EAR ALARM CIRCUIT SWITCHES Multiple Drives Now suppose you want KIM to drive several devices rather than a single one For example you may want to connect a 3 x 3 matrix of LED lights to the A and B ports to play tic tac toe The simplest way to do this is by using one of the inexpensive digit driving ICs such as 75492 used in many
53. initially 800 pounds will be shown in the first four digits of the KIM display The last two digits of the KIM display always show your rate of descent or ascent restores altitude Set your thrust by pressing buttons 1 through 9 Warning button 0 turns your motor off and it will not reignite thrust of 1 minimum burns very little fuel but gravity will be pulling your craft down faster qnd faster A thrust of 9 maximum overcomes gravity and reduces your rate of descent very sharply A thrust of 5 exactly counterbalances gravity you will continue to descend or ascend at a constant rate If you run out of fuel your thrust controls will become inoperative safe landing is considered to be one where you land at a descent rate of 5 or less After you land your thrust controls will be inoperative since the motor is automatically turned off but you can still press to look at your fuel Pressing GO starts a new flight 2 Exe 152277 Suggestions for a safe flight 1 Conserve fuel at the beginning by pressing 1 You will begin to pick up speed downwards 2 When your rate of descent gets up to the 90 s you re falling fast enough Press 5 to steady the rate 3 When your altitude reaches about 1500 feet you ll f need slow down Press 9 and slow down fast 4 When your rate of descent has dropped to 15 to 20 steady the craft by pressing 5 or 6 Now you r
54. internal registers can be viewed BUT YOU MUST SET YOUR VECTORS PROPERLY see the beginning of this section OR NONE OF THE ABOVE WILL WORK A complete list of the register image addresses can be found in the KIM User Guide on page 39 Fig 3 13 when you need it From here on you don t have to take anybody s word for any KIM operation You can go to your KIM set SST and try it for yourself Exercises 1 Can you change the program so that it swaps the contents of locations 0020 and 0021 2 Billy Beginner wrote the following program to swap the contents of locations 0010 and 0011 0200 A5 10 START LDA 10 put 0010 into 0202 85 11 STA 11 store to 0011 0204 11 LDX 11 put 0011 into X 0206 86 10 STX 10 store X to 0010 0208 00 BRK stop It didn t work Can you see why 3 Can you write a program to take the contents of address 0010 and place the same value in locations 0011 0012 and 0013 13 MINI PROGRAM B Setting many locations to zero Here s the program 0200 A9 00 START 0 value 0 into 0202 A2 09 LDX 9 start X at 9 0204 95 30 LOOP STA 30 X zero into 0030 0206 CA DEX decrease X by 1 0207 10 FB BPL LOOP back if X positv 0209 00 BRK stop the program This program when you load and run it will set the value of the ten locations from 0030 to 0039 to zero We can t give you a whole programming course here Hopefully you ll use the Programming Manual and the single step fe
55. lamp or appliance of up to 600 Watts AC INTERFACE 46 eoe 4 6 e v J e 5 TO LIGHT OR APPLIANCE 7 1 68 02000 i SCI4I M 75992 RADIO SHACK 276 1080 LAMP _ 6205 ans R 5 216 140 1 2 TO nov OUTLET 161 os rena taces a lad k WS KIM versus Hardwired Logic We have showed you how KIM can control relays lights and AC operated devices but these applications hardly tap KIM s capabilities With the same methods you can also switch tracks on a model train layout control traffic lights and keep your fans and air conditioners going The beauty of performing such tasks with a com puter rather than with hardwired relay logic is that logical responses and changes in rules can easily be implemented by changing a few statements in your prog ram redesign of hardwired circuit on the other hand is always difficult time consuming frequently impossible without starting your design from scratch D A and A D Converters So far we have discussed on off type controls such as switches or relays which are either open or closed However there are many areas where a proportional control with shades of gray instead of black or white would be more desirable For example if you are inte rested in electronic music you would like to shape the electric signals driving your amplifiers and speakers into sinusoids triangles and seesaws to mimic variou
56. on the size of board you buy A quick scan th rough a recent hobbyist publication should give you a rough idea of what to expect How Much Do You Need It depends primarily on what you want to do Quite a bit can be done with just the 1K on the basic KIM 1 Even if you add a terminal this 1K should be adequate for small games etc written in assembly language If you want to use a lot of text or go to a higher level language like Basic you will have to expand Exactly how much you need to expand depends on how elaborate your software is Motherboards If you want to add more than just one board to the expansion connector of your KIM you should start thinking in terms of a motherboard A motherboard is a group of sockets connected in parallel Buffering is also usually provided so the extra boards don t load the busses If you buy a motherboard specifically for the KIM 1 it will also have provision for letting KIM know when one of its boards is being addressed This is so the decoding present on the KIM will be disengaged and not conflict with decoding on the expansion boards Standard Busses The largest number of boards made for hobbyist use have a 100 pin configuration that plugs into the so called S 100 bus MOS Technology also makes a motherboard for KIM with yet another bus It should be possible to hook the KIM to motherboards made for other 8 bit machines too One group is getting together an expansion board
57. put in WINDOW LDY 51 ripple 52 cards STY DPT set full deck JSR LIGHT illuminate display SEC LDA Generate ADC RND 2 new ADC RND 5 random STA RND number LDX 4 LDA RND X move over STA 1 the random DEX seed numbers BPL RMOV AND 3F Strip to 0 63 range CMP 52 Over 51 BCS SHLP yes try new number each card into random slot TAX LDA DECK Y get next card PHA save it LDA DECK X get random card STA DECK Y into position N PLA and the original card STA DECK X into the random slot DEY next in sequence BPL SHLP bck for next card ready to accept bet NOSHUF LDY 300 set up BET msg 03 03 03 BETIN JSR FILL put in WINDOW LDA AMT display balance JSR NUMDIS put in WINDOW JSR LIGHT illuminate display CMP 10 not key 0 to 9 BCS BETIN nope ignore TAX STX BET Store bet amount DEX BMI BETIN zero bet CPX AMT sufficient funds BCS BETIN no refuse bet bet accepted deal CLOOP LDX 11 Clean WINDOW and LDA 0 card counters STA WINDOW X DEX CLOOP 41 here come the cards 0276 20 78 03 JSR YOU one for you 0279 20 03 JSR MB amp one for me 027 20 78 03 JSR YOU another for you 027F 20 6h 03 JSR CARD put my second card 0282 86 7A STX HOLE the hole 028 20 28 03 JSR WLITE wait a moment deal complete wait for Hit or Stand 0287 20 30 03 TRY JSR LIGHT 028A AA TAX DEX key input 028C 30 11 BMI HOLD zero for S
58. retrieval system without permission in writing from the copyright holder application for which should be addressed to the Publisher Printed in the United States of America 1 2 3 4 5 6 7 8 9 PRINTING 78 79 BO 81 82 83 84 85 86 YEAR THIS BOOK YOU LL FIND A BEGINNER S GUIDE TO KIM PROGRAMMING 5 guidelines which take the absolute beginner step by step through the fundamentals of understanding and writing programs RECREATIONAL PROGRAMS 23 dozens of programs including games diversions and educational programs fully detailed so that you can learn from the programming techniques as well as have fun All programs run on the basic KIM 1 system DIAGNOSTIC AND UTILITY PROGRAMS 114 to help you test your KIM computer to help you test other devices such as cassette recorders and to make your KIM a more powerful machine EXPANDING YOUR KIM 143 guidelines on how to expand your KIM from the basic small but powerful KIM 1 system to a huge and super powerful machine understanding the jargon seeing what s available in both hardware and software CONNECTING TO THE WORLD 155 an introduction to the methods by which KIM can read or sense other devices and can in turn control other mechanisms POTPOURRI 166 other useful pieces of information about your KIM system reference material hints etc Acknowledgments Thanks to all who have supported the KIM 1 6502
59. save register LDY 13 LDX 5 6 digits to show LDA 7 STA PADD set directional reg DIGIT LDA WINDOW X STA SAD character segments STY SBD character ID WAIT INC PAUSE 43 036C 036D 0377 0378 0378 0370 037 0381 0383 0385 0387 0389 0388 038D 038E 038F 0392 0394 0396 0398 039A 0396 039 03A0 03A2 03A4 0345 BE CB 64 96 8F 10 02 98 F8 97 97 1F LF 00 03 03 03 03 fill BUST FILL FILLIT deal CARD card YOU YOVER card MOVER BNE WAIT wait loop DEY DEY DEX BPL DIGIT JSR KEYIN switch Dir Reg JSR GETKEY test keyboard LDY YSAV restore Y value RTS WINDOW with BUST or other message LDY BST 300 STY POINTR LDY 5 six digits to move LDA POINTR Y load a digit STA WINDOW put in window DEY BPL FILLIT RTS a card cale value amp segments LDX DPT Pointer in deck DEC DPT Move pointer LDA DECK X Get the card LSRA LSRA Drop the suit TAX to 12 in X CLC no ace flag BNE NOTACE branch if not ace SEC ace flag LDA VALUE X value from table LDY SEGS X Segments from table RTS to player including display amp count JSR CARD deal card INC UCNT card count LDX UCNT use display pointer STY WINDOW 1 X put card in Wndw LDY 10 count for aces BCC YOVER no ace STY ace set 10 flag CLC SED ADC UTOT add points to STA UTOT point total CLD RTS to KIM including display amp count
60. signal your win with a line of dashes The computer won t limit your number of flips but try to get win in 6 moves or less By the way the computer fortids doing the same flip twice in succession so you can t back up a move 0200 E6 16 0202 20 80 0205 DO F9 0207 0208 A2 020A A9 020C 86 020 95 0210 0211 10 0213 38 0214 A5 0216 65 0218 65 021A 85 021C A2 0218 B5 0220 95 0222 CA 0223 10 0225 AO 0227 84 0229 A0 022B C5 022D 90 022F 5 0231 46 0233 88 0234 DO 0236 0237 0239 023 0230 10 02 023F A2 05 0241 Bh 18 0243 DO 0245 95 18 0247 C6 10 0259 10 C8 05 00 10 18 FB 13 16 17 12 oh 12 13 F9 Co 11 o6 11 02 11 11 F5 10 F1 iF START INC ZLOCP RAND RLP SET PASS TOP JSR BNE CLD LDX LDA STX STA DEX BPL SEC LDA ADC ADC STA LDX LDA STA DEX BPL RND 4 KEYIN START 5 0 POINTR WINDOW X ZLOCP RND 1 RND 4 RND 5 RND 4 RND X RND 1 X LDY Co STY LDY MOD 6 MOD PASS MOD MOD SET POINTR TABLE 10 Y TRY 5 WINDOW X TOP WINDOW X POINTR RAND 101 randomize Game by Bob Albrecht People s Computer Co set window to zeros hash in new random number move random string down one divide random 4 by 6 digits to F find an empty window and put the digit in 0245 FO B3 SLINK HEQ START link to start 0240 A2 05 WTEST L
61. that the maximum reach of a branch instruction is 127 locations forward 7F or 128 locations backward 80 you want a forward branch check that the calculated branch is in the range 01 to 7F Similarly be sure that a backward branch produces a value from 80 to FE In either case a value outside these limits means that your desired branch is out of reach 115 BROWSE Jim Butterfield Load BROWSE anywhere in memory it s fully relocatable start it uv and presto It doesn t seem to do anything BROWSE is mini Monitor that performs most of the functions of the regular KIM monitor but you ll find it handy for entering and proof reading programs Most of the keys work the same as usual but PC and DA are slightly different When you hit you go to the next address as usual but then you keep on going just entered Great for proofreading a program you ve It lets you browse through memory Hit PC and the program steps backwards so you can look at a value you ve just passed All other keys instantly freeze the browsing process you can hit AD or DA to stop on a given amp ddress or just enter a new address if you wish Key DA operates a little differently from the regular KIM function To enter data first set up the address before the one you want to change As you enter the data BROWSE will automatically step forward to the next address and then the next one and so
62. to add another instruction later if you need to Some programmers write their programs in sections and at first they put a BRK instruction between each section That way when they are testing the program will stop after each part and they can check to see that each part runs OK When they are finished testing they change the BRK s to NOP s and the program will run straight through The ST Stop Key When everything is under control in program testing you won t need the ST key But sometimes the program gets on you and the only way to find out what it s doing is to use this key Let s wreck mini program B by wiping out the DEX instruction We ll do this by replacing it with a SO write value EA into location 0206 What will happen When we run the program the X register will never change from its starting value of 9 because we don t have a DEX instruction the program will keep branching back to LOOP forever and it will never stop We ve created this situation artificially of course but it could have happened by oversight when we were writing the program 17 Set address 0200 SST off and hit GO Everything goes dead Our program is running but it will never stop Meanwhile the display is dark This time we know why it s happening But if we didn t how would we solve it Press ST stop and the computer will freeze The display will light showing the next instruction we were about to e
63. up and running Back To The Busses It s not manditory that a video board work off the serial ports There are boards made to plug into most standard motherboards These work off the data and address busses directly In many cases they include memory to hold the characters which looks just like any other memory to the processor This has the advantage that any character can be changed instantaneously board like this is undoubtedly going to require software to keep things organized and you ll have to provide programs written especially for KIM Hardware vs Software With the prices of memory continuing to drop it s becoming cheaper to replace many hardware functions with software In the case of video you can use software not only to keep track of what characters go where you can also use it to generate most of the display itself This tends to reduce the cost considerably Using this fact Don Lancaster describes a T V Typewritter addition to the KIM for 25 35 Kilobaud 6 June 77 or Popular Electronics July 77 and August 77 Buta word of caution You ll have to chop up your KIM a bit to implement this the project involves cutting a piece of KIM s printed circuit foil plus wiring in a whole bunch of new wires And while the changes don t affect KIM s operation you have to recognize that memory expansion becomes a different ball game Don uses the addresses from 2000 to EFFF and that means that you can t just a
64. with your controls and see over what range the pattern stays locked in The wider the range the better your cassette recorder 142 EXPANDING YOUR KIM EXPANDING YOUR KIM Games and di versions using the keyboard and display are fine Programming in assembly language can even be a lot of fun once you get over the first few hurdles But sooner or later you are going to get the urge to have your KIM act like the big machines What do you have to add on How much will it cost How much trouble is it going to be Let s look at a few of the options and you can decide for yourself Memory Expansion If you only had more memory you could do anything right Well not exactly but let s see what s involved in adding memory Computer buffs abreviate a thousand memory locations more or less with the letter K Your KIM 1 has a 1K block of RAM and 2K of ROM Provision is also built into the KIM 1 for easily adding an additional 4K of memory 4K Expansion If you want to add only 4K of memory it s not especially difficult An article in Kilobaud 4 April 77 gives instructions for adding one of the lower priced 4K RAM kits It is primarily a matter of connecting wires between the expansion connector on your KIM and the new board Depending on the size of your present power supply an additional supply may be required for the new board Further Expansion Adding more than 4K of memory 1 a bit more difficult Par
65. 0 ILLEGAL 22 52 BNE 2BYTE ALL LEFTOVERS 2 BYTES INC 00 FLIP BIT 0 LDA FF LOOP FOR 1 4 SEC STA 1707 LDA 00 BLINK ON OR OFF AND 01 BEQ FLASH2 0 0 BLINK OFF JSR SCAND BIT 0 1 BLINK ON BIT 1707 BMI FLASH BPL FLASHI INX INX CENTER CODE EOR 07 STA 00 SEE LOOP FOR EACH BYTE LDA POINTL Y CONVERT AND STORE PHA IN E6 EB LSR s LSR s TAY LDA TABLE Y STA 00E5 X INX PLA AND 0 TAY LDA TABLE Y STA 00E5 X INX INC OOEE CPX 00 BCC CONVRT K DOWN JSR DISP DISPLAY UNTIL ALL KEYS K UP BNE DOWN ARE UP JSR DISP DISPLAY AND GET KEY 125 037C 20 6A 1F 037F 0381 0383 0384 0386 0388 0389 038 038 038 0391 0393 0395 0397 0398 039A 039B 039E 03A0 03A2 03A4 03A6 03A8 03AB 03AD 03AF 03B1 03B4 03B6 03B8 03BA 03BD 03C0 03C1 03C3 0565 0500 0510 0320 0330 0340 0350 0360 0370 0580 0590 03A0 0380 03C0 C9 OR DO OE BA EO FF FO 20 68 85 FB 68 85 FA 4c 04 c9 DO OF A5 FA 90 F3 4C 3D 03 00 1F 1F PLUS STEP STEP 1 PC WINDOW DI DISP 1 JSR GETKE CMP S0B BNE PLUS TSX CPX SFF B BCKSTP Y IS PRESSED NO BRANCH a IS STACK EMPTY BEO WINDOW YES ACT LIKE PC PLA STA OOFB PLA STA OOFA NEWORD JMP INIT 450F BNE PC LDA 00 PHA LDA PHA 468 DEC BEQ BNE CMP BNE JSR
66. 018 001E 0020 0025 0025 0027 0028 0029 002B 002D 002F 0031 0033 0036 0038 0039 0058 003D 003E 0040 0042 0044 0045 0046 0047 ANOTHER CARD AT 0000 00 FB A2 35 86 92 94 92 00 FB A5 92 4C AD 04 DO 1C 17 AD 44 17 DO 06 A5 92 69 01 C5 92 90 07 FO 05 E5 92 4C 2B F5 93 FO 05 10 F8 C6 92 00 INIT INIT 1 INIT 2 NEWCRD RANDOM FASTER FIND FIND 1 UPDATE LDX LDX SEC SBC BEQ BPL STA DEC TXA LSR LSR TAY 48 PRESS ANY KEY TO GET EACH WILL APPEAR ONLY ONCE WHEN ALL CARDS HAVE BEEN DEALT THE PROGRAM MUST BE RESTARTED 4506 500 0088 INIT 1 934 0092 0092 X INIT 2 0092 RANDOM START 1704 FASTER 1744 FASTER 0092 01 0092 FIND FIND 0092 FASTER 333 0095 X UPDATE FIND 1 0093 X 0092 CLEAR DISPLAY C8C 91 0 FILL DECK STORE CARDS LEFT 52 93 62 1 DECK FINISHED YES STOP RANDOM 4 C1 FF BOTH CLOCKS OUT OF RANGE APPROX MIDDECK GET NUMBER 1 34 FIND THE CARD KEEP SUBTRACTING CARD CARD 0 MEANS PICKED CARD 1 MEANS IN DECK X CARD POSITION CARD 0 1 LESS CARD LEFT GET FIRST 6 BITS OF X Y C0 C gt 0048 89 7B 00 LDA 0078 Y GET VALUE FROM VALTBL 0088 85 90 STA 0090 STORE AS 5TH DISPLAY DIGIT 0046 8A TXA GET LAST 2 BITS OF X OO4E 29 03 AND 03 0 3 0050 8 TAY 0051 89 88 00 LDA 0088 Y GET SUIT FROM SUITBL 0054 85 91 STA 0091 STORE AS 6TH DISP DIGIT
67. 02 7 02 9 02 02 02 02 0 02F2 02F4 02 7 0229 02FB 02FE 0500 0502 0304 0306 0308 030A Q30C 050 0510 0512 0514 0515 0518 031A 031C 031E 0531F 0321 0323 0325 0327 0329 0328 0320 032F 0351 0333 0336 0339 30 01 FOUR SPLA PLAC DUMB TPLA PLAY MTST IQDN IQUP BCS DONE STIQ IQST DONE CHIQ CPY BNE AND BNE CPY BNE BEQ BEQ CMP BNE LDA STA LDA STA LDA STA JSR JSR JSR 80 50 10 5 601 8513 SEMO 512 514 DONE 8500 505 POINTL IQ INH SCANDS KEYPR GETKEY 15 PLAY NO YES 1 2 TIME PLAY A CORNER 4TH PLAY NO SKIP YES CK WHO HAS CENTER KIM PLAY A SIDE PLAYER PLAY A CORNER CAN PLAYER MAKE A SQUEEZE PLAY YES BLOCK IT START WITH THE CENTER START WITH THE SIDES USE THE RANDOM PLAY TABLE OPENeSQUARE FOUND ONE PLAY IT NO TRY NEXT ONE NOT YET START OVER MARK THE wSQUARE FOR KIM PLAYER S TURN NEXT FIRST DID KIM WIN WHO WON PLAYER UP KIM S I Q KIM S TOO SMART LOWER THE I Q NOT BELOW ZERO NOT OVER 10 HEX START WITH 75 I Q DISPLAY RESULTS GET KEY START WITH KIM IF GO KEY PRESSED START WITH PLAYER IF KEY PRESSED PRESSED SKIP NO KEY LOOP SHOW 5 AND I Q ON DISPLAY 0 3 cg 1 11 DA KEY PRESSED 033E F0 05 BEQ DONE RETURN TO LOOP 0340 E5 BCS CHIQ KEEP TRYING IF OVER AD 0
68. 02 A9 7F 8D 41 17 AO 13 A2 01 86 0270 89 A5 86 4A 4A 4A 85 8A 86 29 OF AA BD E7 0280 20 A4 02 6 8A C6 89 10 F4 A2 03 BD 2D 05 Eh 0290 85 DO 02 05 81 20 02 CA 10 F1 30 05 20 9 02 02A0 D8 4C 00 02 8D 40 17 8C 42 17 C6 8B DO FC 88 88 02B0 60 A8 82 06 82 06 82 05 82 29 OF 85 82 38 A5 02 0 80 E5 83 85 83 B9 31 03 85 80 B9 35 05 85 81 BD 0200 49 03 88 30 04 4A 4A 10 F9 29 03 85 8C AD 04 02 0 17 29 07 C5 8C FO 33 90 51 2 0h 5 84 OA OA 02F0 10 04 A2 FF A9 01 86 85 18 65 86 85 86 AD 00 0300 AA 29 OF C9 DO 02 84 84 8A HA HA HA DO FO 0510 A2 03 BD 24 03 95 80 CA 10 F8 A5 84 18 49 FF 69 I 0320 01 85 84 60 30 CO 00 80 01 FF 00 01 00 00 06 30 0330 00 20 20 20 14 08 40 01 49 02 02 01 02 01 03 01 0340 02 03 03 00 02 00 00 02 02 78 BS 9E 76 6E Al 0350 75 AA 8F 75 5B 56 7A 55 99 3 0 U C K I By Peter Jennings Modified by Jim Rutterfield Description Here s a program to test your speed of reaction Press GO and the display will blank for a random period of time When it lights hit any numbered button The number on the display will tell you how quick you were the smaller the number the faster your reaction time You may play repeatedly just press GO each time you want a new test 0300 5 F9 START LDA INH RANDOMIZE DELAY 0302 2A ROL A MULTIPLYING 0303 65 F9 ADC INH BY 3 AND 0305 29 7F AND 7F KING 0307 85 STA POINTH WORK DISPLAY AREA 0309
69. 0227 86 61 STX FIAG flag total in disvlay 0229 D8 CLD 022A 10 Dh BPL START return to start 022C 9 00 DOGO IDA 0 set flag for 022E 85 61 STA FLAG total in disolay 0230 2 02 LDX 2 for 3 digits 0232 95 F9 CLEAR STA INH X clear display 023 DEX next digit 0235 10 FB BPL CLEAR last digit 0237 30 C7 BMI START finished back to go 0239 Al 61 NUM LDY FIAG total in display 023B DO OF BNE PASS no add new digit 023D E6 61 INC FLAG clear t i d flag 023F 48 PHA save key 0210 A2 02 LDX 2 3 digits to move 24 0242 BS F9 0214 95 62 0216 9 F9 0248 CA 0249 10 F7 O2hB 68 0210 OA O2hE OA OA 0250 A2 0252 0253 26 F9 0255 26 0257 26 0259 025A DO F6 025C FO A2 MOVE IDA INH X STA ACCUM X STY INH X DEX BPL MOVE PIA ASL A ASL A ASL A ASL A IDX 4 ASL ROL INH ROL POINTL ROL POINTH DEX BNE SHIFT BEQ START PASS SHIFT get display digit copy to total Accum clear display next digit last digit recall key move digit into position bits move bit from A INH eto rest of display next bit last bit yes back to start HEX DUMP ADDITION XXXXX 0200 20 1F 1F 20 6A 1F C5 60 FO F6 85 60 C9 90 29 0210 C9 13 FO 18 C9 12 DO E8 F8 18 A2 FD B5 FC 75 65 0220 95 FC 95 65 E8 30 F5 86 61 08 10 04 A9 00 85 61 0230 2 02 95 F9 10 FB 30 C7 A4 61 DO OF E6 61 48 0240 A2 02 B5 F9 95 62 94 F9 CA 10 F7 68 0A 0A 0250 A2
70. 03 JSR BUST make BUST message 02 20 28 03 JSR WLITE and show it 42 02 2 02E4 02 02 8 O2EA 02ED 02F0 02F3 02F5 02 7 0229 2 02FD 02FE 0300 0302 0305 0307 0309 030B 030D 030F 0311 OF 02 03 03 03 03 03 17 17 17 IWIN LDA decrease balance SED SEG SBC BET by amount of bet JLINK STA AMT Store new balance XLINK JMP DEAL next play Player wins here IBUST JSR BUST make BUST message UWIN JSR WLITE display pause ADD LDA AMT increase balance SED CLC ADC BET by amount of bet LDY 99 99 maximum BCC NOFLO have we passed it TYA yes restore 99 BNE JLINK unconditional branch KIM stands compare points HOLD2 LDX 3 flag KIM JSR SHOTOT for total display LDA MTOT KIM s total CMP UTOT vs Player s total BEQ XLINK same no score BCS KIM higher wins BCC ADD KIM lower loses subroutines start here SHTOT shows point totals per X register SHTOT LDA UTOT X player s or KIM s total SED CLC ADG UACE X try adding Ace points 22 exceeds 21 total BCS SHOVER yes skip STA UTOT X no make permanent SHOVER CLD LDA UTOT X get revised total PHA save it LDY TOT 300 set up TOT msg JSR FILL put in WINDOW PLA recall total JSR NUMDIS insert in window display pause approx 1 second WLITE LDY 80 timing constant WDO JSR LIGHT illuminate screen DEY countdown BNE WDO illuminate display LIGHT STY YSAV
71. 0BB NOR CALCULATED PLAYS E 0202 AO 0h LDY 504 CENTER FIXED ORDER 020F 20 F2 03 JSR RPLA j 0212 A2 04 LDX 04 3 0214 D5 BB ELP2 REVN X z 0216 FO F7 BEQ ELP1 E 0218 CA DEX E 0219 DO FQ BNE ELP2 en 021B 99 BB 00 STA SIDES IN RANDOM ORDER 4 021 88 DEY 4 021F DO FE BNE ELP1 E 0221 E6 B6 INC ODEV 26 0223 AQ 04 LDY 04 0225 20 F2 03 OLP1 JSR RPLA 0228 A2 05 LDX 8505 022A 05 B6 OLP2 CMP RODD X 022C FO F7 BEQ OLP1 022E CA DEX 022 DO F9 BNE OLP2 0231 99 B6 00 STA RODD Y CORNERS IN RANDOM ORDER 0234 88 DEY 0235 DO EE BNE OLP1 0237 9 03 PVAL LDA 03 0259 AO 08 TEST LDY 8508 TEST FOR 3 IN A ROW 0238 09 C8 00 CMP ROWS Y 03 PLAYER WIN OC KIM WIN 023E 05 BEQ WIN GAME WON BLINK THE ROW 0240 88 DEY 0241 DO F8 WNLP NOT YET CK NEXT ROW 0243 FO 15 BEQ DRAW NO WINNER CK FOR DRAW 0245 BE 17 01 WIN LDX SQ1 Y f 0288 20 06 01 JSR BLNK BLINK 1 0258 BE 1F 01 LDX SQ2 Y 024E 20 0601 JSR BLNK BLINK 42 78 0251 27 01 LDX 503 0254 20 06 01 JSR BLNK BLINK 47 0257 4C FE 02 JMP MTST CHECK THE WINNER 025 2 09 DRAW LDX 09 025C A9 CO OPEN LDA 5 0 OPEN SQUARE P 025 35 AND DSPL X 0260 FO OE BEQ TURN YES CONTINUE GAME 0262 CA DEX NO CK NEXT SQUARE 0263 DO F7 BNE OPEN ALL DONE 0265 A2 09 LDX 09 0267 20 06 01 NXBL JSR BLNK OPEN SQUARES 026A CA DEX IT S A DRAW 026B DO FA BNE NXBL BLINK EM ALL 026D 4C 15 03 JMP DONE GAME S OVE
72. 1 B5 85 02 0 E6 02 5 02 C9 10 90 18 01 5 05 20 2D 05 02 0 20 16 03 00 06 20 05 03 38 26 00 00 85 02 85 0300 01 D8 4C 00 02 A9 00 85 02 85 01 A2 06 BD 3B 03 0310 95 0A CA 10 F8 60 A9 00 85 0A A2 06 D5 03 BO 06 0320 B5 03 85 03 86 01 CA DO F3 C6 03 A8 60 95 03 FO 0330 04 A8 B9 E7 1F 95 A9 00 60 FF 06 BE 00 B8 BF 0540 ED F9 po UTER Er TN s 76 TAC 0100 0103 0106 0108 010 010C 010D 010F 0118 0120 0128 0130 0132 0134 0136 0138 013A 013C 013D 013F 0140 0142 0144 0146 BY LEW EDWARDS DIRECTIONS PLAY BEGINS WITH KIM MAKING THE FIRST PLAY WHEN GO IS PRESSED THE SECOND THROUGH FOURTH DIGITS OF THE DISPLAY HOLD THE PATTERN WITH SQUARES NUMBERED AS YOUR ENTRY WILL BE IMMEDIATE BUT 789 KIM S ACTION WILL BE DELAYED YOUR 456 PLAYS LIGHT STEADILY WHILE KIM S 12 3 FLICKER A WINNING ROW BLINKS AND A DRAW BLINKS EVERYTHING ON COMPLETION OF A GAME THE KEY WILL START A NEW GAME IF YOU PREFER TO PLAY FIRST PRESS THE KEY INSTEAD THE KIM HAS 1 0 LEVEL THAT CAN CHANGED BY PRESSING AT GAMES END YOU WILL SEE ODDS AND KIM S 1 0 DISPLAYED THE I Q IS INITIALLY SET TO 75 COC CHANGE IT TO WHAT YOU WISH AND THEN PRESS DA TO RETURN TO THE DONE LOOP AND JART A NEw GAME IN THE NORMAL MANNER THE I TED UPWARD EACH TIME THE PLAYER WINS AND DOWNWARD EACH TIME KIM WINS THE PROGRAM STARTS AT 0100 hC 10 05 JMP STIQ
73. 18 65 42 C5 45 FO 28 0250 45 FO 12 C9 07 DO 2D A5 44 FO 05 18 F8 E9 00 D8 0260 20 02 DO 1F 46 86 48 47 86 49 85 45 AA 0270 BD C6 02 FO OF 30 EO A5 44 C9 99 FO 04 F8 69 01 0280 08 20 9 02 A5 41 FO 04 46 47 A9 7F 8D 41 0290 17 AO 13 A2 05 B5 46 8D 40 17 8C 42 17 E6 HF DO 02A0 FC 88 88 10 EF 4C 00 02 85 44 AO 00 84 45 84 02B0 8 84 49 A8 HA 4A AA BD E7 85 4A 98 29 02 0 OF AA BD E7 1F 85 60 FF FF 00 00 00 01 00 00 0200 00 01 FF Coding notes CRAPS is a highly top down program The program always flows from START to LIGHT and back again with few breaks in sequence The dice are randomized from TIMER 1704 and RNDLP contains a small division routine dividing by 6 the remainder randomly 0 to 5 gives the roll of one die On the first roll of a run we use the table at 02 C8 to analyze the total in this table FF means you lose and 01 means you win FLAG is zero if you re not pushing any button Segments for the display are stored in table WINDOW 0046 to 004B 61 DUEL 2 DESCRIPTION THIS IS GAME FOR TWO PLAYERS WHEN THE PROGRAM IS STARTED AT 0200 EACH PLAYER IS GIVEN TEN POINTS AS INDICATED ON OPPOSITE SIDES OF THE DISPLAY THE CENTER DIGITS WILL BE BLANK AFTER A RANDOM DELAY THE CENTER DIGITS WILL LIGHT THE FIRST PLAYER TO PRESS HIS KEY WILL INCREASE HIS SCORE BY ONE AND DECREASE HIS OPPONENT S BY ONE THE CENTER DIGITS WILL THEN BLANK FOR ANOTHER R
74. 2 29 3C 00 1 99 89 00 20 C5 02 29 38 85 9A B9 0290 8C 00 30 29 38 C5 9A BO 05 9 FF 99 89 00 20 02A0 3D 1 AO FF 99 3D FO 02 FO 01 88 98 55 89 85 0280 9 20 5 02 38 29 01 65 8 18 6 99 75 8 95 8 02 0 95 86 4C 2A 02 38 5 92 65 95 65 96 85 91 2 04 0200 B5 91 95 92 CA 10 F9 60 00 80 80 80 80 80 80 80 4 02 0 FF FF FF 80 80 80 00 00 00 80 80 80 08 FE BF F7 02 0 01 02 04 71 KEY TRAIN Ever wish you could touch type your KIM keypad like some people can type It s not hard all you need is practice And what better teacher to drill you on key entry than the KIM system itself Load this fully relocatable program anywhere Start it up and the display will show a random hexadecimal digit fom O to Hit the corresponding key and the display will plank and then present you with another random digit Hit the Wrong key and nothing will happen The educational principle involved is called positive reinforcem nt That is you re rewarded for doing the right thing and ignored if you do it wrong few minutes of practice a day and you ll become a speed demon on the keyboard 0000 20 hO 1F START JSR KEYIN 0003 DO FB BNE START key still depressed blank 0005 AD 0 17 LDA TIMER random value 0008 LSRA LSRA wipe high order bits 000 LSRA LSRA 000 85 FF STA TEMP save the digit 000 OA OA ASLA ASLA move back left 0010 OA OA ASLA ASLA 0012 05 FF O
75. 342 85 D2 STA IQ UNER 11 CHANGE 0344 90 El BCC CHIQ 10 TO KEY 4 NO KEY AGAIN 0346 84 DB SEMO STY MODE SET STARTING PLAY 0348 4 00 02 JMP NEW ANOTHER GAM 034B EA NOP SUBROUTINE DISPLAY 034C AQ 7F DISPLAY LDA 7F O34E 8D 41 17 STA PADD OPEN DISPLAY CHANELS 0351 6 DA INC RATE 0353 AO 00 LDY 00 0355 A2 0B DIGX LDX 0B INDEX DIGIT 0357 B9 CO 00 SEGY LDA SQST Y GET CONTROL BYTE 035A 85 FC STA SAVE SAVE IT 035C FO 14 BEQ OFF OPEN SQUARE 055 29 20 AND 20 BLINK FLAG 0360 FO 04 BEQ FLIC NOT ON SKIP BLINK 0362 24 DA BIT RATE 0364 70 0C BVS OFF ALTERNATE ON OFF 0366 5 FC FLIC LDA SAVE 0368 29 40 AND 40 STRADY FLAG 036A DO OA BNE ON ON SKIP FLICKER 036C 5 DA LDA RATE 036E 29 08 AND 508 FLICRPR RATE 0370 FO 04 BEQ ON ON 0372 AQ 00 OFF LDA 00 OFF 0374 FO 03 BEQ DIGT 0376 B9 OF 01 ON LDA SEGS Y 0379 84 FC DIGT STY SAVE SAVE FROM LOSS IN SUBR 0378 20 4E IF JSR CONVD 6 DISPLAY A SEGMENT 037E C8 INY 037F CO 09 09 LAST SQUARE 0381 FO O6 BEQ LAST YES DONE 0383 EO 11 CPX 11 NO LAST DIGIT 0385 FO CE BNE DIGX YES REPEAT DIGITS 0587 DO CE BNE SEGY NEXT DIGIT 0389 60 LAST RTS SUBROUT INE RS ADD 038A 5 BF RSA LDA 505 038C 85 09 STA TEMP 038 24 09 BIT TEMP WHO S SQUARE 0390 30 06 BMI KIM KIM S 0392 70 08 BVS PLYR PLAYER S 0394 9 00 OPEN LDA 00 OPEN SQUARE VALUE 0396 FO 06 BEQ ADD 0398 9 04 KIM LDA 04 KIM VALUE 039A 00 02 BNE ADD 039C A9 01 P
76. 5 CPX 15 Last one 17C2 DO CF BNE NEXT No do next 17Ch FO CB BEQ MORE Yes do more 1780 9 07 8D 42 17 A9 01 8D 01 17 85 1 A9 7F 8D 41 1790 17 A2 09 AO 07 2C 42 17 30 02 0 38 8C 40 17 8E 17A0 42 17 2C 47 17 10 FB E2 30 04 91 DO 03 9 1780 93 EA 8D 44 17 A9 01 45 El 85 El 8D 00 17 E8 E8 17C0 EO 15 DO CF FO CB 129 m RELOCATE Ever long for an assembler Remember when you wrote that 500 byte program and discovered that you d forgotten one vital instruction in the middle And to make room you d have to change all those branches all those addresses Or the program with that neat piece of coding in it tt you suddenly need to remove say to change it to a subroutine but if you do you ll have to fill all that empty space with NOPs It s enough to make a grown programmer Dry those tears Program RELOCATE will fix up all those addresses and branches for you whether you re opening out a program to fit in an extra instruction closing up space you don t need or just moving the whole thing someplace else RELOCATE doesn t move the data It just fixes up the addresses before you make the move It won t touch zero page addresses you ll want them to stay the same And be careful it won t warn you if a branch instruc tion goes out of range You ll have to give RELOCATE lot of information about your program 1 2 3 Where your program starts Thi
77. 8A TXA 024 HA LSRA LSRA Extract first digit 0246 4A LSRA LSRA 0248 85 16 STA SEED1 and store 024 86 15 STX SEED Store whole number 024 A2 FC LDX FC Minus 4 for window O24E A9 00 PATT LDA 0 Clear Accum 0250 26 15 ROL SEED then roll in 0252 2A ROL A two bits 0253 26 15 ROL SEED 0255 2 convert 0256 A8 TAY ec 0257 9 7 02 LDA TAB Y segments 025A 95 1C STA FLAG1 X 025C E8 INX next segment 025D DO EF BNE PATT 025F A9 7F LIGHT LDA 7F Set directional 0261 8D 41 17 STA SADD registers 0264 AO 09 LDY 9 0266 A2 FA LDX FA Minus 6 0268 B5 1E SHOW LDA FLAG2 1 X Window contents 026A 8D 40 17 STA SAD 0260 80 42 17 STY SBD 0270 C6 11 WAIT DEC MOD 0272 DO FC BNE WAIT 0274 C8 C8 INY INY 0276 E8 INX 0277 30 EF BMI SHOW 0279 10 8A BPL MAIN 027B 14 12 TAB 14 12 24 22 0270 24 22 end DUMP BITZ XXXXX 2200 108 9 1 5 ID 28 40 IF 20 IF C5 14 50 85 0218 14 C9 15 FZ 46 D C C5 16 DE 4 EL 5220 IF 85 1C DZ C5 17 LO 36 ED E7 IF 85 ID DE 2230 2E 1L 2 9 Z 85 1 85 AL 04 17 29 22404 OF 65 17 4A 4A 85 16 86 15 2 FC A9 00 25 26 15 2 26 15 2A 8 LO 7E 22 95 1 EB LO EF 9 2260 8D 41 17 09 2 FA ES IE D 40 17 8 42 17 2278 11 D FC C8 C8 E8 30 EF 10 14 12 24 22 39 BLACKJACK
78. 904 LDA 04 do four times before 0373 C580 CMP QSEC updating seconds 0375 1058 BNE RTN 0377 A900 LDA 00 reset second counter 0379 8580 STA QSEC 037B 18 CLC 0370 F8 SED advance clock in decimal 037D A581 LDA SEC 037F 6901 ADC 01 advance seconds 0581 8581 STA SEC 0383 C960 CMP 60 until 60 seconds 0385 1028 BNE RTN 0387 A900 LDA 00 then start again 0389 8581 STA SEC 038B A582 LDA MIN 038D 18 CLC 038 6901 ADC 01 and advance minutes 0390 8582 STA MIN 0392 C960 60 until 60 minutes 0394 1019 BNE RTN 0396 A900 LDA 00 then start again 0398 8582 STA MIN 039A A583 LDA HR and advance hours 059 18 CLC 049D 6901 ADC Z 01 O39F 8583 STA HR 05 1 C912 12 until 12 hours 0545 DOO2 BNE TH 05 5 E68h INC DAY advance day O3A7 C913 TH 315 if 15 hours 05 9 DOO4 BNE RTN start again with one O3AB A901 LDA 301 O3AD 8583 STA HR O3AF D8 RIN CLD go back to hex mode O3BO A9F LDA 5F4 start timer with interrupt 0382 8 17 STA TIMEF in 249 856 microseconds 53 PT 4 0585 68 PLA 0586 8 TAY 0387 68 PLA 0388 AA restore X O3B9 68 PLA restore O3BA 40 RTI return from interrupt ESCAPE TO KIM IF 1 ON KIM IS PRESSED This is a subroutine which will return to the KIM monitor routine without stopping the real time clock It is done by pressing 1 on the KIM keyboard 0500 206A1F JSR GETKEY 1 go back to KIM i
79. A At 20 CA 48 20 33 CA 10 1D A9 26 hF hC 20 58 CO C5 02 C5 02 FO A2 05 Bl 18 98 65 86 DB A9 DB 00 EF 84 FC 20 1 20 3E 20 6A 1F 65 45 85 AA A5 CO 72 02 29 AA B5 C6 85 C7 B5 05 CA 10 02 4C D4 00 02 4C B7 F3 BE C1 CA 10 20 72 02 10 EC 20 30 17 EO 10 02 A9 CA B9 E7 10 F6 A0 C5 02 85 10 F9 20 AQ 00 A9 4C CF 02 CF 02 A9 02 20 C5 CB FO 15 CA F0 BB F7 A9 73 DB BE 05 Hof caus DIAGNOSTIC AND UTILITY PROGRAMS BRANCH oe Load this fully relocatable program anywhere Once it starts key in the last two digits of a branch instruction address then the last two digits of the address to which you are branching and read off the relative branch address For example to calculate the branch to ADDR near the end of this program hit 26 from 0026 20 to 0020 and read F8 on the two right hand digits of the display The program must be stopped with the RS key 0000 D8 START CLD 0001 18 CLC 0002 A5 FA LDA POINTL 0004 E5 FB SBC POINTH 0006 85 F9 STA INH 0008 F9 DEC INH 000A 20 1F 1F JSR SCANDS 0000 20 1 JSR GETKEY 0010 C5 F3 LAST 0012 FO EC BEQ START 0014 85 F3 STA LAST 0016 C9 10 10 4 0018 BO 6 BCS START 001A ASL A 001B ASL A TE 001C 0A ASL A 0010 OA ASL 001 A2 Ol LDX 4 0020 0A ADDR ASL A 0021 26 POINTL 0023 26 M ROL POINTH 0025 CA DEX 0026 DO F8 BNE ADDR 0028 FO D BEQ START Keep in mind
80. A SLIP CMP POINTL Y here s the test DO 15 BNE branch if failed 0051 C8 INY 0052 DO FO BNE POP 005 INC POINTH 0056 A5 Ol LDA END d 0058 C5 FB CMP POINTH 005A BO E8 BCS POP 3 above test OK cHffnge amp repeat 0050 C 72 DEC MOD change 1 3 position OOSE 10 AD BPL PASS amp do next third 0060 A5 70 LDA FIAG invert 0062 19 FF EOR flag for pass two 006l 30 Al _ BMI BIGLP 0066 8 FA OUT STY POINTL put low order adds to display 0068 hC 1C JMP START And exit to KIM 006 Hex Dump Memory Test 0000 00 00 A9 00 A8 85 FA 85 70 A2 02 86 72 A5 00 85 0010 FB 01 A5 70 49 FF 85 71 91 FA C8 00 FB E6 FB 0020 E4 FB BO F5 72 A5 00 85 FB 70 CA 10 04 A2 0030 02 91 FA C8 00 F6 E6 FB 5 01 C5 FB BO 5 00 0040 85 FB 72 5 71 CA 10 04 A2 02 5 70 01 00 0050 15 C8 DO FO E6 FB AS 01 C5 FB BO E8 C6 72 10 AD 0060 A5 70 49 FF 30 1 84 hC HF 123 MINI DIS 7 yis One day I was single stepping through a program and not being too alert I kept going after the program ended Then I noticed 1 was going through instructions not in any OP code table What was being executed With a little luck I found that many nonexistent codes would duplicate others with only one bit changed I haven t looked into it very deeply but here are two examples 17 is the same as 16 ASL Z PAGE and FF is the same as FE INC ABS X By single stepping I
81. A7 FF 27 00 42 00 Extra Datafile for Music Box 0000 00 56 0010 2 29 26 2020 56 52 40 0030 44 39 0040 4D AF 4D 2050 A4 32 A9 2060 2F 29 7 FF 20 52 24 AF FC AF 2 AD 29 06 80 29 A4 4D 39 FC 2F 24 AF 32 FC A9 G2 29 2 AF 62 00 A4 A9 FC FE 56 eF AF Note be sure to set the break vector 17FE FF 00 1C 94 PING PONG Play against the computer or C slam F change the program for a two player game each shot you choose 8 block B between four plays Spin Lob Block or Slam If you re playing 4 lob 7 the left side of the court use the left hand buttons 0 4 8 and C 0 spin 3 See the diagram at right Each shot has its own strengths and weaknesses for example a Slam is a powerful shot but it s also likely to be fluffed Strategy is not trivial your chances of success on any play depend not only on your choice of shot but on what shots have gone before You ll have to learn the combinations the hard way You ll see the net in the middle of the court Don t try to play the ball until it is on your side of the net or you ll lose the point Each type of shot has a distinctive appearance which you ll learn to recognize Ty are similar to the key positions a Spin lights the bottom segment a Lob lights the middle segment a Block Ifgnts the upper segment and the mighty Slam s
82. AND UP THE PROGRAM CAN BE EASILY CONVERTED TO A SUBROUTINE REPLACING THE BRK INSTRUCTION WITH A RTS THIS ALLOWS THE PROGRAMMER TO PLAY VARIOUS PHRASES OF MUSIC TO PRODUCE QUITE COMPLEX TUNES 91 THE LOWEST NOTE YOU CAN PLAY IS BELOW MIDDLE C EACH NOTE YOU CAN SELECT WHETHER IT IS PLAYED AS A LONG NOTE OR A SHORT NOTE CNORMALLY A LONG NOTE WILL LAST TWICE AS LONG AS A SHORT NOTE SOME OF THE NOTES ARE AS FOLLOWS NOTE SHORT LONG PEERS S F5 cT E8 MIDDLE 62 E2 6 DC D 56 D6 Dis ova dao a 52 D2 E 4D CD C8 F 44 C4 CO 3C BC B i VR ate cea ET 90 B9 Ai 35 85 62 B2 HIGH C 2F AF e MET AC D 29 A9 gt Au d 22 2 E yq 2 9E PAUSE 00 80 INITIALIZE RESET WORK PARAMETERS 0200 2 05 START LD 505 f 0202 BD 86 02 LDA INIT X 0205 95 EO STA WORK X 0207 CA DEX 0208 10 F8 BPL MAM ROUTINE HERE WORK NOT RESET 020A A9 BF GO LDA BF 020C 8D 43 17 STA PBDD OPEN OUTPUT CHANNEL 020F A0 00 LDY 00 0211 LDA CWORK 4 Y GET NEXT NOTE 0213 INC WORK 4 0215 C9 FA 5 TEST FOR HALT 0217 0 BNE NEXT 0219 00 BRK COR RTS IF USED AS SUBR j 021 EA NOP 021B FO ED BEQ GO RESUME WHEN GO PRESSED 021D 90 0B NEXT BCC NOTE IS IT A NOTE 021F E9 FB SBC FB IF NOT DECODE INSTR 0221 92
83. ANDOM DELAY IF A PLAYER PRESSES HIS KEY WHILE THE CENTER DIGITS ARE BLANK HIS SCORE WILL BE DECREASED BY ONE WHEN ONE PLAYER REACHES ZERO THE GAME IS OVER AND MUST BE RESTARTED AT 0200 THE PLAYER TO THE LEFT USES KEY ZERO AND THE ONE ON THE RIGHT USES KEY SEVEN 0200 A9 10 LDA 510 INITIALIZE DIGITS 0202 85 F9 STA 00 9 0204 85 FB STA 00 0206 AD 44 17 RAND LDA 1744 GET RANDOM 4 0209 29 IF AND 1F NOT TOO BIG 020B 0901 ORA 8501 NOT TOC SMALL 0200 85 EE 5 00 DECREMENT LOC 020 9 00 LDA 4500 BLANK CENTER DIGITS 0211 85 FA STA 00 0213 207102 DISP JSR LITE DISPLAY DIGITS 0216 AD 07 17 LDA 1707 TIME UP 0219 F0 00 BEQ MORE NO 0218 A9 FF LDA 5FF 0210 8 07 17 STA 1707 START TIMER 0220 C6 EE DEC 00 FULL TIME UP 0222 10 04 BPL MORE NO SKIP 0224 9 36 LDA 36 YES CHANGE 0226 85 FA STA 00 CENTER DIGITS 0228 D8 MORE CLD CLEAR FOR KEYBOARD 0229 20 40 1F JSR KEYIN INIT KEYBOARD 022C 20 6A 1F JSR GET KEY KEY DEPRESSED 022F C9 15 15 VALID KEY 0231 10 EO BPL DISP NO 0233 C9 07 8507 RIGHT KEY 0235 FO OE BEQ RITE YES 0237 C9 00 00 LEFT KEY 0239 FO 02 BEQ LEFT YES 023B DO 06 BNE DISP NOT A 0 OR A 7 0230 2 02 LEFT LDX 02 INDEX FOR LEFT 023F AS EE LDA OOEE TIME UP 0241 10 14 BPL 1051 NO DECREASE LEFT ONE 0243 30 06 BMI ADD1 YES INCREASE LEFT 0245 2 00 RITE LDX 00 INDEX FOR RIGHT 0247 AS EE LDA 00 CHECK TIME 0249 10 OC BPL LOS1 NO
84. B STA 024D A5 EA LDA 00 LAST ITEM IN LIST 024F C5 EC 00 0251 00 C8 GET NO NOT YET 0255 5 E9 LDA 00 9 0255 85 5 00 0257 5 CMP 00 LAST PAGE 0259 DO CO BNE GET NO 0258 4C 1C JMP 1C4F BACK TO KIM DONE 1 kkkk Hex Dump Sort 0200 AD F5 17 85 85 EA AD F6 17 85 E9 85 EB AD F7 d 1 0210 17 85 EC AD F8 17 85 0220 OC 1 85 E7 Al EA 81 E8 0250 02 EB A5 EA C5 EC 00 E2 0240 E8 DO 02 E6 9 8 85 EA 0250 EC 00 C8 A5 E9 85 EB C5 ED 17 D 2 00 D8 1 E8 EA 8 AS E7 81 EA E6 EA 00 5 ED C5 EB DO DC E6 5 9 85 A5 EA C5 DO CO HC HF 1C amete meu 5 137 SUPER DUPE SUPER DUPE is handy it lets you duplicate a complete tape containing many programs in jig time SUPER DUPE is versatile it will write various tape densities from regular to Hypertape SUPER DUPE is mu ti purpose if you don t want to duplicate programs you can use it for cataloguing tapes or for writing The maximum size program that SUPER DUPE can copy is dependent on the amount of memory of the KIM system The basic 1 system can copy programs up to 512 bytes long For duplicating tape it s useful to have two tape recorders one for reading the old tape one for writing the new They are connected in the usual way at TAPE IN and TAPE OUT Pause controls are handy SUPER DUPE starts at address 0000 Hit GO and
85. BNE NOKEY neither skip 0221 45 85 KEY EOR PLACE check vs ball postn 0223 A8 TAY 0224 29 04 AND 4 ball off screen 0226 DO 12 BNE NOKEY 0228 8A TXA restore key 0229 45 84 EOR DIRECT ball going away 022B 29 02 AND 2 022D FO OB BEQ NOKEY yes ignore key 022 98 TYA ball position 0230 29 02 AND 2 wrong side of net 0232 DO 69 BNE POINT yes lose 3 legal play found here 0234 8A TXA restore key 0235 4A 4A LSRA LSRA type 0 Spin etc 0237 20 Bl 02 JSR SHOT make shot key rtns complete play ball 023A 20 40 1 NOKEY JSR KEYIN if key still prest 023D DO 27 BNE FREEZE freeze ball 023F C6 83 DEC PAUSE 0241 10 23 BPL FREEZE wait til timeout 0243 A5 80 LDA SPEED 0245 85 83 STA PAUSE 0247 18 0248 5 85 LDA PLACE move 024A 65 84 ADC DIRECT 11 024 85 85 5 024 29 04 AND 4 ball still 0250 FO 14 BEQ FREEZE in court ball outside KIM to play 0252 A5 85 LDA PLACE 0254 30 04 BMI TESTL ball on left 0256 A5 88 LDA PRITE KIM plays right 0258 10 02 BPL SKPT unconditional 025A A5 87 TESTL LDA PLEFT KIM plays left 025C DO SKPT BNE POINT no lose point 96 029D 02A1 02A4 02A7 02AA 02AC 02AE 02B0 0281 0282 0284 0286 0288 02 02BC 02BE 02BF 02 1 02C3 03 02 17 LE 02 03 02 02 02 17 17 KIM plays either side here LDX LOG log determines LDA PLAY X KIM s play JSR SHOT make the shot FREEZE LDA 7 STA PADD open registers light disp
86. C LDA STA TYA CMP BNE INC TXA STA LDA BEQ LDY LDA AND BEQ LDA LDX 3 CMP BEQ DEX BPL BMI ING ASL DEY BPL SHOW WAIT SHOW WAIT debounce key WINDOW 4 new guess RES UME no input digit 4120 60 previous game finished NEW new game GUESS no next guess GETKEY 10 guess must be in WAIT range A to F 7 POINTR zero to start POINTR ya TABLE Y segment pattern WINDOW X SECRET X exact match NOTEX EXACT destroy input INPUT X WINDOW 3 has fourth digit arrived BUTT no 3 calculate matches INPUT Y for each digit 18 has it already been ON matched SECRET Y if not test INPUT X against input GOT LOOK ON MATCH increment counter INPUT X and destroy input STEP 30 02 2 01 LDX 1 display counts O2Al Bl OE TRANS LDY EXACT X 02A6 B9 E7 1F LDA TABLE Y 02A9 95 08 STA WINDOW 4 X O2AB CA i DEX 02 10 F6 BPL TRANS O2AE 20 CE 02 DELAY JSR SHOW long pause for debounce 0281 OF INC MATCH 0283 DO F9 BNE DELAY 02B5 20 CE 02 BUTT JSR SHOW wait for key release 0288 DO FB BNE BUTT 02BA FO BEQ WAIT we we TEN GUESSES MADE SHOW ANSWER 0286 A2 03 FINISH LDX 3 O2BE B 00 FIN2 SECRET X 02CO B9 E7 1F LDA TABLE Y 0203 95 04 STA WINDOW X 02C5 C DEX 0206 10 F6 BPL FIN2 02C8 A9 E3 LDA e3 square flag 02CA 85 08 STA WINDOW 4 02CC DO EO BNE DELAY unconditional jmp SUBROUTINE TO DISPLAY AND
87. C B F8 BCS SUB keep dividing 024 AE 46 17 LDX 1746 random timer 2 1 0251 Eh ED CPX IQ KIM smart enough E 0253 BO 02 BCS COMP Yes 4 0255 A9 01 DUMP LDA 1 No 46 0257 0259 025 025C 025E 0260 0262 0264 0266 0268 026A 0266 026E 026F 0271 0273 0275 0278 027A 027C 200 2210 g225 0238 40 d25 2260 0270 9 6A A5 ED COMP DEAD SHOW 1F LOK 85 C9 5 A2 FB ED ga F9 20 26 Eg 5A 84 STA POINTL SEC LDA INH SBC POINTL STA INH BNE PLAY LDA 5 LDY FE LSR IQ BPL SHOW LDX DE LDY Z AD SEC ROL IQ STX POINTH STY POINTL JSR SCANDS BNE NEW BEQ LOK Record the move Subtract KIM move from total Player wins SAFE get smart KIM winst DEAD get dumb new game if key DUMP BLACK MATCH 21 85 F9 A9 Fe C9 00 FE 32 EG 85 2C 07 17 04 EQ GA F A9 01 85 FA FE 46 ED 16 20 IF IF 47 20 F9 16 OB 38 87 8 85 A9 5 A2 FO FB gg C6 ZA F9 DE 20 85 EE BO ES AQ IF EE L AD 85 9 EF AE 85 38 20 FA FF 18 46 F9 26 1 CARD DEALER o DESCRIPTION THIS PROGRAM WILL DEAL A FULL DECK OF 52 CARDS THE VALUE AND SUIT OF THE CARDS APPEARS IN THE RIGHT TWO DIGITS OF THE DISPLAY 0000 0002 0004 0006 0007 0009 000 000C 000E 000F 0011 0012 0014 0016 0018 0
88. CAN BE THE JOCKEY AND WHIP YOUR HORSE TO GO FASTER WARNING WHIP THE HORSE TOO MUCH AND HE PROBABLY POOPS OUT THE PROGRAM STARTS AT 0200 HORSE PRINCE CHARMING COLORADO COWBOY IRISH RAIR 0200 0201 0203 0206 0208 0209 020B 020D 0210 0212 0214 0217 0219 021C 021D 021F 0221 0225 0226 0228 022A 022B 022D 022F 0251 0255 0255 0237 025A 023C 023E 025F 0241 0244 0246 0248 025A 024C 024E 0250 0252 0254 D9 02 ED 02 INIT DISP LITE NEXT TRACK TOP MIDDLE BOTTOM CLD LDX 13 LDA 02D9 X STA 007C X DEX BPL INIT LDA 7F STA 1741 LDY 500 LDX 4509 LDA 007C Y STY OOFC JSR 1F4E INY CPY 06 BCC LITE JSR 1F3D A WHIPPING BUTTON PC C 4 INITIALIZATION HORSES TO STARTING GATE e LIGHT DISPLAY 377 OUTPUT DIGIT SIX DIGITS DISPLAYED NOT YET TURN OFF DIGITS LDA LAP CNT FINISHED TOTAL LAPS BMI DISP LDX 8503 DEX BMI DISP DEC 0086 X BNE NEXT STX 0099 LDY 0099 LDX 0083 Y LDA 02ED Y AND 007C X STA 007C X INX STX 0083 Y LDA 02ED Y EOR FF ORA 007C X STA 007C X CPX 8505 BMI POOP BNE NLAP LDA 008F BEQ LAST BNE POOP 69 YES FREEZE DISPLAY NEXT HORSE FINISHED 3 HORSES DEC CNT HORSE X NOT ZERO NEXT HORSE SAVE HORE INDEX AND PUT IN Y AS INDEX DIGIT POS OF HORSE IN X MASK TO REMOVE HORSE GET RID OF HORSE RETURN REMAINING HORSES GO TO NEXT DIGIT RIGHT UPDATE HORSE DIGIT POS GET MASK CHANGE TO AN INSERT MA
89. CROWARE 27 Firstbrooke Rd Toronto Ontario CANADA MAE 212 MICRO SOFTWARE SPECIALISTS P O Box 3292 E T Station Commerce Texas 75428 6502 Program Exchange 2920 Moana Lane Reno Nevada 89509 Pyramid Data Systems 6 Terrace Ave New Egypt New Jersey 08533 Julien Dub 3174 Rue Douai Ste Foy Quebec G1W 2X2 Canada 175 Focal 2 1 2K assembler 6K assembler text editor send S A S E for info Please Package Help editor and mailing list packages send S A S E for info Tom Pittman s Tiny Basic send 5 5 for info MICROCHESS Chess in lk assembler send A S E for info 2K assembler editor send S A S E for info Focal Focal programs Kim and TIM programs send 50 for program list 1K monitor system send S A S E for info Baudot Monitor send S A S E im aea Jim Butterfield 14 Brooklyn Avenue Toronto Ontario Canada M4M 2X5 Lew Edwards 1451 Hamilton Ave Trenton 9 N J 08629 Ron Kushnier 3108 Addison Ct Cornwells Hts Penna 19020 Stan Ockers R R 4 Box 209 Lockport 111 60441 Charles Parsons 80 Longview Rd Monroe Conn 06468 Eric Rehnke 109 Centre Ave W Norriton 19401 Charles Eaton 19606 Gary Avenue Sunnyvale California 94086 Peter Jennings 27 Firstbrooke Rd Toronto Ontario Canada MAE 2L2 Cass Lewart or Dan Lewart 12 Georjean Drive Holmdel N
90. D2 10 OF E6 D2 A9 10 C5 D2 90 F4 BO 05 0310 A9 0C 85 02 D8 20 05 AD 01 C9 13 FO 28 88 C9 0320 12 FO 23 C9 14 DO EE OD 85 FB A9 05 85 FA A5 0330 D2 85 F9 20 1F 1 20 40 1F 20 1F C9 11 FO 05 0340 BO E5 85 D2 90 El 84 DB 00 02 EA 7F 8D 41 0350 17 E6 DA A0 00 A2 B9 CO 00 85 FC FO 14 29 20 0360 FO 04 24 DA 70 OC FC 29 40 DO DA 29 08 0370 FO 04 9 00 FO 03 B9 OF 01 84 FC 20 HE 1F C8 CO 0380 09 FO 06 EO 11 FO CE DO CE 60 B5 BF 85 09 24 DY 0390 30 06 70 08 A9 00 FO 06 A9 04 DO 02 A9 01 18 79 03A0 C8 00 99 C8 00 60 20 4C 03 20 HO IF FO F8 20 6A 0580 AA 60 08 58 9 D4 65 07 65 08 85 05 2 04 B5 03C0 03 95 Dk 10 F9 60 EA 85 09 A2 09 16 DB 16 DB 0300 DO F9 0 08 A5 09 09 C8 00 DO 12 17 01 20 03 0 40 01 01 20 40 01 27 01 20 40 01 88 DO 03F0 E4 60 20 B3 05 29 OE 05 B6 FO F7 C9 BO F3 60 XXXXX ZERO PAGE USAGE 00B6 ODD EVEN MODIFIER 00C0 C8 RANDOM PLAYS 00C9 DO0 ROWS STATUS 0001 DELAY TIMER 00D2 I Q 0003 08 RANDOM NUMBER REGISTERS 00D9 TEMPORARY STORAGE 00DA FLICKER BLINK RATE 00DB PLAY MODE 1 O0DC E4 PLAY STATUS 00FC SAVE 83 LUNAR LANDER Description The program starts at 0200 When started you will find yourself at 4500 feet and falling The thrust on your machine is set to low so you ll pick up speed due to the force of gravity You can look at your fuel at any time by pressing the l F button Your fuel
91. DX 5 test 0242 BS 18 TEST2 LDA WINDOW X win 0251 DD A6 02 CMP WINNER X condition 0254 oC BNE PLAY 0256 CA DEX 0257 10 F6 BPL TEST2 0259 2 05 LDX 5 0258 A9 LDA 40 set 0250 95 18 SET STA WINDOW X to 025F CA DEX w 0260 10 FB BPL SET 0262 9 7 PLAY IDA 7 directional 0264 8D 17 STA SADD registers 0267 AO 09 LDY 09 0269 A2 FA LDX 4FA negative 5 026B B5 1E SHOW LDA WINDOW X light 0260 8D ho 17 STA SAD display 0270 8C 12 17 STY SED 0273 C6 11 571 DEC MOD 0275 DO FC BNE ST1 027 C8 INY 0278 08 INY 0276 INX 027A 30 EF BPL SHOW 027C 20 ho IF JSR KEYIN 027F 20 IF JSR GETKEY 0282 C9 13 3913 GO key 0284 FO C5 SLINK yes restart 0286 C9 07 47 Keys 0 to 6 0288 BO C3 ECS WTEST no test win 028A TAX Keys 1 to 6 0288 FO D5 BEQ PLAY no exit 028D CA DEX Keys 2 to 6 1 to 5 028 FO D2 BEQ PLAY no exit 0290 10 CPX POINTR Same key as before 0292 FO CE PLAY yes ignore 0294 86 10 STX POINTR no we ve got a live one 0296 B5 18 TOPl LDA WINDOW X 0298 48 roll out 0299 CA DEX 029A 10 FA 029C A6 10 LDX POINTR 029 68 PLA roll em back in 029 95 18 STA WINDOW X 02 1 CA DEX 02 2 10 FA HL O2A4 30 BMI PLAY 0246 F7 FC BO WINNER BYTE 7 9 5 1 02A9 DE F9 F1 end 102 TEASER Description This program is an adaptation of the Shooting Stars game utilizing the k
92. E CA CMP BB BEQ DE 02 JMP 01 LDY 80 LDA 00 02 JSR F7 BEQ 73 OUT LDA CF 02 JMP DE STY DD STA 07 LDA DF STA 05 LDY 05 CONT LDX DD CHAR LDA 00 CMP 01 BNE RTS E8 STA MORE DEY DEX F3 BPL CLD CLC TYA DF ADC DC STA 28 02 JSR DC LDY 0A 02 JMP DELAY DISPLAY LDX DB STX 52 TIME LDA 07 17 STA 3E 02 JSR 07 17 BIT F8 BPL DB DEC EF BNE RTS BASIC DISPLAY SUBROUTINE XXX 7F LDA 41 17 STA 00 LDY 09 LDX E8 00 SIX LDA FC STY JSR 110 DID HE MOVE INTO YOUR ROOM YES DISPLAY CANS LEFT MESSAGE GREAT amp ETC MESSAGE REPEAT OUT OF GAS TRANSFER POINTER HIGH TRANSFER POINTER LOW INIT SCAN FORWARD INIT Y INIT X GET CHARACTER LAST CHARACTER IF NOT CONTINUE STORE IT SET UP NEXT CHARACTER SET UP NEXT STORE LOC LOOP IF NOT 6TH CHAR BINARY MODE PREPARE TO ADD GET CHAR POINTER UPDATE FOR 6 NEW CHAR SAVE NEW POINTER DELAY DISPLAY RESTORE POINTER CONTINUE REST OF MESSAGE SET RATE PUT IN DECR LOC LOAD TIMER START TIMER JUMP TO DISPLAY SUBR TIMER DONE IF NOT LOOP DECREMENT TIMER NOT FINISHED GET 6 NEW CHAR CHANGE SEGMENTS TO OUTPUT INIT RECALL INDEX INIT DIGIT NUMBER GET CHARACTER SAVE Y DISPLAY CHARACTER 024F 0250 0252 0254 0257 0258 025B 025E 0260 0263 0265 0268 026A 026D 026F 0271 0272 0273 0274 0275 0276 0278 027A 027C 027E 0280 0282 0284 0285 0287 0289 028A 028B 028D 028F 0291
93. EA0 The character then comes spewing out the serial output port bit by bit ASCII The code that is used in this process is the American Standard Code for Information Interchange or ASCII for short The hardware connection is also standardized and is made of two 20 milliamp current loops The device to be connected to KIM should be set up for these standards Connections are made as shown starting on page 17 of the Kim User s Manual SES a SERRE TSE The Teletype P es The serial ports were obviously set up with a particular machine in mind the Teletype The problem is that a new Teletype will cost over 1000 and used ones aren t much cheaper eee qe Baudot Machines ud Older model Teletypes and some other makes of teleprinters go for 25 on up The difference These are Baudot machines Where the modern Teletype uses a 8 bit 8 level code to represent ASCII characters the older machines use a 5 bit 5 level code called Baudot A good place to find out what is available etc is a series of three articles appearing in the April May and June 77 issues of Byte magazine Teleprinters are noisey smelly and slow What s more the interface of a Baudot machine to your KIM is far from a trivial problem Why then even bother with the teleprinter One reason it s great to have a hardcopy of your program a piece of paper you can sit down and take a pencil to when something goes wrong Video Terminals Also easil
94. F9 C9 16 0020 20 24 1A F9 10 FS C9 2 D F1 20 19 0030 85 F9 A2 FE 20 F3 19 95 20 91 8 30 F5 A 0040 02 20 24 1A C9 2F FO 15 20 00 1A DO CA DO FI 6058 61 20 91 IF E6 ES D 02 DO 20 F3 19 0060 CS F DO 05 20 F3 19 C5 F6 D 95 20 IF IF F FB 0070 20 C9 07 B F4 85 F5 A F 84 8 BE 01 65 0080 FS 8D 0 01 A9 27 85 F5 A9 BF 8D 43 17 2 64 9 009 0 16 20 61 01 A9 2 20 88 01 A5 F9 20 70 01 5 FA BJAG 20 70 01 AS FB 20 70 01 20 BI 26 70 01 E6 22B0 E2 D 02 5 E2 CS 5 ES EI 90 E9 9 00 0 2F 20 88 01 5 F7 20 70 01 5 F6 4C 54 01 FF EA 4C 29 19 00 0 00 02 00 02 REMEMBER You must also include HYPERTAPE page 119 140 la Dri TONO VERIFY TAPE Do you want to verify the cassette tape you just recorded before the information is lost Then follow this simple procedure 1 Manually verify that the starting address 1725 17F6 the ending address 1727 817 8 and the block identification 17F9 locations are correct in memory 2 Enter zeros 00 into CHKL 17E7 and CHKH 81758 3 Enter the following routine 17EC CD 00 00 VEB cmp START 17EF DO 03 bne failed 1771 40 19 jmp LOADI2 17Fh 4C 29 19 failed jmp LOADT9 4 Rewind the tape enter address 188C press GO and playback the tape If the tape compares the LEDs will come back on with address 0000 If th
95. IT ALTERNATIVELY AN AMPLIFIER WILL PLAY THE f SIGNAL THROUGH A SPEAKER HOW TO RUN LOAD THE PROGRAM LOAD THE 5 EITHER FROM CASSETTE TAPE PAPER TAPE OR KEYBOARD ENTRY SURE TO STORE THE VALUE FA AT THE END OF EACH TUNE AND BEHIND THE LAST TUNE STORE FF 00 STARTING ADDRESS FOR THE PROGRAM IS 200 ENTER AD 0 2 0 0 GO HOW TO WRITE YOUR OWN 52 EACH NOTE GOES INTO A BYTE OF STORAGE STARTING AT LOCATION 0000 OF MEMORY EACH TUNE SHOULD END WITH THE VALUE FA WHICH STOPS THE PROGRAM UNTIL GO IS PRESSED SPECBAL CODES ARE INCORPORATED IN THE PROGRAM TO ALLOW CERTAIN EFFECTS ADJUSTMENT OF SPEED TONE ETC THE CODES ARE FOLLOWED BY A VALUE WHICH SETS THE PARTICULAR EFFECT CODES ARE LISTED BELOW CODE EFFECT INITIALLY EXAMPLES FB SETS SPEED OF TUNE 30 18 IS QUICK 60 IS SLOW FC SETS LENGTH OF 02 2 MEANS LONG NOTE LASTS LONG NOTES TWICE AS LONG AS SHORT FD SETS OCTAVE PITCH 01 2 IS BASS 4 IS DEEP BASS FE SETS INSTRUMENT SFF FF IS PIANO 00 IS CLARINET FF SETS ADDRESS FOR 00 00 WILL TAKE YOU BACK TO TUNE FIRST TUNE LIKE A JUMP FOR EXAMPLE AT ANY TIME DURING A TUNE YOU MAY INSERT THE SEQUENCE FB 18 AND THE TUNE WILL THEN BEGIN TO PLAY AT FAST SPEED INSERTING FF 45 WILL CAUSE A SWITCH TO THE TUNE AT ADDRESS 45 THE INITIAL VALUES SHOWN BE RESET AT TIME BY STARTING AT ADDRESS 200 NO TUNE SHOULD EXTEND BEYOND ADDRESS DF SINCE PROGRAM VALUES ARE STORED EO
96. J 07733 James Van Ornum 55 Corne11 Drive Hazlet N J 07730 Jim Pollock 6 Terrace Ave New Egypt New Jersey 08533 Joel Swank 186 4655 S W 142nd Beaverton Ore 97005 k k k k k k k k k ee k k k k k k k k k k k k k k k k k k k k k k k k k k k k k e k k k k k k k Here are the folks responsible They eagerly await your praise comments criticism indignation whatever Please do the courtesy of enclosing self addressed 2 stamped if possible envelope SASE if you wish a reply 176 mc 5119 0 8 95 THE FiRST BOOK OF KIM JIM BUTTERFIELD STAN OCKERS and ERIC REHNKE Here is a step by step guide that will take you through the fundamentals of writing KIM programs This beginner s guide includes dozens of examples of programs that are run on a basic KIM 1 system These programs include games and puzzles such as Blackjack Chess Clock Horserace Lunar Lander Music Box and Ping Pong which are fu ly described so that you can learn from the prc jramming techniques illustrated as well as fun playing the games The authors go into detail on how you can expand your KIM from the basic small but powerful KIM 1 system to a huge and super powerful ma chize They include diagnostic and utility programs to help you build devices onto your KIM system such as teletype display or more The book also covers the jargon of KIM programming and what s avai
97. JSR RAND GET RANDOM NUMBER 29 OE AND 550 0 E CEVEND 05 B6 ORA ODEV MAKE IT ODD IF 01 F0 F7 BEQ RPLA NO ZEROS C9 0A 0 BO F3 BCS RPLA LOOP TILL DONE 60 RTS 82 BAR HEX DUMP TAC 0100 4C 10 03 EA EA EA AQ 20 15 BF 95 BF 60 EA EA 08 0110 08 08 40 40 40 01 01 01 01 04 07 01 02 03 01 03 0120 02 05 08 04 05 06 05 05 03 06 09 07 08 09 09 07 0150 85 09 A2 09 A5 09 35 DB 24 D9 00 03 CA DO F5 b0 0140 85 BF DO 02 F6 DB 60 95 BF AD 08 A9 00 99 C8 00 0150 BE 17 01 20 8A 03 BE 1F 01 20 8A 03 BE 27 01 20 0160 8A 03 88 00 E6 60 0200 A9 00 2 1D 95 B CA DO FB 9 05 85 BB 0 04 20 0210 F2 03 A2 04 05 BB FO F7 CA DO F9 99 BB 00 88 DO 0220 EE E6 B6 0 04 20 F2 03 A2 05 05 B6 FO F7 DOP 0230 F9 99 B6 00 88 DO EE A9 03 AD 08 D9 C8 00 FO 05 0240 88 DO F8 FO 15 BE 17 01 20 06 01 BE 01 20 06 0250 01 BE 27 01 20 06 01 4C FE 02 A2 09 CO 35 BF 0260 FO OE CA DO F7 A2 09 20 06 01 CA DO FA 4C 15 03 0270 E6 BS A5 DB DO 17 20 03 FO FB C9 OA BO F7 AA 0280 B4 BF DO F2 9 40 20 47 01 E6 DB DO AA 20 4C 03 0290 D1 DO F9 9 08 20 C8 03 A9 02 20 C8 05 9 04 02A0 20 C8 03 A9 01 20 C8 03 A9 CO 20 30 01 DO 43 A9 02B0 30 20 30 01 DO 3C A9 08 20 30 01 DO 35 28 05 0200 29 OF C5 D2 BO 1F BS CO 01 DO 04 29 01 0200 CO 04 DO 06 24 C4 30 OD 70 07 A9 02 20 30 01 02 0 11 0 05 DO 02 0 09 B6 B6 B5 BF FO 05 88 DO F7 02 70 FO F3 9 80 20 47 01 C6 DB 9 OC HC 39 02 A5 DB 0300 DO 04 C6
98. LLOWING A HIT OR TWO BEFORE YOU ARE FINALLY DISABLED 28 A BAGELS orewa DIRECTIONS THE COMPUTER HAS CHOSEN FOUR LETTERS ALL OF WHICH ARE A B C D E OR F LETTERS MAY BE REPEATED FOR EXAMPLE THE COMPUTER S SECRET COMBINATION MIGHT BE OR BBBB YOU GET TEN GUESSES EACH TIME YOU GUESS THE COMPUTER WILL TELL YOU TWO THINGS HOW MANY LETTERS ARE EXACTLY CORRECT CTHE RIGHT LETTER IN THE RIGHT PLACE AND HOW MANY LETTERS ARE CORRECT BUT IN THE WRONG POSITION FOR EXAMPLE IF THE COMPUTER S SECRET COMBINATION IS CBFB AND YOU GUESS BAFD THE TWO NUMBERS WILL BE 1 AND 1 CTHE F MATCHES EXACTLY THE B MATCHES BUT IN THE WRONG PLACE THESE NUMBERS WILL SHOW ON THE RIGHT HAND SIDE OF THE DISPLAY THE CODE YOU ENTERED WILL APPEAR ON THE LEFT MAKE A NOTE OF YOUR GUESSES AND THE COMPUTER S RESPONSE WITH A LITTLE MENTAL WORK YOU SHOULD BE ABLE TO BREAK THE CODE EXACTLY IN SEVEN OR EIGHT WORDS A CORRECT GUESS WILL PRODUCE A RESPONSE OF 4 0 IF YOU DON T GUESS RIGHT IN TEN MOVES THE COMPUTER WILL GIVE YOU THE ANSWER AFTER A CORRECT GUESS OR AFTER THE COMPUTER TELLS YOU THE ANSWER IT WILL START A NEW GAME WITH A NEW SECRET CODE THE INSTANT YOU TOUCH A NEW KEY 0200 E6 16 GO INC RND 4 randomize 0202 20 40 1F JSR KEYIN on pushbutton delay 0205 DO F9 BNE GO 0207 D8 CLD 0208 A9 0A NEW LDA 0A ten guesses game 020 85 18 STA COUNT new game starting 020C A9 03 LDA 3 create 4 mystery codes 020E 85 10
99. LOSE 02 DO 04 BNE FRST AND SKIP 02B0 C6 D3 MODE DEC 00D3 SET MODE TO 0 02B2 AQ 00 LDA 00 BLANK FIRST DIGIT 02B4 85 DO FRST STA 00D0 FILL FIRST DIGIT 02B6 DO 03 BNE NONE END OF GAME 0288 4C 14 02 UMP MLOP MAIN LOOP AGAIN 02BB 20 DD 02 DONE JSR DISP DISPLAY UNTIL 02BE 20 40 IF JSR 1F40 60 KEY IS 02C1 20 IF JSR GETKEY PUSHED 02Ch C9 13 13 0206 00 F3 BNE DONE 02C8 4C 00 02 JMP BEGN START A NEW GAME 02CB 01 02 04 08 10 10 20 40 80 1B 07 36 49 92 6C 0208 0 D8 DISPLAY SUBROUTINE 02DD Ag 7F DISP LDA 7F TURN ON DISPLAY 020 8D 41 17 STA 1741 02E2 A2 09 LDX 09 02E4 B5 C7 MORE LDA 00C7 X PUT INASEGMENTS 02E6 84 FC STY OOFC SAVE Y 02 8 20 IF JSR 1F4E DISPLAY THEM 02 15 15 DONE 6 TIMES 02ED DO F5 BNE MORE NO LOOP 02 60 RTS YES RETURN HEX CONVERSION SUBROUTINE 2 0220 4A LEFT LSR A 02F1 LSR 0222 HA LSR A Q2F3 4A LSR A 02F4 29 OF SEG AND 0 MASK TO L BITS 02F6 TAY USE AS INDEX 0277 B9 IF LDA 1FE7 Y CONVERT TO SEGMENTS 02FA 60 RTS RETURN 105 TIMER e V js Description TIMER turns KIM into a digital stopwatch showing up to 99 minutes and 59 99 seconds It is designed to be accurate to 50 microseconds per second The interval timer is used to count 9984 cycles and the instructions between the time out and the reset of the timer make up the other 16 cycles in 01 seconds The keyboard is used to control the routine as f
100. LYR LDA 01 PLAYER VALUE 039E 18 ADD CLE 039F 179 C8 00 ADC RS Y ADD TO ROW STATUS 03A2 99 C8 00 STA RS Y BYTE 03A5 60 RTS 81 ae w 03A6 03A9 05 0 5 0281 0382 0585 0385 0385 0587 03589 0388 0580 03BF 03C1 03C3 03C4 03C6 03C7 03C8 05CC 03 0200 0201 0203 0305 0307 03DA Q3DC 0502 03 2 0355 03 8 03EB 03EE 0321 03 2 0325 0327 03279 05FB 05FD O3FF b iN SUBROUT INE 20 4 03 BACK JSR DISPLAY DISPLAY LOOP 20 40 1 JSR UNLESS F0 F8 BEQ BACK A KEY IS PRESSED 20 6A 1F JSR KEYS THEN GET A NUMBER AA TAX RECOVER THE FLAGS 60 RTS MPT Pipi ocd SUBROUT INE RANDOM D8 CLD 38 SEC GENERATES A A9 Dh LDA R 1 RANDOM NUMBER 65 D7 ADC R 4 CTHANKS TO J BUTTERFIELD 65 D8 ADC R 5 85 D3 STA R A2 04 LDX 04 B5 D3 ROLL LDA R X 95 D4 STA R 1 X 2 DEX 10 F9 BPL ROLL 7 60 RTS EA NOP SUBROUTINE PS LOAD 85 D9 PSL STA TEMP A2 09 LDX 09 f 16 DB XLP ASL PS X SHIFT PREVIOUS DATA 16 DB ASL PS X OUT OF THE WAY CA DEX DO F9 BNE XLP A0 08 LDY 08 A5 D9 YLP LDA TEMP D9 C8 00 CMP RS Y COUNT THE TIMES AN OPEN 00 12 BNE NOCT SQUARE FITS THE BE 17 01 LDX 501 TEST PARAMETER 20 40 01 JSR 1 BE 1F 01 LDX SQ2 Y 20 40 01 JSR 1 BE 27 01 LDX 503 20 40 01 JSR 1 88 NOCT DEY DO E4 BNE YLP 60 RTS SUBROUTINE RANDOM PLAYS 20 83 03 RPLA
101. MBER FROM 01 TO 98 THE START THE FIRST FOUR DIGITS SHOW THE HIGH AND LOW BOUNDS OF THE NUMBER 99 HIGH AND 00 LOW AS GUESSES ARE ENTERED ENTER THE GUESS AND PRESS A FOR ATTEMPT THE BOUNDS CHANGE AS YOU ARE NARROWING DOWN THE POSSIBILITIES FOR EXAMPLE GUESS 32 AND THE DISPLAY MIGHT CHANGE TO 32 00 MEANING THAT THE COMPUTER S SECRET NUMBER IS BETWEEN THESE VALUES AFTER EACH LEGAL GUESS THE COMPUTER SHOWS THE NUMBER OF ATTEMPTS MADE SO FAR ONE PLAYER GAME TRY GET THE MYSTERY NUMBER IN SIX ATTEMPTS MULTI PLAYER GAME EACH PLAYER TRIES TO AVOID GUESSING THE MYSTERY NUMBER THE CORRECT GUESSER LOSES AND IS OUT AER epi ena Doc Xo 5 4 0231 85 E2 STA LAST 0200 F8 T START SED 7 0201 A5 EO TOP LDA RND generate random 0203 38 SEC 01 to 98 0204 69 00 0 0206 2 01 LDX 1 overflow at 99 i zo 0208 C9 99 CMP 99 i 020 0 01 OVRO 020C 8A 3 020D 85 EO OVRO STA RND 5 020 20 40 IF JSR KEYIN 0212 DO ED BNE TOP i 0214 D8 CLD initialize 0215 9 99 LDA 8599 hi 0217 85 5 0219 00 LDA 0 I 021 85 5 10 5 021D A2 RSET LDX A0 guess counter 021 86 F9 NSET STX INH 0221 86 1 STX NGUESS k 0223 20 1F 1F GUESS JSR SCANDS light display 0226 20 6A 1 JSR GETKEY test key 0229 C9 13 13 go key 022B D3 BEQ START
102. O PLAYERS BY DEPRESSING KEYS 1 OR 2 RESPECTIVELY NUMBER THE LEFT FOUR DIGITS SHOW MINUTES AND SECONDS MAXIMUM TIME IS 99 MINUTES 59 SEC BE FINELY TUNED BY CHANGING THE VALUE OF WORD 027F INCREASE BY 1 SLOWS THE CLOCK BY APPROXIMATELY 6 SEC 24 HOURS AND VICE VERSA 0200 AQ 00 LDA 00 0202 AA TAX 0203 9D 00 00 ZERO STA 0000 X 0206 INX 0207 DO FA BNE ZERO 0209 20 1F 1F DISP JSR SCANDS 020C 20 6A 1 JSR GETKEY 020F C9 02 02 0211 00 F6 BNE DISP 0213 A9 01 LOOP LDA 01 0215 85 04 STA 0004 0217 20 60 02 JSR TIME 021A 20 31 02 JSR SAVE 021D A9 02 LDA 02 021F 85 D4 STA 0004 0221 20 60 02 JSR TIME 0224 18 CLC 0225 5 F9 LDA 00 9 0227 6901 ADC 01 0229 85 F9 STA 00 9 022B 20 31 02 JSR SAVE 022E 13 02 JMP LOOP xxx SAVE TIME INDICATED 0231 AQ 02 SAVE LDA 8502 0233 C5 04 CMP 00D4 0235 DO 11 BNE CLK1 0257 AS FB LDA 00FB 0239 85 D2 STA 00D2 023B 5 FA LDA 00 023D 85 D3 STA 0003 023F 5 DO LDA 0000 0241 85 FB STA 00 0243 AS 01 LDA 0001 0245 85 STA 00 0247 60 RTS 0248 As CLK1 LDA 00 024A 85 DO STA 0000 024C 5 FA LDA 00 024E 85 01 STA 0001 0250 A5 02 LDA 0002 0252 85 STA 00 0254 A5 D3 LDA 00D3 0256 85 FA STA 00FA 0258 60 RTS 50 THE RIGHT TWO DIGITS SHOW THE MOVE THE CLOCK PROGRAM CAN ZERO ALL OF PAGE ZERO DISPLAY ZEROS KEY PRESSED KEY 2 NO WAIT TILL 2 DOWN FLAG TO 1 CCLOCK 41 TO RUND GET CLOCK RUNNING SAVE TIME ON DISPLAY FLAG TO 2 CCL
103. OCK 42 TO RUND GET OTHER CLOCK RUNNING e INCREMENT MOVE NUMBER SAVE CLOCK 2 TIME BACK TO CLOCK 1 SUBROUTINE CLOCK 2 NO STORE FOR CLOCK 1 STORE VALUES FOR CLOCK 2 IN 0002 AND 00D5 eee LOAD DISPLAY WITH VALUES FOR CLOCK 1 STORE VALUES FOR CLOCK 1 IN 0000 AND 00D1 LOAD DISPLAY WITH VALUES FOR CLOCK 2 kuu adi o uns da i CLOCK ADVANCE SUBROUTINE Xxx 0260 F8 TIME SED SET DECIMAL MODE 0261 AQ 04 LDA 504 TIME MULTIPLIER TO 4 0263 85 05 STA 00D5 0265 9 FO LOAD LDA 5 0 SET TIMER 0267 8D 07 17 STA 1707 026A 20 1F 1F LITE JSR SCANDS DISPLAY CLOCK 026D 20 6A 1F JSR GETKEY GET KEYBOARD ENTRY 0270 C5 D4 CMP 000 EQUAL TO FLAG 0272 00 01 NO TIME OUT THEN UPDATE 0275 60 RTS YES RETURN FROM SUBR 0275 2C 07 17 WAIT BIT 1707 TIME DONE 0278 10 FO BPL LITE NOT YET 027A C6 05 DEC 00D5 DECREMENT TIME MULT 027C DO E7 BNE LOAD NOT ZERO RESET TIMER 027E A9 BF LDA BF LAST LITTLE BIT OF TIME 0280 8D 06 17 STA 1706 INTO TIMER 0283 2C 07 17 TINY BIT 1707 DONE 0286 10 FB BPL TINY NO 0288 18 CLC SECOND ADDED 0289 As FA LDA 00 TO CLOCK 028B 69 01 ADC 3 01 028D 85 FA STA 00 CCENTER TWO DIGITS 028F C9 60 8560 A MINUTE UP 0291 DO 05 NOMN NOT YET 0293 38 SEC YES SEC TO ZERO 0294 AQ 00 f LDA 500 0296 85 FA STA 00 0298 5 NOMN LDA 00 MINUTES INCREMENTED 029A 69 00 ADC
104. PE NOT YET 62 k 0248 F8 ADD1 SED 024C gt 18 CLC INCREASE SCORE 02900 B5F9 LDA 00 9 BY ONE 024F 69 01 501 0251 95 F9 STA 00 9 0253 8A TXA INDEX TO OTHER 0254 49 02 EOR 02 SIDE 0256 AA TAX 0257 F8 LOS1 SED DECREASE SCORE 0258 38 SEC BY ONE 0259 B5 F9 LDA 00F9 X 0258 9 01 SBC 01 025D 95 F9 STA 00F9 X 025F FO 0A BEQ FIN GO TO FIN IF ZERO 0261 20 71 02 WAIT JSR LITE WAIT FOR SWITCH 0264 20 40 IF JSR KEYIN TO BE RELEASED 0267 00 F8 BNE WAIT 0269 9B BEQ RAND THEN START NEW DELAY 0268 20 71 02 FIN SR LITE FINISHED LOOP 026E B8 LV 026F 50 FA BVC FIN UNCOND JUMP DISPLAY SUBROUTINE 454441914 0271 97 LDA 7F 0273 8041 17 STA SADD 45 0276 A2 09 LDX 8509 INIT DIGIT 0278 5 FB LDA 00 027A 20 8B 02 JSR 2HEX 0270 5 FA LDA 00 GET CENTER DIGITS 027F 20 HE IF JSR CONVX CONVERT NONHEX CHAR 0282 20 1F JSR CONVX TWO OF THEM 0285 A5 F9 LDA 00F9 0287 20 8B 02 JSR 2HEX 028A 60 RTS CHARACTER CONVERSION SUBROUTINE 2999 0288 2 028C HA LSR SUBROUTINE TO CONVERT 0280 HA LSR ONE WORD TO 2 028E LSR A CHARACTERS 028F 4A LSR A 0290 FO BEQ ZBLK 0292 20 48 IF JSR CONVD 0295 98 2NDC TYA SECOND CHARACTER 0296 29 OF AND 0 0298 20 48 1F JSR CONVD 029B 60 RTS 029C AQ 80 ZBLK LDA 80 BLANK LEADING ZEROS 029E 84 FC STY 00 0240 20 1F JSR CONVX CONVERT NONHEX CHAR 02A3 B8 CLV 02A4 50 EF
105. R 0270 E6 B5 TURN INC PLAH COUNT THE PLAYS 0272 A5 DB LDA MODE 5 TURN 0274 00 17 BNE WAIT 5 0276 20 A6 03 KEY JSR KEYS PLAYER S 0279 FO FB BEQ KEY GET A KEY 027B C9 OA 50 OVER 9 0270 F7 BCS KEY GET ANOTHER 027F AA TAX SE IT AS AN INDEX 0280 B BF LDY DSPL X SEE IF SQUARE S OPEN 0282 00 F2 BNE KEY NO TRY AGAIN 0284 A9 40 LDA 40 YES MARK IT FOR 0286 20 47 01 JSR UPDATE PLAYER 0289 6 DB INC MODE KIM S NEXT 028B DO BNE PVAL BUT FIRST CK FOR WIN 028D 20 4C 03 WAIT JSR DISPLAY HOLD KIM BACK 0290 E6 D1 INC LPCNT A LITTLE 0292 00 F9 BNE WAIT UPDATE AND 0294 9 08 LDA 4508 THEN CHECK THE 0296 20 C8 03 JSR PSLD BOARD 0299 9 02 LDA 02 0298 20 C8 03 JSR PSLD 029E A9 05 LDA 04 02A0 20 C8 03 JSR PSLD 02A3 9 01 LDA 01 02A5 20 C8 03 JSR PSLD 02A8 AQ CO LDA 0 WINNING PLAY FOR KIM 02 20 30 01 JSR GETPLA 02AD DO 43 BNE PLAY YES MAKE IT 02AF 9 30 LDA 8530 2 IN A ROW FOR 02B1 20 30 01 JSR GETPLA PLAYER 0288 DO 3C BNE PLAY YES BLOCK IT 0286 9 08 LDA 508 _ POSSIBLE SQUEEZE 02B8 20 30 01 JSR GETPLA PLAY FOR KIM 02BB DO 35 BNE PLAY YES DO IT 02BD 20 B3 03 IPLA JSR RAND HOW MUCH SMARTS 02CO 29 OF AND 0F NEEDED 0202 C5 02 IQ KIM S I Q 02Ch 1F BCS DUMB TOO LOW BAD MOVES 02C6 B5 LDY PLAC SMART 79 Cau iu caida 02C8 02CA 02CC 02CE 02D0 02D2 0204 0206 0208 02DA 02DC 02DF 02 1 02 3 02 5
106. RA TEMP repeat the digit 0014 85 F9 STA INH put 0016 85 FA STA POINTL einto 0018 85 FB STA POINTH display 001A 20 IF 1F LIGHT JSR SCANDS light display 0012 20 6A 1 JSR GETKEY test keys 0020 CS FF CMP TEMP right key 0022 FO DC BEQ START yes blank amp rpeat 002 DO Fy BNE LIGHT The random number used in this program is taken from the KIM timer This timer runs continuously and might be anywhere between OO and FF at the instant we push the button We use the four left hand high order bits of the timer to produce the next digit Be sure that is not in decimal mode when you run this vrogram set address OOFl to 00 before starting If you forget you might find that the alphabetic keys A to F don t work right Exercises can you make the program clear decimal mode automatically How about a counter to record the number of correct keystrokes you have made That way you could time yourself to see how many keys you can get right in 60 seconds The count could be shown in the two right hand digits of the display Do you think it should be in decimal or hexadecimal 72 4 KIM NIM oA Here s a jumbo NIM that s good for all skill levels Why Because KIM matches wits with you literally Play a duffer s game and KIM will make lots of errors too Start winning a few and KIM will move up to the master player level Hit GO and several digits on the KIM display will light Each lit digit represents a pile of
107. ROLL 7 PUSH THE 60 BUTTON ONLY ON THE FIRST ROLL FOR SUBSEQUENT ROLLS PUSH ANOTHER BUTTON 0200 D8 START C D 0201 20 40 iF J 3 KEYIN 0204 20 6A 1F JSR GETKEY 0207 C5 40 LAST 0209 FO 79 BEQ LIGHT same key as before 020B 85 40 STA LAST 020D 49 15 EOR 15 test 020F 85 41 STA FLAG into flag 0211 C9 06 6 GO key 0213 DO 05 BNE NOGO nope 0215 A9 10 LDA 10 yes 10 0217 20 9 02 JSR DOBUX put in window 021A AD Ol 17 NOGO LDA TIMER random value 0210 A2 CO LDX CO divide by 6 O21F 86 STX DIVR 0221 A2 05 LDX 5 0223 C5 RNDLP DIVR divide 0225 90 02 BCC RNDOV 0227 E5 SBC DIVR digit 0229 46 RNDOV LSR DIVR 022B CA DEX 022 10 F5 BPL RNDLP 022 AA TAX die 0 5 022F E8 INX die 1 6 0230 BD E7 iF LDA TABLE X segment 0233 Ah 41 LDY FLAG which die 0235 FO O6 BEQ PLAY second 0237 86 42 STX DIE first save it 0239 85 43 STA WINDX amp segment 023B DO 47 BNE LIGHT unconditional 023D 85 47 PLAY STA WINDOW 1 show die 023F A5 43 LDA WINDX other 0241 85 46 STA WINDOW one 0243 A5 44 LDA BUX out of dough 59 4 0215 0247 0249 0248 0240 O24F 0251 0253 0255 0257 0259 0258 0250 025F 0260 0263 0265 0267 0269 0268 0260 026F 0270 0273 0275 0277 0279 0278 0270 027 0280 0281 0284 0286 0288 028A 0286 028E 0291 0293 0295 0297 029A 029D 029F 0241 02A3 02 02 6 02 9 02 02 2 02 02
108. SK PUT HORSE IN NEXT DIGIT RIGHT REACHED RIGHT SIDE NOT YET OFF RIGHT SIDE CHANGE LAP CHECK LAP COUNTER IF ZERO LAST LAP w 0256 0258 0259 025B 025D 025F 0260 0262 0264 0266 0268 026 026C 026D 026F 0271 0273 0275 0277 0279 027C 027E 0281 0283 0285 0288 0288 0280 028F 0292 0294 0296 0298 029A 029C 029F 02A2 02A4 02A6 02A9 02 02 02AD 02AF 02B1 02B4 02B5 0287 0289 02BA 02BC 02BE 02 0 02 2 89 9 C5 01 9A 99 8C 8C 2A 02 00 02 00 02 02 02 NLAP DOWN STOR LAST POOP NOPO FAST SKIP LDX SEC LDA SBC STA DEX BPL LDX LDA STA LDA STA DEX BNE DEC BNE LDA ORA STA LDA BEQ JSR AND BNE STA JSR AND STA LDA BMI AND CMP BCS LDA STA JSR 3 02 0083 X 506 0083 X DOWN 8506 007C X 0076 X 580 007C X STOR 008F POOP 0081 506 0081 0089 Y NOPO RAND 3C FAST 0089 Y RAND 538 009 008C Y FAST 538 009 FAST 0089 Y KEYIN 5 0099 02 0 5 0089 009 RAND 4 01 009A 0099 008C X 008C X 0086 X NEXT 70 TO NEW LAP SHIFT ALL HORSE DIGIT POSITIONS SIX PLACES DOWN A ALSO SHIFT DIGIT CONTENTS INTO STORAGE AREA AND CLEAR DISPLAY AREA DEC LAP COUNTER NOT LAST CONTINUE LAST LAP PUT FINISH LINE IN LAST DIGIT HORSE Y POOP FLAG HORSE NOT POOPED POOPED BUT
109. SSEMBLER 65XX 1 0 PAGE 01 5 XXXXXXYYYXETYEXEXETEEXXEZENXEKEKEEXXY 0030 ONE ARMED BANDIT HERE H 0040 BY JIM BUTTERFIELD x 0050 0060 0070 0201 WINDOW 0000 DISPLAY WINDOW 0080 02D1 0005 CASH CACHE 0090 0201 ARROW 8 0006 0100 02 1 RWD 0007 REWARD 0110 0251 STALLA 0008 WAIT WHILE 0120 02D1 TUMBLE 0009 0130 0140 LINKAGES TO KIM 0150 0160 02D1 KEYIN 1F4O IS KEY DEPRESSED 0170 0201 PADD 1741 0180 0201 SAD 1740 0190 0201 SBD 1742 0200 0251 TABLE 1FE7 7 SEG 34 0210 0220 MAIN PROGRAM 0230 0240 0200 BANDIT ORG 0200 0250 0200 A9 25 GO LDAIM 25 GIVE HIM 25 0260 0202 85 05 STA AMT TO START WITH 0270 0204 20 02 JSR CVAMT AND SHOW TO HIM 0280 0207 A9 00 LDAIM 00 RESET ARROW 0290 0209 85 06 STA ARROW 0300 0310 MAIN DISPLAY LOOP 0320 0330 0208 20 8D 02 JSR DISPLY DISPLAY UNTIL 0340 020 DO FB BNE GO IS RELEASED 0350 0210 E6 09 ROLL INC TUMBLE RANDOMIZE TUMBLE 0360 0212 20 8D 02 JSR DISPLY DISPLAY UNTIL 0370 0215 FO F9 BEQ ROLL KEY IS HIT 0380 0390 0217 A9 03 LDAIM 03 0400 0219 85 06 STA ARROW 0410 021B F8 SED 0420 021C 38 SEC 0430 021D A5 05 LDA 0440 021 EO 01 SBCIM 01 CHARGE ONE BUCK 0450 0221 85 05 STA AMT 0460 0223 20 BA 02 JSR CVAMT CONVERT FOR LED 0470 0226 26 09 ROL TUMBLE 0480
110. STA POINTR 0210 38 RAND SEC one plus 0211 A5 13 LDA RND 1 three previous 0213 65 16 ADC RND 4 random numbers 0215 65 17 ADC RND 5 0217 85 12 STA RND new random value 0219 A2 04 LDX 4 021B B5 12 RLP LDA RND X move random numbers over 0210 95 13 STA RND 1 X O21F CA DEX 0220 10 F9 BPL RLP 0222 A6 10 LDX POINTR 0224 CO LDY CO divide by 6 0226 84 11 STY MOD keeping remainder 0228 AO 06 LDY 6 022A C5 11 SET CMP MOD 022C 90 02 BCC PASS 022 E5 il SBC MOD 0230 46 11 PASS LSR MOD 0232 88 DEY 0233 DO F5 BNE SET continue division 0235 18 CLC 0236 69 OA ADC 0A random value A to F 29 CONG 0238 023A 023C 023E 0240 0242 0214 0246 0248 0249 O24B 024E 0250 0253 0255 0257 0259 0258 025D 025F 0261 0264 0266 0268 026A 026C 026D 026F 0271 0274 0276 0277 0279 027B 027D 027E 0280 0282 0284 0286 0289 028B 028D 0290 0292 0294 0296 0297 0299 029B 029D 029P 02A0 95 C6 10 C6 30 A2 95 CA 10 00 10 D2 18 00 oC 04 02 02 1F 1F 00 00 GUESS WIPE WAIT RESUME NOTEX STEP LOOK GOT ON STA DEC BPL DEC BMI LDA LDX STA DEX BPL SECRET X POINTR RAND COUNT new guess starts here FINISH ten guesses 0 2 0C clear from WINDOW WINDOW X to POINTR WIPE WAIT FOR KEY TO BE DEPRESSED JSR BEQ JSR BEQ LDA BEQ AND EOR BEQ BNE JSR CMP BCS CMP BCC TAY LDX IN
111. STA TIMEF f 03C9 581 DSP LDA SEC Start here if clock is running O3CB 85 9 STA INH display clock on KIM O3CD A582 LDA MIN O3CF 85FA STA POINTL 0501 A583 LDA HR 0303 85 STA POINTH 0305 201 JSR SCANDS 03D8 200003 JSR KIM escape to KIM 0508 202005 JSR BEEP sound on the hour O3DE EAEAEA 03 1 O3E4 EAEAEA O3E7 EAEAEA O3EA EAEAEA O3ED EAEAEA O3FO EAEAEA O3F3 EAEAEA O3F6 EAEAEA 05 9 EAEAEA 03 905 JMP DSP Hex Dump Clock 0300 20 C9 01 D OD 20 IF IF 20 6A C9 01 DO 0310 03 05 60 0320 AS 82 DO 29 5 81 38 E5 83 10 24 5 80 DO 06 AD 0330 IE 85 70 D A A9 01 C5 80 DO 14 9 28 85 70 9 0340 01 8D 03 17 02 17 5 70 10 FD 30 DC 60 0360 48 48 98 48 AD 83 8D 04 17 20 C 17 10 FB E6 0370 80 A9 04 C5 80 DO 38 AD BB 85 80 18 FB AS 81 69 0380 91 85 81 C9 44 DO 28 A9 00 85 81 5 82 18 69 01 0390 85 82 C9 60 18719 A9 00 85 82 5 83 18 69 01 85 2 83 C9 12 D 02 84 C9 13 DO 04 9 01 85 83 LS 03 0 A9 8D 17 68 A8 68 68 40 93 0 9 00 85 80 9 FA 8D OF 17 AS 81 85 F9 AS 82 85 03 0 FA 83 85 20 1 IF 20 00 03 20 20 03 EA EA 03 EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA EA 4C C9 3 55 CODE TEST DESCRIPTION THIS PROGRAM REQUIRES THAT A SPEAKER BE HOOKED TO AS IN FIGURE 5 1 OF THE KIM MANUAL WHEN
112. TINE 02B2 A6 CA LDX 00CA YOUR ROOM AS INDEX 0284 B5 50 LDA 0050 X NEXT ROOMS ARE LOADED 02B6 85 C6 STA 00C6 INTO 00C6 00C9 FROM 0288 85 60 LDA 0060 X TABLES 02BA 85 C7 STA 00C7 02BC 85 70 LDA 0070 X 02BE 85 C8 STA 00C8 02 0 85 80 LDA 0080 0202 85 C9 STA 00C9 02 60 RTS Xxx CHECK VALID SUBROUTINE 02C5 A2 03 VALID LDX 503 CHECK IF 02C7 D5 C6 CMP 00C6 X MATCHS 00C6 00C9 02C9 FO 03 BEQ YVAL YES VALID ROOM 02CB CA DEX 02CC 10 F9 BPL NXTV 02 60 YVAL RTS LOSE SUBROUTINE 02CF AO 01 LOSE LDY 5501 DISPLAY REASON LOST 0201 20 00 02 JSR SCAN THEN YOU LOSE 0204 00 LDY 500 02D6 AQ AC LDA 45 0208 20 00 02 JSR SCAN 02DB LC D4 02 JMP REPT R GAS LEFT MESSAGE 02DE EQ LDY 00 0 GET CANS LEFT 02E0 B9 E7 IF LDA 1FE7 Y GET CONVERSION 02 85 9F STA 09 STORE IN MESSAGE 02 5 A0 00 LDY 8500 PAGE ZERO 02E7 A9 90 LDA 90 DISPLAY CANS OF GAS 02E9 20 00 02 m UJSR SCAN LEFT MESSAGE 02 4C 2C 03 JMP ADR kkkk Messages kkkkk 0000 80 EE DC BE 80 F7 DO F9 80 84 D4 80 EF 80 CO 80 0010 F8 D4 04 F9 B8 ED 80 B8 F9 F7 DE 80 F8 DC 80 0020 FD FF F7 B9 80 00 80 DC DC F3 ED 80 CO 80 FC BE 0050 B7 F9 DE 80 F7 80 9C BE B7 BE ED 80 80 00 Next Room List 0050 02 02 00 01 01 00 03 0 00 06 07 00 09 01 04 0060 05 05 01 02 03 02 05 06 05 08 09 08 0B OC 08 07 0070 08 04 03 0 07 06 07 09 OF OC OD OE OC 0A 0080
113. To The Moon real time lunar lander program for KIM April 1977 p 100 Navigation With 0 Software details for a phase tracking loop filter using Jolt or KIM June 1977 p 18 Designing Multichannel Analog Interfaces Hardware and 6502 software for 8 channel analog 1 0 June 1977 p 46 Teaching KIM To Hardware and software for hooking KIM up to a Selectric June 197 p 76 Come Fly With KIM Hardware and software for interfacing Fly Paper Tape Reader to KIM July 1977 p 126 Giving KIM Some Fancy Jewels How to outboard KIM s seven segment displays j 1 DR DOBBS March 1976 p 17 6502 Breakpoint Routine August 1976 p 17 6502 Floating Point Routine August 1976 p 20 Monitor For The 6502 173 C mem ws Ye August 1976 p 21 Lunar Lander For The 6502 September 1976 p 22 6502 Disassembler September 1976 p 26 A 6502 Number Game September 1976 p 33 6502 String Output Routine November 1976 p 50 6502 String Output Routine November 1976 p 57 6502 Floating Point Errata February 1977 p 8 More 6502 String Output Routine INTERFACE AGE September 1976 p 15 6502 Disassembler October 1976 p 65 Interfacing The Apple Computer How to hook a SWIPPR 40 to the Apple 6502 November 1976 p 12 Build A Simple A D Hardware and 6502 software for simple joystick or whatever interface November 1976 p 105 Floatin
114. User Notes from which much of this material was taken A special thanks to Earl Nied for the use of his KIM interfaced Selectric The KIM 1 microcomputer is manufactured by Commodore MOS Technol ogy 950 Rittenhouse Road Norristown Pennsylvania 19401 It may be obtained directly from the manufacturer or from many hobbyist computer retail stores At the time of writing the complete KIM 1 system less power supply sells for 245 All programs in this book run on the basic KIM 1 system two require an audio amplifier BEGINNER S GUIDE TO PROGRAMMING a m eu m PU a er wer kanren ieee BEGINNER S GUIDE KIM PROGRAMMING Running programs can be fun But writing programs can be even more fun and exasperating and exhilirating too When you get the hang of it and it will take time you ll be able to create your own games diversions or useful routines This section tries to introduce you to the mechanics of programming so you can find your own way at your own speed Don t be afraid to use ideas from other parts of this book If you like try changing parts of a program or two and see what happens And you can borrow whole sections of coding from another program if it does something you want LOOKING AT MEMORY Random Access Memory If you ve just turned your KIM system on press the RS Reset button to get things started Hit the following keys AD for
115. X 022 95 D2 STA 0231 DEX 3 values from INIT 0232 10 F8 BPL SETUP pick out specific part of maze 0234 AO OB MAP LDY 11 0236 Bl D2 GETMOR LDA MZPT Y 6 rows x 2 0238 99 D8 00 STA WORK Y 023B 88 DEY 023C 10 F8 BPL GETMOR shift for vertical position gt 023 2 0 LDX 10 for each of 6 rows 0240 A4 D4 NXDIG LDY POSIT Shift Y positions 0242 A9 FF LDA SFF filling with walls 0244 38 REROL SEC both sides 0245 36 D9 ROL WORK 1 X 0247 36 D8 ROL WORK X roll em 0249 2A ROL A 024A 88 DEY 024B DO F7 BNE REROL 88 NINE n o hi rl k 4 P RU AC x Bk PAIR UN calculate segments 024D 29 07 AND 47 024F 8 TAY 0250 B9 C6 02 LDA TABl Y 3 bits to segment 0253 95 D8 STA WORK X Stored 0255 CA DEX I 0256 CA DEX 0257 10 E7 BPL NXDIG test flasher 0259 C6 D5 LIGHT DEC PLUG time out 025B 10 0A BPL MUG 025 9 05 5 reset 025F 85 D5 STA PLUG 0261 A5 DE LDA WORK 6 0263 49 40 EOR 540 flip 0265 85 DE STA WORK 6 flasher light display 0267 A9 7F MUG LDA S7F open the gate 0269 8D 41 17 STA SADD 026C AO 09 LDY 09 026 A2 OA LDX 10 0270 5 D8 SHOW LDA WORK X tiptoe thru 0272 8D 40 17 STA SAD the segments 0275 8C 42 17 STY 580 s 0278 C6 D6 71 DEC STALL pausing 027A DO FC BNE 5 1 027C C8 IN 027M C8 IN 027E CA DEX 027F CA DE
116. X 0280 10 EE BPL SHOW test new key depression 0282 20 40 1 JSR KEYIN set dir reg 0285 20 1F JSR GETKEY 0288 C5 D7 CMP SOK same as last 028A CD BEO LIGHT 028C 85 D7 STA SOK test which key 028E A2 04 LDX 4 5 items in table 0290 DD CE 02 SCAN CMP TAB2 X 0293 05 BEQ FOUND 0295 CA DEX 0296 10 F8 BPL SCAN 0298 30 BC LIGHT 029A CA FOUND DEX 029B 30 8D SLINK go key 029D BC D3 02 LDY TAB3 X 02A0 B9 D8 00 LDA WORK Y 02A3 3D D7 02 AND TAB4 X 02 DO Bl BNE LIGHT move 02 8 CA DEX 02 9 10 04 BPL NOTUP 02 C6 D4 DEC POSIT upward move 02AD DO 85 MLINK BNE MAP l o n g branch 89 02AF 0 4 NOTUP BNE SIDEWY 02B1 E6 D4 I INC downward move 0283 DO F8 BNE MLINK 02B5 CA SIDEWY DEX 02B6 DO 06 BNE LEFT 02B8 C6 D2 RIGHT DEC MZPT right move 02BA C6 D2 DEC MZPT 02BC DO EF BNE MLINK 2 E6 D2 LEFT INC MZPT left move 02 0 D2 INC MZPT 02C2 DO E9 BNE MLINK 02C4 FO F2 gt BEQ RIGHT tables follow in Hex format 02C6 1 00 08 40 48 01 09 41 49 02CE TAB2 13 09 01 06 04 p 02D3 TAB3 06 06 04 08 gt 0207 TAB4 01 08 40 40 i 02DB INIT DA 02 08 E 02DE MAZE FF FF 04 00 F5 7F 15 00 41 FE 5F 04 51 7D 5D 04 51 B6 54 14 F7 D5 04 54 7F 5E 01 00 FD FF 00 00 00 00 00 00 00 00 00 00 00 0308 05 10 10 14 18 17 10 0310 1 01 04 80 10 80 02 40 40 7 0318 2 02 02 40 01 1004 80 10 end of program
117. X CA DEX DO FB BNE CLOP AQ 40 1 044510 ee INITIALIZE DISPLAY 85 D4 STA 0008 A9 10 LDA 10 INIT STARFIELD 85 DE STA 00DE REGISTERS LSR 85 DF STA 000 20 DD 02 JSR DISP DISPLAY D3 LDX 0005 MODE 50 DELA MODE 1 DELAY AND UPDATE 20 40 1F JSR 1F40 MODE 0 GET KEY FO F4 BEQ MLOP NO KEY RETURN 20 40 1F JSR 1F40 KEY STILL PRESSED FO EF BEQ MLOP NO RETURN 20 JSR GETKEY YES GET KEY cg 13 CMP 13 GO KEY FO D4 BEQ BEGN YES START AGAIN C9 0A 50 OVER 9 10 BPL YES TRY AGAIN A8 TAY USE AS INDEX 103 0231 0233 0235 0238 023A 023D 023F 0241 0243 0245 0247 0249 024B 0240 025F 0251 0252 0255 0255 0257 0259 025A 025D 025F 0261 0264 0266 0268 026B 026D 0270 0271 0273 0275 0278 0279 027B 027D 027F 0281 0282 0285 0285 0287 0289 028A 028B 028D 028F 0290 0292 DE DE DF DF DE 06 02 02 02 02 02 02 02 SKIP HOLE STAR DELA LOWF BEQ STA JSR STA LDA CMP BMI BIT BNE BEQ BIT BNE LDA STA BNE SED SEC LDA ADC STA CLD JSR STA LDA JSR STA INC JMP LDY JSR DEY BNE MLOP 0001 SEG 0000 02CA Y 506 SKIP 00DF STAR HOLE 00DE STAR 576 0000 MLOP 8500 0005 0005 SEG 00DA 00D5 LEFT 00D8 0003 MLOP 500 DISP DELA LDX 00D1 LDA TAY CPX BMI EOR STA TYA LDY ASL EOR STA TYA LSR EOR STA ASL LDA LDX 02D3 X
118. X WINDOW 6 clear extreme left 027C FO 09 BEQ NOMOVE unconditional branch 027 2 FO COMING LDX 8 16 0280 B5 6C CMLOOP LDA WINDOW 12 X 0282 95 6B STA WINDOW 11 028 E8 INX 0285 30 F9 BMI CMLOOP 0287 A9 7F LDA 7F light KIM display 0289 8D 11 17 STA PADD 028C AO 13 LDY 13 028 2 05 LDX 5 six display digits 0290 B5 60 LITE LDA WINDOW X 0292 8D 10 17 STA SAD 0295 8C h2 17 STY SBD 0298 73 LITEX INC WAIT 029A DO FC BNE LITEX 029 88 88 CA DEY DEY DEX 029F 10 EF BPL LITE 02 1 hc OB 02 JMP TEST y index and animal pictures in hexadecimal form O2A AA BO B6 BC C2 C8 08 00 00 OO 00 00 01 61 61 40 00 00 0286 61 51 47 01 00 00 63 58 hE 00 00 00 71 1D hl 1F 01 OO O2C8 63 58 hC hO OO OO 65 FARMER BROWN Exercises 1 2 3 You can see that each animal occupies memory locations starting at O2AA the Ant and the last location must always be zero Can you make up your own animals The letters may not fit exactly but you can always invent names or use odd ones you could make an Aardvark a Burfle Cobra and on The game might be more fun if the animals went faster after while so that sooner or later they would just zip by The location that controls speed is at address 026A the lower the number the faster the animals will go So if you could arrange to have the program decrease this number automatically once in a while you d get amp nice spee
119. Y YOU ENTRY MAKING SURE ALL ARE DIFFERENT STORE IN 00 00 SET UP ADJACENT ROOM LIST HAZARDS IN ADJ ROOMS COMPARE EACH TO HAZARDS X CONTAINS MATCH INFO NO MATCH NO HAZARDS BATS NO BATS NEARBY MESSAGE PIT NO CPIT CLOSE MESSAGE MUST BE WUMPUS PAGE ONE DISPLAY HAZARD MESSAGE TRY NEXT ADJ ROOM FINISHED NO LOAD AND DISPLAY YOU ARE IN TUNNELS LEAD TO MESSAGE CFOUR NEXT ROOMS CONVERS ION PUT IN MESSAGE FINISHED NO LOCATION AND PAGE OF MESSAGE DISPLAY MESSAGE 0372 0375 0377 0379 057C 057E 037F 0381 0383 0385 0387 0389 038A 038C 038F 0390 0392 0394 0396 0398 039A Q39C Q39E 03 1 03A4 03A6 03A8 0 03AD 0581 03B4 0387 0589 05 05 03C1 03C3 03C5 03C8 03CB 05CE 0500 0301 0503 0305 0507 0509 0508 0300 0502 05E1 05E5 05 8F 02 00 02 99 02 00 02 16 03 CF 02 CF 02 00 02 C5 02 NXTG BATM PITM GASM ROOM JSR CMP BEQ JSR STA TXA BMI LDA LDX CMP BEQ DEX BPL JSR TXA DEBO 14 ROOM VALID 00CA ROOMS 00CA 504 00C1 X GASM NXTG ADJR BPL CPX BPL LDY LDA JSR JSR CMP BNE LDA JMP LDY LDA JSR JMP LDA JSR LDA JMP LDY LDA JSR JSR JSR STA TXA BMI LDA LDX STA CMP BEQ DEC BEQ LDX JSR JSR 503 501 500 526 SCAN MOVE 00CA ADJR 526 LOSE 8501 530 SCAN
120. YT stack 5 bytes 0023 95 FC STA POINTH 1 X into display 0025 E8 INX area 0026 30 F8 BMI RD 0028 20 1F 1 SHOW JSR SCANDS eeoand shine 002B DO D3 BNE GO until keyed 002D FO F9 BEQ SHOW at s all folks 118 0100 0102 0105 0108 010 010C 010E 0111 0113 0115 0118 011A 011D 0120 0123 How long does it take you to load a full 1 of KIM 1 memory Over two minutes And if you re going for memory expansion how long will it take you to load your 8K Twenty minutes Hold onto your hats Program HYPERTAPE will write fully compatible tapes in a fraction of the time You can load a full 1 in 21 seconds Fully compatible means this once you ve written a tape using HYPERTAPE you can read it back in using the normal KIM 1 program starting at 1873 as usual And the utilities and daagnostic programs work on this super compressed data e g DIRECTORY and VUTAPE You ll need some memory space for the program of course If you have memory expansion there ll be no problem finding space of course But if you re on the basic KIM 1 as Iam you ll have to squeeze in HYPERTAPE along with the programs you re dumping to tape I try to leave page 1 alone usually the stack can overwrite your program due to bugs so I stage HYPERTAPE in that area For the convenience of relocation the listing underlines those addresses that will need changing There are also four values needed in page zero
121. a number from your keyboard and type its square you need only write 50 INPUTA receive value a from keyboard 60 LET B A A means multiplication 70 PRINT THE SQUARE OF IS 80 STOP See how easy it is KIM must read each line character by character decide what it means inputting calculating printing or whatever and then perform that action KIM works hard but you don t 153 Text Editors It can be very handy to compose a number of lines of material such as a letter a program or general data put it into your KIM system save it permanently on tape or disk and then later recall it and change insert or delete information If you re writing a letter you can correct mistakes and insert new thoughts as they occur to you perhaps even generating several slightly different versions to mail to various people If you have a program you can correct bugs as you find them and insert new coding as needed Data files can be kept up to date Text Editors are very important with other software such as assemblers and interpreters often they are built in Mathematical Packages Each memory location in KIM can store a number from 0 to FF hexadecimal or 0 to 255 decimal Ther are no fractions and you have to make special arrangement for signed positive and negative numbers You can link memory locations together to hold larger numbers but extremely large numbers and fractions call for special mathematica
122. able to back up what is stored ona disk One disk is simply copied to another Since each disk may store over 1 4 million bytes you can see how time consuming this would be if you tried to read all information into memory and back out on another disk Smaller versions of floppies using a 5 diskette with less storage capacity are also available at somewhat lower prices Again you need not only the floppy drive and controller electronics but also the necessary software written for KIM The operating system software that goes with floppies is quite complex But then it s also very powerful 151 SOFTWARE TO EXPAND YOUR KIM In addition to building extra devices onto your KIM system like teletype display or more memory you can increase the power of your system with special programs called software The name software is often misunderstood Software strictly Speaking refers to programs that help you do the job They are helping not doing programs For example if you write a program to play a game that s not software it s called an application program for it actually does something But the programs that help your game such as the Monitor subroutines that you may call are software They don t do the job but they sure help Most of the extra software that we ll talk about here will require extra memory to be fitted to your KIM system Assemblers If you ve tried writing a progra
123. ables for op code indentification 018 OC 1F OD TABl 0C 81F 0D 587 4 1F FF 03 0192 87 1F FF 0195 03 0196 OC 19 08 2 OC 19 08 00 10 20 03 0199 00 10 20 019C 03 0190 02 FF FF TAB3 BYTE 02 FF FF 01 01 00 FF FE 0140 01 01 OO u 0143 FF FE Ju en Credit for the concept of RELOCATE goes to Stan Ockers who insisted that it was badly needed and maintained despite my misgivings that it should be quite straightforward to program He was right on both counts Hex Dump Relocate O 1 gt 3 y e ABC DE p 0110 D8 Bl 2 07 98 3D BE 01 SD 95 01 FQ 0120 03 D 9D 01 30 QD F 22 EA DO 02 E6 0130 88 DO F7 FO DA C8 30 09 C8 Bl EA 8 EA 0140 20 79 01 91 EA 88 8A 91 EA 03 10 DE C8 A6 EA 0150 AS 22 79 01 86 A2 FF EA 18 69 02 30 01 0160 8 86 18 65 EA AS 65 20 79 01 0170 38 ES EO 91 EA C8 10 Be 05 7 BO 11 CS ED D 0180 02 90 09 48 18 65 68 65 E9 60 BC 0190 IF D 87 IF FF 03 C 19 08 00 10 20 03 02 FF FF 01 8 01 01 00 133 USING PROGRAM RELOCATE an example Jim Butterfield Program RELOCATE is important and powerful But it takes a little getting used to Let s run through an example Follow along on your KIM if you like Suppose we d like to change program LUNAR LANDER When you run out of fue
124. ably random numbers and it won t lock up so that the same number starts coming out over and over again The numbers are scattered over the entire range of hexadecimal 00 to FF Statistician would observe that the numbers aren t completely unbiased since a given series of numbers will tend to favor odd or even numbers slightly But it s simple and works well in many applications Here s how it works Suppose the last five random numbers that we have produced were A B C D and E We ll make new random number by calculating B E 1 The one at the end is there so we don t get locked up on all zeros When we add all these together we may get a carry but we just ignore it That s all The new last five will be B D E and the new number keep everything straight we move all these over one place so that B goes where used to be and so on The program xxxx D8 RAND CLD clear decimal if needed xxxx 38 SEC carry adds value 1 xxxx 5 13 53 LDA RND 1 last value E xxxx 65 16 ADC B carry xxxx 65 17 ADC RND45 C 85 12 9 7 STA RND number xxxx A2 Oh 4 move 5 numbers E xxxx BS 125 RPL LDA RND X 9 95 135 STA RND 1 X move over 1 7 DEX 10 F9 BPL RPL all moved 209 0 lt The new random number will be in and RND and in RND 1 Note that you must use six values in page zero to hold the random s
125. and enter the hex value For example if all bits happen to be on the number you d enter is FF or if all the bits were If you re not yet at ease with the concept of bits and how they relate to hexadecimal numbering a few runs of this program will help a lot 0200 0201 0203 0205 0208 0208 0200 020 0211 0213 0215 0217 0219 0218 0210 021 0221 0223 0225 0227 0229 022 0220 022 0231 0233 0235 0237 0239 0238 023E 023F 0241 D8 9 85 20 01 1D iF 1 1 1 27 START MAIN DIGI NOKEY CLD LDA STA JSR JSR CMP BEQ STA CMP BEQ LDX BNE CMP BNE off you d enter 00 KIM rewards a correct answer with another problem 1 Set FLAG2 TAX LDA STA BNE CMP BNE TAX LDA STA BNE LDX BEQ LDA STA STA LDA TAX AND STA FLAG2 to new problem KEYIN set directnl reg GETKEY get key input PREV same as last time LIGHT yes skip PREV record new input 15 no key NOKEY yes brnch FLAG1 first digit found DIG1 yes check second SEED1 first digit match LIGHT no ignore input TABLE X change to segment FLAGI Store LIGHT and exit SEED2 second digit match LIGHT no ignore input TABLE X change to segment FLAG2 LIGHT FLAG2 problem solved LIGHT not yet skip 0 Clear FLAG1 for new problem FLAG2 TIMER get random value 0F extract last digit SEED2 and store 38 It s kind of fun Some of the bits 0213
126. at by now you have gained some appreciation for KIMs potential kkk kkk de e f gx 165 t POTPOURRI GUIDELINES FOR WRITING KIM PROGRAMS 1 4 S Use of Memory Wherever possible place your programs in pages 2 and 3 addresses 0200 to It s handy to keep page zero for variables values that change during program run and page one is best left alone because the program Stack uses it The Stack by the way only uses a few locations usually But a small program error can sometimes make the stack run wild which would destroy your page one data Your variables changeable data should be kept in page zero in locations 0000 to OOEE These addresses are easy to use since you can use zero page addressing modes which save you time and memory Program and constants Set up your programs in the following pattern first the main program starting at address 0200 or higher then your subroutines and finally your data Keep them all fairly close together so that when you dump the whole thing to cassette tape it won t take extra time to write the blank spaces in between Initial values Don t assume anything about the beginning values in your registers or in zero page If you want to be out of decimal mode and you usually do make your first command a CLD D8 If you want the accumulator to be zero load it with LDA 00 A9 00 Every zero page variable that nee
127. at your own speed Communicate with other KIM owners you ll have a lot of information to swap But most of ali have fun RECREATIONAL PROGRAMS Clear Decimal Mode Set 00 1 to OO before running these programs ADDITION DIRECTIONS HERE S A HANDY LITTLE ADDING MACHINE PROGRAM KIM BECOMES A SIX DIGIT ADDER CLEARS THE TOTAL SO YOU CAN START OVER THEN ENTER A NUMBER AND HIT THE PLUS KEY TO ADD IT TO THE PREVIOUS TOTAL IF YOU MAKE A MISTAKE IN ENTERING A NUMBER JUST HIT THE 0 KEY SEVERAL TIMES AND ROLL THE BAD NUMBER OUT BEFORE ENTERING THE CORRECTION NO OVERFLOW INDICATOR AND NO SUBTRACTION OR MULTIPLICATION MAYBE YOU WOULD LIKE TO TRY YOUR HAND AT ADDING THESE THE PROGRAM IS FULLY RELOCATABLE 0200 20 1 1F START JSR SCANDS light display 0203 20 6A 1F JSR GETKEY read keyboard 0206 C5 60 CMP PREV same as last time 0208 FO F6 BEQ START yes skip 020A 85 60 gt STA PREV no save new key 020C C9 OA 0A numeric key 020 90 29 BCC NUM yes branch 0210 C9 13 13 GO key 0212 FO 18 BEQ DOGO yes branch 021 C9 12 12 key 0216 DO BNE START no invalid key 0218 F8 18 SED CLC prepare to add 021A A2 FD LOX FD minus 3 3 digits 021C BS FC ADD LDA POINTH 1 X display digit 021 75 65 ADC ACCUM 3 X add total 0220 95 FC STA POINTH 1 X total to display 0222 95 65 STA ACCUM 3 X amp to total accum 022 E8 INX next digit 0225 30 F5 BMI ADD last digit
128. ature to trace out exactly what the program does But here are a few highlights When we load registers A and X in the first two instructions we don t want to load the contents of a memory location Instead we want the actual values 0 and 9 do this we use new kind of addressing called IMMEDIATE addressing Immediate addressing when we use it says Don t go to memory use this value Immediate addressing can be spotted two ways First note the sign that we use in writing the program that signals that we are using immediate mode adressing Secondly you may have noticed that the computer instruction called the Op Code has changed the previous program used code A5 to mean LDA now we re using A9 which also means LDA but signals immediate addressing You can and should use the SST feature to check that immediate addressing works as advertised The instruction at 0204 uses the X register for INDEXING That means that instead of storing the A value in address 30 the computer first calculates an effective address by adding the contents of the X register to the base address of 30 Since X contains 9 the first time through the effective address will be 30 9 or 39 and that s where we store our A value of 00 Later X will be decreased to a value of 8 so we ll store into address 38 14 Indexing seems complicated but remember that it s a very powerful feature of KIM Try to get the hang of it it s w
129. bytes of course Put 02 and 00 into addresses OOE8 and 00 9 respectively We re ready to go Be sure your vectors have been set properly at addresses 17FA to 17FF Then set address 0110 the start address of RELOCATE and press GO The display will stop showing 0114 EA confirming that RELOCATE ran properly Now check to see the whole program was properly converted by looking at the addresses OOEA B We put address 0200 there remember Now we ll see address O2CC stored there the address of the value FF we Stored to signal end of program Go back to 02CC where we stored FF and restore the original value of 45 We ve completed part I The addresses have been corrected for the move Let s go on to part II and actually move the program fo make room My favorite method is to use a tiny program to do the move itself For moving 1 to 256 bytes to a higher address I use the program A2 nn BD xx xx 9D tt tt CA DO F7 00 In the above nn is the number of bytes to be moved and and tttt are the from and to addresses of the data minus one Since we want to move aboui 160 bytes from block starting at O24E to a block starting at 0250 we code like this AO BD 02 9D 02 CA DO F7 OO This little program can be fitted in anywhere Let s put it in memory starting at address 0040 The final byte value 00 should end up in 0048 Now back to 0040 hit GO and your data program is moved over The tiny prog
130. calculator circuits Each of these ICs will drive up to 6 lights relays or what have you with the simple circuit shown below The six IC outputs act as sinks which requires that you connect one side of your electric load to the positive battery voltage and the other side to one of the IC outputs When the appropriate port is current will flow through your load when the port is off current will stop maximum current through each load is 200 mA MULTIPLE KIM INTERFACE 7 14 LOADS 3500 5 gt 5 RELAY SMALL lt 200mA LAMP Vp ELI de Di i E AC Control To go one step further we can show you how KIM can operate AC devices without relays However we would like to caution you that the power line voltage of 110 Volts AC and the low voltages in your KIM do not mix easily You may even achieve a non voluntary beautiful pyrotechnic display In other words if you are not careful in your soldering techniques and like to leave a few wires dangling just in case we would recommend that you skip the following paragraph The circuit we show here electrically separates KIM from the power line by means of a lamp photocell interface The amplified voltage from one of the KIM ports turns on an incandescent lamp or an LED which lowers the resistance of a photocell which then turns on the electronic TRIAC switch This simple and inexpensive circuit can easily control
131. could determine the number of bytes ina uctions is worked for all instructions except 54 Lea 332 18 pa 92 B2 D2 and F2 which blank the display he filling in the Bytes per Instruction table many patterns became obvious For example the ending with digits 8 and A could be summarized as having a bit pattern of 10 0 where x means don t care This covers all possibilities and when a number of this form is ANDed with 00001101 mask all the x bits the result will be 00001000 By doing this for all 0 illegal 1 and 3 byte instructions and having the 2 byte instructions whatever s left over I had the basis of semi disassembler The only odd byte length is that of 20 JSR which should be only 1 byte long Though this is not a full disassembler it has helped me to write several programs including itself To relocate the program change locations 374 6 379 B and 38E 390 to jump to the appropriate locations If you have a program in page or don t want to write on the stack change 397 and 39A to EA NOP To run the program store 00 in 17FA and 03 in 17FB Go to the beginning of your program and press ST You will then see the first instruction displayed If it is illegal the location and opcode will flash on and off In that case press RS To display the next instruction press Fro display the current address and opcode press 0 at any time backstep press When you have backstepp
132. d up feature You can t shoo the animal until it s completely entered the display but you can still catch it after it s partly left The game would be harder and maybe more fun if you could only shoo it while it was completely in the display Hint testing location 005F WINDOW 1 would tell you if an animal was on its way out on You d have a Target Practice game if you made the animal disappear instead of backing up when you pressed the right button With a little planning you ll find that this is quite easy to do XXXXX DUMP FARMER BROWN XXXXX 0200 2 D 86 6E 9 00 95 60 10 2 OB B5 60 DO 0210 10 F9 E6 6D AS 6C F 09 C6 6D C6 6E D 03 0220 4C 25 19 AD 04 17 4A 4A 4A 4A 4A C9 06 90 02 29 0230 03 18 69 A 85 6F BD 02 85 70 9 02 85 71 0240 S 70 99 66 00 88 10 F8 84 6C 2 05 BS 66 0250 13 10 F9 20 40 IF 20 IF CS 6F D 06 AS 0260 6C 10 02 E6 6C C6 72 D 1E 9 20 85 72 AS 6C 30 0270 D A2 A BS SA 95 5B CA D F9 86 5A F 09 A2 F 0280 BS 6 95 6B E8 30 F9 AY 7 8D 41 17 13 2 05 290 BS 60 8D 40 17 8C 42 17 73 D 88 88 CA 10 B2AG EF B 02 AA B B6 BC C2 C8 08 00 00 00 00 00 2 01 61 61 40 00 00 61 51 47 01 00 00 63 58 AE 00 g2co 00 00 71 ID 41 1 01 00 63 58 AC 40 00 00 66 9 L BY JIM BUTTERFIELD DESCRIPTION AN EASY GAME FOR ONE OR MORE PLAYERS KIM CHOOSES A SECRET NU
133. dd on extra memory in those areas Dedicating the processor to running the display in this manner also means that it is going to have to steal time from this job to run your programs This can slow things up a bit Keyboards The keyboard also doesn t have to come into the serial port Some video boards have a keyboard port built in Another possibility is the parallel I O ports on the KIM itself Again you ll have to provide the necessary software but it would save you from having to buy a serial interface board 149 If you are thinking of running both the keyboard and video board off the parallel ports of KIM you should add up the total number of lines you need By the time you include all necessary strobe lines you will probably find you don t have enough ports available Hooking To Your T V When you hook a video board to a T V set make sure that the T V has a transformer which isolates the set from the A C line 110 volts can ruin a lot of chips in a hurry There are two ways of putting the video signal in the T V If you want to go into the antenna terminals you will need a board which generates a regular T V frequency signal with the video signal being imposed upon it Kits are available for 10 15 A method less susceptible to interference problems is to go directly into the video amplifier of the set A T V repair shop should be able to handle this i
134. ds to start at a certain value should be set to that value by the program For example if you want address 0043 to start out with a value of 7 write LDA 8507 STA 0043 A9 07 85 43 General Make your subroutines simple with clearly visible entry and return points One of the stickiest problems to find is a subroutine that doesn t return via a RTS command but instead jumps straight back to your main coding or a subroutine that you somehow get into without giving the vital JSR command Avoid super clever programming such as having the program change itself It can work but if it misbehaves you can have a bad time Remember Computers are dumber than humans but smarter than programmers 167 T Lao hawka aaa LIGHTING THE KIM 1 DISPLAY Jim Butterfield A SIX DIGIT HEXADECIMAL The easiest way to display six digits of data is to use the KIM 1 Monitor subroutine SCAND Calling JSR SCAND 20 19 1F will cause the first four digits to show the address stored in POINTL and POINTH 00 and OOFB while the last two digits of the display show the contents of that address If you look at the first three lines of subroutine SCAND lines 1057 to 1059 on page 25 of the listing you ll see how the program digs out the contents of the address given by POINTL POINTH and stores it in location INH 00F9 It s neat programming and worth studying if you re not completely familiar with the 6502 s
135. e you may want the train in a model train layout to stop for exactly 45 seconds at a station under some conditions but for only 30 seconds under other conditions For this and other purposes as well KIM a built in interval timer which can be set to various multiples of its crystal controlled cycle time of 1 microsecond 10 6 sec By storing number between 1 and one of the special memory locations listed below we direct the timer to count a specific number of cycles The special memory 10 cations used by the interval timer and the longest count down period are as follows Location Timer Count Max Period sec microseconds For FFhex 1704 Kx1 0 000255 1705 K x 8 0 002 1706 K x 64 0 016 1707 K x 1024 0 26 Location 1707 is also used to sense that the timer has finished counting By putting the interval timer inside a loop the timing can be lengthened to seconds minutes and hours The timer starts counting as soon as a number between 1 and FFhex is stored in one of the above four locations by means of the STA STore Accumulator in memory instruction When time runs out the BIT test BITs in memory with accumulator instruction returns a non positive value from 10 cation 1707 163 Timer Example The following short program illustrates the use of the interval timer The program will leave the loop after 5 x 64 320 microseconds count is detected by the BIT instruction While t
136. e on your own ES aaa Main routine initialization 28 4 0200 A2 OD GO LDX 13 fourteen bytes E 0202 BD CC 02 LP1 LDA INIT X 0205 95 05 STA ALT X 0207 DEX 0208 10 F3 1 1 update height amp velocity 020A A2 05 CALC LDX 5 3 020C AO 01 RECAL IDY 1 020 F8 SED 020F 13 CLC 84 4 f o7 0210 5 05 DIGIT LDA ALT X 0212 75 07 ALT 2 X add each digit 0214 95 D5 STA ALT X 0216 CA DEX 0217 33 DEY 0213 10 F6 BFL DIGIT next digit 021A B5 D3 LDA ALT 3 X hi order zero 021 10 02 BFL INCR OF ae 021 9 99 LDA 99 0220 75 D5 ALT X 0222 95 D5 STA ALT X 0224 CA DEX 0225 10 E5 BPL RECAL do next addition 0227 A5 05 LDA ALT 0229 10 OD BPL UP Still flying 022B A9 00 LDA 0 nope turn off 022D 35 E2 STA DOWN 4 022F A2 02 LDX 2 0231 95 05 DD STA ALT X 0233 95 DB STA TH2 X 0235 CA DEX 0236 10 F9 gt BPL DD 0233 33 SEC update fuel 0239 A5 EO LDA FUEL 2 023B E5 DD SBC THRUST 023D 35 EO STA FUEL 2 023F A2 O1 LDX 1 two more digits to go 0241 B5 DE IP2 LDA FUEL X 0243 E9 00 SBC 0 0245 95 DE STA FUEL X 0247 CA DEX 0243 10 F LP2 024A BO OC BCS TANK still got fuel 024 A9 00 LDA 0 nope kill motor 024E A2 03 LDX 3 0250 95 DD LF3 STA THRUST X 0252 CA DEX 0253 10 FB LP3 Show alt fuel or messages 0255 20 BD 02 JSR THRSET 0252 A5 DE TANK LDA FUEL fuel into regstrs 025A A6 DF LDX FUEL 1 025C 09 FO
137. ed to the beginning of your program or changed locations 397 and 39A pressing acts like PC 0300 08 START SED 0301 A2 FF LDX FF INITIALIZE STACK 0303 9A TXS POINTER 0304 AO 00 INIT LDY 00 CE6 EE 0 0306 A2 09 LDX 09 0308 94 E5 INIT1 STY 00E5 X 030A DEX 030B 00 FB BNE 030D INX 1 124 050 0510 0512 0314 0316 0318 051A 031C 031D 051F 0321 0323 0325 0327 0329 0328 0520 032F 0330 0332 0334 0336 0338 033A 033D 033F 0341 0343 0346 0349 034B 034D 034 034F 0350 0352 0354 0356 0358 0359 035B 035D 035E 0361 0363 0364 0365 0367 0368 036B 036D 036E 0370 0372 0374 0377 0379 20 19 1F 2C 07 17 10 FO E8 E8 8A 49 07 85 ED A4 EE Bl 48 4 4A 4A 4 A8 B9 E7 1F 95 E5 E8 68 29 OF A8 B9 E7 1F 95 E5 E8 E6 EE E4 ED 90 EO 20 AF 03 DO FB 20 AF 03 LENGTH FLASH FLASH1 FLASH2 1 2 CONVRT LDA CPOINTL Y GET OPCODE FIND LENGTH CMP 20 ANALYZE BIT PATTERNS BEQ 00100000 3 BYTES AND 9F MEANS DON T CARE BEQ 1BYTE 0XX00000 1 BYTE 20 92 BEQ FLASH 1XX10010 ILLEGAL B2 D2 TAY STORE TEMPORARILY AND 1D CMP 4519 BEQ 3BYTE XXX110X1 3 BYTES 59 B9 AND 34 0D 08 BEQ 1 XXXXX0X0 1 BYTE D8 5A AND 850 0 BEQ 3BYTE XXXX11XX 3 BYTES C4C EE TYA RESTORE AND 8F 02 0XXX001
138. ell worth the effort The DEX instruction Op Code CA is the one that decreases X from 9 to 8 and later to 7 6 5 and so on Eventually as this part of the program is automatically repeated X will reach a value of 00 Finally when we decrement X one more time X will go to value FF which KIM sees as a negative number kind of like the value l KIM views all values in the range 80 to FF as negative when you re ready the Programming Manual will tell you more The BPL instruction at line 0207 is a CONDITIONAL TEST BPL means Branch plus the result of our previous operation Decrement X gives us a positive or plus number we will branch back to address 0204 and repeat the instructions from that point The X values of 9 8 7 down through 0 are all positive plus so each time we ll go back and set one more location in memory to value zero Finally X becomes equal to value FF a negative number So in this case BPL won t branch the plus or positive condition isn t satisfied This last time since BPL doesn t take us back we proceed to the following instruction BRK which stops the program That s OK because we ve done our job of Setting addresses 0030 0039 to value zero Single Step the program carefully checking the value of X from time to time location 00 5 remember Satisfy yourself that you can see it working By the way that funny address on the branch instruction FB is a special kind of
139. enever a can is tossed unless you get him If Wumpus moves into a room with a pit or Superbats he ll be hidden you won t be told WUMPUS CLOSE Either guess or pitch a can to make him move Good hunting The program is adapted from a game by Gregory Yob which appears in The Best of Creative Computing AN 8 5 2 d odo C 9 6 3 1 107 0505 0507 0309 0508 030C 050 0510 0512 0314 0316 0318 031A 051D 031F 0321 0323 0324 0326 0329 032A 032C 032F 0331 0333 0336 0339 033A 033C 033E 0350 0342 0344 0346 0348 034A 034C 034E 0350 0353 0355 0357 0359 0558 035E 0260 0362 0364 0367 0369 036A 036C 036E 036F 02 00 02 00 02 02 02 INIT GETN CKNO ADJR NXTR SKP1 SKP2 MESS XRO LDA LDX STA DEX BPL LDA DEC LDY BPL LDY LDA STA LDX LDY LDA STA DEX BPL LDY TYA JSR SFF 0E 00C1 X INIT 503 00 0 8505 3500 505 RAND 50 00 CKNO 00CA Y GETN NXTR 03 00 1 00C6 Y COMP NOMA 503 SKP1 3519 MESS 501 SKP2 50 MESS 500 501 00 1 00E1 NXTR 00CA 1FE7 Y 000C 503 00C6 X 1FE7 Y 0020 X XRO 8500 5 108 INITIALIZATION CLEAN OUT ROOMS INIT TO FF FINISHED NO GIVE THREE CANS OF GAS RANDOMIZE YOU WUMPUS PITS AND BATS CONL
140. ere is a discrepancy between memory and the tape the LEDs will come on with address FFFF VU Program VUTAPE lets you actually see the contents of a KIM format tape as it s going by It shows the data going by very quickly because of the tape speed but you can at least sense the kind of material on the tape In case of tape troubles this should give you a hint as to the area of your problem nothing noise dropouts And you can prepare a test tape see below to check out the tape quality and your recorder The test tape will also help you establish the best settings for your volume and tone controls Perhaps VUTAPE s most useful function though is to give you feeling for how data is stored on tape You can actually watch the processor trying to synchronize into the bit stream Once it s synehed you ll see the characters rolling off the tape until an END or illegal character drops you back into the sync mode again It s educational to watch And since the program is fairly short you should be able to trace out just how the processor tracks the input tape VUTAPE starts at location 0000 and is fully relocatable so you can load it anyplace it fits 141 KIM UTILITY VUTAPE 0000 D8 START CLD 0001 49 7 LDA 7F 0003 8D 41 17 STA PADD set display dir reg 0006 49 13 SYN LDA 13 eewindow 6 and tape in 0008 85 EO STA POINT and keep pointer ooo 8D 42 17 STA SBD 0000 20 41 1A JSR RDBIT ge
141. eyboard and display of the KIM 1 Originally published in the Sept 74 issue of PCC a version also appeared in the May 76 issue of Byte magazine The starfield is displayed on the horizontal segments of the second through fourth digits of the display The segments represent stars when lit and are numbered as follows Shooting a star creates a hole where the star 789 was The resulting explosion changes the 456 condition of certain adjacent stars or holes 123 stars to holes or holes to stars according to the following 0200 0202 0204 0206 0207 0209 0208 0200 020 0211 0212 0214 0217 0219 0218 021 0220 0223 0225 0228 022 022 022 0230 Center 5 lt Sides 2 8 4 6 1 Comers 1 Z 40 N OIN 9 Y 57 The game starts with a star in position 5 the rest are holes The object of the game is to reverse the initial condition making 5 a hole and all the rest stars Eleven moves are the minimum number Should you attempt to shoot a hole the first digit displays a H until a star key is pressed This digit also displays a valid number selection A count of valid moves is given at the right of the display A win gives a F in the first digit All holes is a losing situation L in the first digit You may start over at any time by pressing the Go button The program starts at 0200 9 00 LDA 00 ZERO REGISTERS D0 DA A2 10 LDX 8 10 95 CF CLOP STA OOCF
142. f 0303 C901 01 KIM keyboard is one 0205 DOOD BNE ENDR 0307 201 1 JSR SCANDS delay to make sure O30A 206A1F JSR GETKEY O30D C901 CMP 01 10005 BNE ENDR 0511 400510 JMP SAVEL 0314 60 ENDR RTS TWO TONE SOUND TO INDICATE HOURS This is a subroutine which when added to the clock display routine will use the real time clock data to produce one sound per hour on the hour The output is a speaker circuit as shown on Pg 57 of the KIM 1 Manual It is hooked to PBO rather than The specific notes can be changed by altering 0330 and 0330 0320 A582 BEEP LDA MIN on the hour 0322 1029 BNE END if not return 0324 A581 LDA SEC execute until SEC HR 0226 38 SEC 0327 E585 SBC HR 0329 1024 BPL END 032B A580 AGAIN LDA 458 first second 032D 1006 032F LDA 1E set high note 0331 8570 STA NOTE 0333 DOOA BNE GO sound note for 4 second 0335 A901 ONE LDA 401 second X4 second 0557 0580 CMP QSEC 0339 DO14 BNE END PE 033B A928 LDA 28 set low note 033D 8570 STA NOTE 033F A901 80 LDA 01 set I O ports 0341 800517 STA PBDD 0344 EEO217 INC PBD toggle speaker 0347 570 LDA NOTE 0349 set delay CA DEC DEX 0548 10FD BPL DEC 30DC BMI AGAIN keep sounding 60 END RTS 54 DISPLAY CLOCK ON KIM 1 READOUT 0360 A900 LDA 00 reset second counter 0302 8580 STA QSEC O3Ch LDA F4 start timer with interrupt 05 6 800217
143. f is working right The Inserted BRK Break Sometimes SST seems slow You might have a long program and you re sure that the first part is working What you want is a way to run directly through the first bit and then stop and single step the rest It s not hard Decide where you want the program to Stop so you can start single stepping Then put a BRK command code 00 at that point You ll have to wipe out a live instruction of course but that s OK You can put it back after the halt has happened Let s try doing that on mini program B Let s say we want to run straight through to the BPL instruction at 0207 and then single step from that point on 16 4 Change 0207 previously 10 to value 00 the BRK command Now go to the beginning of the program 0200 be sure SST is off and hit GO You ll see 0209 00 on the display which tells you that the halt at 0207 has worked Now go back to 0207 put the value of 10 for BPL back in set the SST switch on and you re ready to step Easy You bet and you can save lots of time this way in testing big programs No Operation NOP code EA It sounds funny but a very handy instruction is one that doesn t do anything When the microprocessor encounters Op Code EA NOP it does nothing just passes on to the next instruction The biggest use of the NOP instruction is to take out another instruction that you don t want any more or to leave room in the coding
144. f you can t About the simplest circuit was given in July 76 Byte p 38 Another appeared in Kilobaud 47 July 77 p 30 Kits are available to make this type of conversion also Video Monitors A video monitor is like a T V set without the ability to pick up channels It just takes a standard video signal like the one coming from a video board and puts it on the screen Because they have a larger bandwidth than the normal T V set they can display more information without the characters getting fuzzy Costs At the present time Summer 77 you can expect to pay 150 250 for a video board 50 150 for a keyboard and over 300 for the combination in a box along with a serial interface Most of the serial interface is in the UART chip which sells for about 10 Kits may be available for about 25 50 Motherboards run 100 150 and a video monitor will cost around 150 200 Graphics If you want to use your KIM for simulating video games on a T V you should be thinking in terms of a graphics board The graphics boards that are used with T V sets generate many tiny white rectangles squares or dot patterns on the screen these can be individually turned on or off at will Some video boards meant to display characters also have limited graphics capability 150 L DEN luit n T AUS ES Lt eius ES pw Printers There are a number of printers on the market wh
145. ference between locations Such tests often involve writing to one location and then checking all other locations to see they haven t been disturbed this can be time consuming This program checks memory thoroughly and runs exceptionally fast It is adapted from an algorithm by Knaizuk and Hartmann published in IEEE Transactions on Comouters Avril 1977 The program first puts value FF in every location under test Then it puts 00 in every third location after which it tests all locations for correctness The test is repeated twice more with the positions of the 00 s changed each time Finally the whole thing is repeated with the FF and OO values interchanged To run Set the addresses of the first and last memory pages you wish to test into locations 0000 and 0001 respectively Start the program at address 0002 it will halt with a memory address on the display If no faults were found the address Will be one location past the last address tested If a fault is found its address will be displayed v4 Example test 0100 to O2FF pages Ol and 02 in KIM Set 0000 to 01 0001 to 02 start program at 0002 If memory is good see 0300 02FF 1 Now if you try testing 0100 to 16FF 0000 01 0001 16 the will halt at the first bad location this will be 0100 if you haven t added memory 0000 xx BEGIN xx starting page for test 0001 xx END xx ending page for test 0002 A9 00 START LDA 0 zero poi
146. for KIM based on the standard 44 pin connector Once you decide on a particular motherboard you are pretty much locked in to buying or building boards whose pins match those in the sockets of the motherboard S 100 Bus The S 100 bus derives from the motherboard Presumably any board which works in an Altair then should work in any other S 100 machine Unfortunately that has not always been the case The S 100 bus is popular though and already a couple manufacturers have advertised S 100 motherboards meant to be attached to the KIM Because of the competition S 100 boards sometimes give a cost advantage This is especially true in the case of memory boards where competition is fierce NOTE Altair is a trademark of MITS Inc 146 Caution No matter what bus you decide on you are going to need programs written for KIM to drive certain boards you might plug in Unless there is a program for that particular board di written for KIM you are in for a lot of work The Serial Port It s not necessary that all expansion take place along the data and address busses of your KIM There is another entrance exit for information the serial ports The serial I O Input and Output ports also have the advantage that most of the required software already exists in the ROM of KIM For example to output a character 1t is only necessary to put that character in the accumulator and jump to the subroutine OUTCH 1
147. g Point Routine For 6502 April 1977 p 18 Computer Controlled Robot Hardware and 6502 software for a KIM controlled robot like vehicle KILOBAUD January 1977 p llh A Teletype Alternative How to Convert a parallel input to serial operation interface to KIM February 1977 p 8 Found Use For Your Computer April 1977 p 74 KIM 1 Memory Expansion How to Add 89 95 4K Ram board to KIM 1977 p 98 Adding To Your System A 6502 noisemaker for computer games June 1977 p 50 For Your KIM NOTE Kilobaud now has a monthly KIM column MICROTREK August 1976 p 7 KIM 1 Microcomputer Module very in depth look inside KIM POPULAR ELECTRONICS July 1977 p 47 Build The TVT 6 to 1 TVT same as Kilobaud 6 174 REI dM otia fa Ogee u RS S a AE 73 MAGAZINE January 1977 p 100 Bionic Brass Pounder How to Turn KIM into a smart morse code keyboard kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 6502 SOFTWARE SOURCES of summer 1977 ARESCO 314 Second Ave Haddon Hts New Jersey 08035 The Computerist 3 S Chelmsford MA 01824 Itty Bitty Computers P O Box 23189 San Jose Calif 95153 MI
148. h normal operation of PB7 Also PB7 was designed to be wire ORed with other possible inter rupt sources if this is not desired a 5 1K resis tor should be used as a pull up from PB to 5v The pull up should NOT be used if PB7 is connected to NMI or IRQ IMPORTANT The KTM Cassette Tape Interface 1 The KIM 1 USER GUIDE doesn t emphasize one vital instruction in telling you how to read and write tapes BEFORE READING OR WRITING MAGNETIC TAPE BE SURE TO SET THE CONTENTS OF ADDRESS 00F1 TO VALUE 00 This ensures that the computer is not in Decimal Mode If you forget to do this you re likely to have trouble with audio tape You might write bad tape which can never be read back in correctly and you might find yourself unable to input properly from tape Many of us have run into this problem and have wasted countless hours trying different tapes and recorders or even investigating KIM s electronics You ll find KIM audio tape to be 100 reliable even on inexpensive recorders providing you follow this rule and always ensure that location 00 1 is set to zero 171 NOTES RANDOM NUMBER GENERATOR _ dim Butterfield It s not my original idea I picked up it from a technical journal many years ago Wish I could remember the source I could credit it This program produces reason
149. he timer counts other tasks can be performed by KIM Loc Code Mnemonic Comments 00 A9 05 LDA 05 Start timer by storing 02 8D O6 17 STA 1706 1706 05 Perform other tasks gy 10 2 07 17 1707 Check if timer finished 13 10 O5 If still counting go to 05 15 Otherwise continue How KIM Communicates with its own Keyboard and Display At first glance the KIM keyboard and the LED display seem to be a hardwired fixed part of the micropro and as difficult to access as if they would belong to a calculator Fortunately it is not so Both the keyboard and the display can be used quite differently from the way they are used by the KIM built in operating system program You can run the display and the keyboard under the control of your own programs to perform all kinds of tricks For example you can program the LEDs to display any pattern in any digit position which can be made with the seven LED segments Similarly the keyboard can be used as input to various programs with individual keys performing functions unrelated to their numerical labels For example the B key in your program can 164 indicate a Backward command while the F key can mean Forward Various game programs shown in other sections of this book are examples of such applications We have tried in this chapter to give you a feeling for what KIM can do in the way of control applications We hope th
150. her octave 026D FO 16 BEQ SEX else exit 026F 8D 42 17 CONT STA SBD 0272 DEX 0273 C6 E8 DEC LIMIT 2 0275 DO EC BNE SLOOP 0277 C6 E7 DEC LIMIT 1 0279 DO E8 BNE SLOOP 027B Al EO LDY WORK 027D 84 E7 STY LIMIT 1 027F C6 E6 DEC LIMIT 93 sqm 0281 0283 0285 DO 0 A9 FF 60 0286 30 02 01 FF 00 00 SAMPLE MUSIC FOR FB BD m 18 BD B3 0000 0010 0020 FE BD 80 FF 00 80 0020 0050 0040 00 5A FB 5A 28 51 5A 48 0040 0050 0060 0070 0080 0090 FF 56 5A F2 80 5A 56 56 80 hC bA 56 00 00 5A BNE SLOOP LDA SEX RTS INITIAL CONSTANTS INIT MUSIC BOX PROGRAM y Uh E6 44 80 E6 00 Cu 51 BD 51 66 5A 30 36 80 5A 51 33 51 48 51 48 60 5A 44 51 48 5A 5A D1 79 5A 6C 5A 5A 00 56 5 66 m 72 5A 5A F2 4C 5A E6 66 80 56 cc F2 72 79 80 4C 5A 5A 72 5A 80 FA 20 5A 60 ch 80 51 DA C4 80 FA FE DA FA 56 4C 3A 80 530 2 1 5 0 0 01 53 EO PE 56 56 66 B8 NOTE THAT TUNES 1 AND 2 SET BOTHTHE SPEED AND THE INSTRUMENT TUNE 3 CONTINUES AT THE SAME SPEED AS THE PREVIOUS ONE BUT THE INSTRUMENT IS CHANGED DURING THE TUNE M THE PROGRAM CAN BE CHANGED TO USE THE SPEAKER SHOWN IN FIGURE 5 1 OF THE KIM MANUAL AS FOLLOWS BYTE 020D 024C 0255 0270 INITIALLY CHANGE TO 43 01
151. hot lights all three segments and travels faster The original version of the game was published for the HP 67 calculator in 65 Notes V4N2P5 Authorship was not given At first the shots will come too fast for you to cope with There are two ways to solve this The easy way is the freeze the ball by holding down any unused key like AD or 7 play will be suspended until you figure out what you want to do next The harder way but not too hard is just to slow down the ball by changing the program locations 0331 to 0334 contain the speeds for each type of shot Increase these values and the ball will slow down e g 40 40 40 28 will halve the speed For a two player game where KIM does not play the right side change location 032C to 01 To have KIM play the left side change location 032B to 00 KIM plays a strong game but CAN BE BEATEN 95 ad k 0200 20 40 1F START JSR KEYIN directional registrs 0203 20 6A 1F JSR GETKEY input key 0206 C9 13 13 GO key 0208 DO OA BNE NOGO nope skip GO key set up game here 020A A2 08 LDX 8 get 9 020C BD 24 03 SETUP LDA INIT X inital valus 020F 95 80 STA SPEED X to zero page 0211 CA DEX 0212 10 F8 BPL SETUP test legal keys 0 3 4 7 8 B C F 0214 C9 10 NOGO CMP 510 key 0 to 0216 BO 22 BCS NOKEY no Skip 0218 AA TAX save key in X 0219 29 03 AND 3 test column 021B FO 04 col 0 0 4 8 C 021D C9 03 CMP 3 col 3 3 7 B F 021F DO 19 i
152. ich use many small solenoids to form dot patterns through a typewritter ribbon onto paper These dot patterns form characters faster than can be done with a typewritter or teleprinter Some use adding machine paper and others a standard size sheet Prices run from 250 on up Also available are printers which use a specially sensitized paper and print using a thermal process Floppy Disks Once you start reading in programs which require 4K or more of memory you are going to find the cassette interface on your KIM a little slow Even with Hypertape it will take about 1 1 2 minutes to read in 4K There are faster tape units on the market but the ultimate as far as the hobbist is now concerned is the floppy The floppy disk is like a flexable phonograph record coated with iron oxide as is used on tapes A read write head is moved radially outward from the center to read or write on different tracks The main advantage over tape is the speed at which any block of information can be located The information is also put on very compactly and reading it back takes only a few seconds at most The mechanism to do all this is a precision piece of equipment and quite expensive Prices are continuing to drop however as the demand becomes greater The electronics necessary is also quite complex but as with the UART single chips are now being made which do most of the job Floppies are often used in pairs One reason for this is to be
153. ile reading But for now just recognize that although the numbers may look a little funny they are still exactly that numbers Read Only Memory So far we ve talked about one kind of memory called RAM You recall that we said that you can store numbers into RAM There s another kind of memory in KIM but you can t store numbers there It s called ROM for Read Only Memory This kind of memory contains fixed values that cannot be changed up For example let s look at address 1C3A key AD 1C 3 A You ll see the value 18 and that value never changes Try it press DA 6 6 to try to change the contents to 66 See how it won t work ROM contains pre stored programs which do important things like lighting the display detecting keyboard input and reading or writing your cassette tape These programs are called the Monitor In fact the name KIM stands for Keyboard Input Monitor in recognition of the importance of these programs We ll talk briefly about the Monitor programs later Special Memory Locations A few addresses in KIM are connected to things that aren t really memory at all You can read up on them in the KIM User Manual when you re ready we ll just point out a few examples here you try to store a number into address 1700 for example you might find that instead of storing the value KIM will convert it to voltages and deliver these voltages to certain pins on your Application Connector at
154. indirect addressing operation Thus 1f you skip these three lines and call JSR SCANDS 20 1F 1F you will be displaying in hexidecimal the contents of three locations POINTH POINTL and INH This of course takes six digits SCAND will display four digits of address and two digits contents SCANDS will display six digits of data Important in both cases the display will be illuminated for only a few milliseconds You must call the subroutine repeatedly in order to obtain a steady display B DRIVING THE BITS OF THE DISPLAY DIRECTLY 1 Store the value 7F into PADD 1741 This sets the directional registers 2 To select each digit of the display you will want to store the following values in location SBD 1742 2 4 5 6 7 Digit 1 509 b Digit 2 0B 7 Digit 3 0D AP 4 202 i 10 oe Digit 4 SOF 9 10111 Digit 5 11 Digit 6 513 Note that this can easily be done in a loop adding two to the value as you move to the next digit 2 5 5 168 9 3 Now that you have selected a particular digit light the segments you want by storing a segment control byte into location SAD 1740 lit by setting the appropriate bit to 1 in SAD according to the following table Rit 7 6 center g into SAD 4 Now that you have picked a digit and lit the appropriate segments wait a while L t 5 4 upper lower lef
155. l as thrust minus 5 O2BD A5 DD THRSET LDA THRUST O2BF 33 SEC 0200 SED 02C1 E9 05 SBC 5 02C3 85 DC STA 2 1 02C5 A9 00 LDA 0 02C7 E9 00 SBC 0 02C9 85 DB STA TH2 0208 60 RTS initial values oH ades ev amp ur abo gt 02CC 45 01 00 INIT 02 99 31 00 BYTE 45 1 0 altitude BYTE 99 31 0 rate of ascent 86 4 02D2 99 97 BYTE 99 397 acceleration 0204 02 i BYTE 2 thrust 0205 08 00 00 8 0 0 fuel 0208 01 BYTE 1 display mode 02D9 01 BYTE 1 in flight landed end 0005 ALT 3 0028 3 00DB TH2 2 0029 THRUST 1 OODE FUEL 3 00 1 MODE 1 00 2 DOWN 1 00 3 DECK 1 linkages to KIM monitor SCANDS uns GETKEY 1 6 2 POINTH FB gt POINTL INH F9 lt Hex Dump Lunar Lander 0200 A2 0D BD 02 95 05 10 F8 A2 05 0 01 F8 18 0210 B5 D5 75 D7 95 05 88 10 F6 B5 08 10 02 A9 99 0220 75 05 95 05 CA 10 E5 05 10 0D A9 00 85 E2 A2 0250 02 95 D5 95 DB CA 10 F9 38 AS EO E5 DD 85 EO 2 0240 01 B5 DE 9 00 95 DE CA 10 F7 BO 0 9 00 A2 03 0250 95 DD CA 10 FB 20 BD 02 5 DE DF 09 FO El 0260 FO 20 FO A2 FE 0 5A 18 5 09 69 05 5 0270 D8 69 00 0 A2 AD 0 DE 98 A4 E2 FO 04 5 05 0280 A6 D6 85 FB 86 FA A5 D9 A6 D8 10 05 38 A9 00 E5 0290 09 85 F9 9 02 85 08 20 1F 20 1 C9 13 02A0 FO CO BO 03 20 AD 02 C6
156. l on the lander you get no special indication except that you start falling very quickly Let s say we want to make this minor change if you run out of fuel the display flips Cver to Fuel mode so that the pilot will see immediately Digging through the program reveals two things i you 50 to fuel mode by storing 00 into MODE address E1 and ii the out of fuel part of the program is located at 024 to 0257 So if we can insert a program to store zero in mode as part of our out of fuel we should have accomplished our goal Closer inspection reveals that we can accomplish this by inserting 85 El STA MODE right behind the LDA instruction at 0240 Let s do it First we must store value FF behind the last instruction of our program So put FF into address O2CC That wipes out the value 45 but we ll put it back later Now we put our program start address 0200 into addresses EA and EB Low order first so 00 goes into address OOEA and 02 goes into OOEB Next the part that we want to move Since we want to insert a new instruction at address 024E we must move the program up at this point to make space In goes the address low order first into address OOEC and 02 into address OOED The page limit should be set to 17 since we don t want the addresses of the KIM subroutines to be changed SCANDS GETKEY etc So put 17 into address OOE7 Finally how far do we want to move the program to make room Two
157. l techniques to be used In addition KIM gives you only addition and subtraction you have to work out multiplication and division for yourself to say nothing of more complex functions like square roots and powers You can program all this yourself if you have the time and the mathematical background But if you really need to perform advanced math on your KIM you ll be better off to obtain a pre written mathematical package Floating point on computers means about the same as the term Scientific Notation on calculators It lets you use fractions and deal with very large and very small values In addition you ll often get extra functions powers roots logarithms and trigonometric functions such as sines and cosines Many mathematical functions are often included in large interpreters 154 CONNECTING TO THE WORLD gt KIM RUNS THE WORLD OR HOW TO CONNECT YOUR MICROPROCESSOR TO EXTERNAL DEVICES By Cass Lewart Introduction Calculator versus Computer Most of you are familiar with the ubiquitous pocket calculator From the simple four banger to the most sophisticated card programmable the sequence of ope rations is always the same You enter numbers from either the keyboard or a program card depress a few keys the calculator crunches your input and out come the processed numbers on the display or printer Though a calculator will do a great job of processing numbers just try
158. lable in both hardware software the KIM microprocessor Other Books of interest HOW TO BUILD A COMPUTER CONTROLLED ROBOT TOP LOCFBOURROW Lise the KIM 1 microprocessor t build your own computer controlled robot hes are ster by step directions for the construction of a robot with the complete contre programs clearly written out Photographs diagrams and tables direct you thro ish the construction 5681 8 paper BA3 C BASIC Ar Introduction to Computer Programming BASIC Language Second Edition sDVANCED BASIC Applications and Problems by JAMES 5 COAN The complete picture cf the BASIC language One introduces the lenguaye through an integratica of programming and the teaching of mathematics The offers advanced techniques and applications Both begin with short complete programs and progress to more sophisticated problems Basic BASIC 5106 S paper 5107 7 cloth Advanced BASIC 5855 1 paper 5856 cloth COMPUTER SYSTEMS HANDBOOK SOL LIFES An ovurview of the new world c home computing Provides the basics of digital logic number systems computer hardware and software to intel iigeni y purchase assemble and interconnect components and to program the microcomputer 5678 8 paper H HAYDEN COMPANY INC Rochelle Park New Jersey ISBN 0 8104 5118 0
159. lay here LDY 13 LDX 1 STX DIGIT count score digts LDA SCORE LSRA LSRA shift amp store LSRA LSRA left player score STA ARG LDA SCORE AND 0 right player score TAX LDA TABLE X JSR SHOW LDA ARG DEC DIGIT BPL HOOP LDX 3 VUE LDA PIX X CPX PLACE BNE NOPIX ORA SPOT show the ball JSR SHOW DEX BPL VUE BMI SLINK lose score amp reverse board POINT JSR SKORE SLINK CLD JMP START return to main loop display subroutine SHOW STA SAD STY SBD STALL DEC MOD BNE STALL DEY DEY RTS SHOT TAY save shot in LDX LOG old log in X ASL LOG ASL LOG ORA LOG AND 45 update log book STA LOG last two shots SEC LDA SPEED SBC PAUSE invert timing STA PAUSE 97 02 5 02C8 02CA 02CD 02CF 02D2 02D3 02D5 02D7 02D9 02DB 02DC 02DE 02 1 02 3 02 5 02E7 0259 02 02 02 02 1 0223 02F5 02F7 02F9 02FA 02FC 02FE 0300 0301 0303 0305 0307 0309 030A 030C 030E 0310 0312 0315 0317 0318 031A 031C 031D 031F 0321 0323 31 80 35 03 03 03 17 03 Set speed amp display segment s LDA SPD Y STA SPEED LDA SEG Y STA SPOT test play success random LDA CHANCE X odds from log bk GIT DEY BMI GET LSRA LSRA BPL GIT unconditional GET AND 3 odds 0 to 3 ASL A now 0 to 6 STA TEMP LDA TIMER random number AND 7 now 0 to 7 CMP TEMP BEQ REVRS success BCC REVRS success lose a point 8 position tOyse
160. listing again the right hand side we have the program exactly as we have described it but abbreviated You can see that LDA means Load A and so forth The BRK Break at the end stops the program Step by Step Let s go through the program a step at a time literally Maybe you re satisfied that it works Even so follow this procedure It will show you how to test any KIM program First go back to addresses 0010 and 0011 and put a couple of brand new numbers there This will help you see the computer operating Wow set address 0200 again but don t press GO yet going to Single Step our program and see every struction work So slide the SST Single STep Seitch over to the right and then read the next section carefully 11 Seeing the Registers Registers A and X plus quite a few we haven t talked about are inside the 6502 microprocessor chip There s no way you can view them they are buried deep within the electronics To help you out the KIM Monitor system will write out a copy of these registers into memory where you can inspect them The contents of the A register may be seen at address 00F3 and the contents of the X register at 00 5 Don t be confused These locations are not the actual registers just copies made for your convenience But it s a great convenience for it allows you to see everything that s going on inside the microprocessor Small Step for
161. location 1707 and determine when the timer has timed out Reading the count in the timer If the timer has not counted past zero reading location 1706 will provide the current timer count and disable the inter rupt option reading location 170E will provide the current timer count and enable the interrupt option Thus the interrupt option can be changed while the timer is counting down 170 If the timer has counted past zero reading either memory location 1706 or 170E will restore the divide ratio to its pre viously programmed value disable the interrupt option and leave the timer with its current count not the count originally writ ten to the timer Because the timer never stops counting the timer will continue to decrement pass zero set the divide rate to l and continue to count down at the clock frequency unless new information is written to the timer d Using the interrupt option In order to use the interrupt option described above line application connector pin 15 should be connected to either the IRQ Expansion Connector pin or NMI Expansion Connector pin 6 pin depending on the desired interrupt function PB7 RE ED be programmed as in input line its normal state after a RESET NOTE If the programmer desires to use PB7 as a normal I O line the programmer is responsible for dis abling the timer interrupt option by writing or reading address 1706 so that it does not inter fere wit
162. m you may have noticed that converting your coding into KIM s machine language is quite a tedious job For example you may have written the command LDA TOTAL to load the accumulator with a zero page quantity that you have called TOTAL Before you can enter the program you must convert this to the 6502 code A5 for LDA from zero page 63 the zero page location you have chosen for TOTAL Not too hard perhaps but you must look up the code and keep track of the addresses If your program contains dozens of instructions this conversion called hand assembly can become quite a chore An assembler program will do the conversion for you quickly neatly and without error If you have a hard copy printing device it will give you a complete printout called a listing of your program resident assembler works on program data held entirely within KIM s memory It s very fast but it does need lots of memory to hold all of your program information Other assemblers work from data stored on magnetic tape or on floppy disk They are slower since the data must be copied into memory as it s needed but allow your programs to be almost unlimited in size cross assembler will assemble your KIM program on a completely different machine such as a Digital Equipment Corporation PDP 11 or a commercial time sharing processor Because these other computers are not so limited in size compared to the KIM they can be very powerful 152
163. n should be disabled For example if you re working on a program in the 0200 to O3FF range your program might also address a timer or I O regist ers and might call subroutines in the monitor You don t want these addresses relocated even though they are above the boundary 50 your page limit would be 17 since these addresses are all over 1700 On the other hand if you have memory expansion and your program is at address 2000 and up your page limit will need to be much higher You d normally set the page limit to FF the highest page in memory Place the page limit in location 7 Now you re ready to Set RELOCATE s start address hit go and ZAP your addresses are fixed up After the run it s a good idea to check the address now in and OOEB it should point at the FF at the end of your program confirming that the run went Now you can move the program If you have lots of memory to spare you can write general MOVE program and link it in to RELOCATE so as to do the whole job in one shot But if like me you re memory deprived you ll likely want to run RELOCATE first and then load in a little dustom written program to do the actual moving The program will vary depending on which way you want to move how far and how much memory is to be moved In a pinch you can use the FF option of the cassette input program to move your program Last note the program terminates with instruction
164. nd are found on serial interface boards One such board was described in issue 1 of Kilobaud Jan 77 What to look for Video boards vary considerably in the features they offer The simplist boards begin writing characters in the upper left of the screen and continue on down the page When the end of the last line is reached they return to the upper left corner and start over The only control you might have is a home signal which returns you to the starting point Any carriage returns linefeed etc have to be taken care of by a program which is keeping track of exactly where you are A better scheme is to have a cursor which is usually a flashing or solid white square located where the next character will appear In more advanced units you can move this cursor around under software or hardware control That way it s easy to back up and go over any mistakes Another handy feature is scrolling When you reach the end of the last line on the screen it s a little confusing to have 148 the next line start at the top Instead some boards automatically push every line up to make room for the incoming line the top line goes off the screen Blank to end of line and blank to end of screen features are necessary to keep from having a lot of unwanted characters left on the screen Be sure to check to find out exactly what features are included on the board you are buying If you can find someone who has a similar board
165. ne called GETKEY You call it with JSR GETKEY 20 6A IF This subroutine will give you the identity of the key that is being pressed at that moment as a value in the A register You can continue by using this value any way you want If no key is being pressed at the time you ll get a value of 15 in There are a couple of cautions on the use of JSR GETKEY First you must not be in Decimal Mode If you re not sure about this give a CLD D8 instruction at the beginning of your program Secondly before giving JSR GETKEY you must open up the channel from the keyboard with either one of two subroutines JSR SCANDS or JSR KEYIN You ve met JSR SCANDS before it s used to light the display If you don t want to light the display use JSR KEYIN 20 40 1F before using JSR GETKEY This program reads the keyboard and displays what it sees 0200 D8 START CLD clr dc mode 0201 A9 00 LDA 0 zero into A 0203 85 FB STORE STA POINTH 0205 85 FA STA POINTL 0207 85 F9 STA INH 0209 20 1F IF JSR SCANDS light display 020C 20 6A 1 JSR GETKEY test keys 020F 4C 03 02 JMP STORE Exercises l Do you think that the instruction at 0201 is really needed Try removing it change 0201 and 0202 to EA and see 2 What values do you get for the alphabetic keys For keys like PC and GO Are there any keys that don t work with JSR GETKEY 3 Try running in decimal mode change 0200 to SED code F8 What happens Is it serious How about key F
166. ng the clock This means that you can run other programs simultaneously with the clock program unless your program also needs to use the NMI such as single step operation or if there could be a timing problem such as with the audio tape operation Pressing the KIM GO button will get you out of the KIM loop To start the clock 1 Connect PB A 15 to NMI 6 2 Initialize NMI pointer 17FA 17FB with 60 and 03 5 Set up the time and AM PM counter locations in page Zero 4 Go to address 03CO and press GO To get back into the clock display mode if the clock is run ning start at location 0509 NOTE These routines are not listed in any particular order so be watchful of the addresses when you load them PAGE ZERO LOCATIONS 0070 NOTE Sets frequency of note 0080 QSEC second counter 0081 SEC second counter 0082 MIN minute counter 0083 HR hour counter 0084 DAY day counter for 52 INTERRUPT ROUTINE This routine uses the NMI to update a clock in zero page locations Since the crystal may be slightly off one MHz a fine adjustment is located at 0566 pointers must be set to the start of this program 0360 48 PHA save 0361 8A TXA 0362 48 PHA save X 0363 98 TYA 0364 48 PHA save Y 0365 A983 LDA 9485 fine adjust timing 0567 8100817 STA TIME4 036A 200717 7 test timer 0360 10 BPL TM loop until time out O36F E680 INC QSEC count seconds 0371 A
167. ning the program which starts at 1780 or wherever you want to have it in your system Program uses zero page locations D0 thru D9 to do the job 1780 D8 START CLD 1781 FF LDY SFF STORE TEST VALUE 1783 38 SEC 1784 A5 D2 LDA OEAL HOW MANY BYTES 1786 5 DO SBC OSAL TO MOVE 1788 85 D8 STA BCL 178A A5 D3 LDA OEAH 178C ES 01 SBC OSAH 178E 85 09 STA 1790 18 CLE 1791 AS D8 LDA BCL ADD THE COUNT TO 1793 65 D4 ADC NSAL THE NEW START TO 1795 85 D6 STA NEAL GET A NEW END 1797 5 09 LDA 1799 65 05 ADC NSAH 1798 85 D7 STA NEAH 1790 D8 INC BCL ADJUST THE BYTE COUNT 179F 09 INC TO PERMIT ZERO TESTING 17 1 38 SEC 17A2 5 D4 LDA NSAL IF NEW LOCATION 17A4 5 DO SBC OSAL HIGHER THAN OLD 17A6 AS 05 LDA NSAH CARRY FLAG IS SET 17A8 Dl SBC gt 17AA 2 00 LOOP LDX 00 HIGH POINTER INDEX 17AC 90 02 BCC MOVE 17 A2 02 LDX 02 LOW POINTER INDEX 1780 Al DO MOVE LDA OSAL X MOVE OLD 17B2 81 D4 STA NSAL X TO NEW 1784 90 14 BCC DOWN 1786 C6 02 DEC OEAL ADJUST UP POINTER COLD 1788 98 BELOW ZERO 1789 45 02 EOR OEAL 17BB DO 02 BNE NO NO ENOUGH 1780 C6 03 DEC OEAH YES ADJUST THE HIGH BYTE 17BF C6 D6 DEC NEAL ADJUST THE OTHER ONE NEW 17C1 98 TYA 17C2 45 D6 EOR NEAL NEED HIGH BYTE ADJUSTED 170 DO 02 BNE NEIN NO 1766 C6 07 DEC NEAH YES DO IT 17C8 OC BCS COUNT 17CA 00 DOWN INC OSAL ADJUST OLD DOWN POINTER 17CC 00 02 BNE NYET g
168. nters 000 8 TAY for low order 0005 85 FA STA POINTL addresses 0007 85 70 BIGLP STA FIAG 00 first pass FF second pass 0009 A2 02 LDX 2 0008 86 72 STX MOD set 3 tests each pass 000 A5 00 PASS LDA BEGIN set pointer to OOOF 85 FB STA start of test area 0011 A6 Ol LDX END 0013 A5 70 LDA FIAG 0015 h9 FF EOR reverse FLAG 0017 85 71 STA FLIP FF first pass 00 second pass 0019 91 FA CLEAR STA POINTL Y write above FLIP value 0018 INY into all locations 001 DO FB BNE CLEAR 001 FB INC POINTH 0020 Ek FB CPX POINTH 0022 BO F5 BCS CLEAR 122 3 FLIP value in all locations now change 1 in 3 002 72 LDX MOD 0026 A5 00 LDA BEGIN set pointer 0028 85 FB STA POINTH back to start 002 A5 70 FILL LDA FLAG change value 002 CA TOP DEX 002D 10 Ol BPL SKIP skip 2 out of 3 002 A2 02 2 restore 3 counter 0031 91 FA STA POINTL Y change 1 out of 3 0033 C8 SKIP INY 003 DO F6 BNE TOP 0036 E6 FB INC POINTH new page 0038 A5 01 LDA END have we passed 003A C5 FB CMP POINTH end of test area 003C BO EC BCS FILL nope keep going 3 memory set up now test it 003E AS 00 LDA BEGIN set pointer 0040 85 FB STA POINTH back to start 0042 A6 72 LDX MOD set up 3 counter AS 71 POP LDA FLIP test for FLIP value 0046 CA 2 0 Out of 3 times 0017 10 0 BPL SLIP or 0019 2 02 LDX 2 1 out of 3 A5 70 LDA FIAG test for FIAG value OOhD Dl F
169. nters a number on the keyboard the left two digits display the players number The centre digits display the computer s choice after some think time The rightmost digits display a running total of matches left The computer has an I Q and will become dumber if you lose smarter if you win 0200 A9 21 START LDA 9921 initial IQ 0202 85 ED STA IQ 0204 A9 21 NEW LDA 21 21 matches 0206 85 F9 STA INH to start game 0208 A9 00 PLAY LDA 0 clear player s move 020A 85 FB STA POINTH 020C 20 1F 1F JSR SCANDS light display 020F 20 6A 1F JSR GETKEY and test keys 0212 C9 0 4 key 4 or over 0214 10 F2 BPL PLAY go back 0216 C9 00 0 key 0 go back 0218 FO EE BPL PLAY 021A 85 FB STA POINTH record move 021C A9 00 LDA 0 wipe last KIM move 021 85 FA STA POINTL 0220 F8 SED decimal mode 0221 38 SEC 0222 A5 F9 LDA INH get total matches 0224 E5 FB SBC POINTH subtract move 0226 30 EO PLAY not enough matches 0228 85 F9 STA INH OK new total 022A A9 08 LDA 8 i 022C 85 EE STA SLOW set slow counter 022E A9 FF TIME LDA FF slowest count into 0230 8D 07 17 STA CLOCK Slowest KIM timer 0233 20 1 1F DISP JSR SCANDS 5 0236 2C 07 17 CLOCK 0239 10 F8 BPL DISP 023B C6 EE DEC SLOW 023D DO EF BNE TIME 023F 18 CLC 0240 A5 F9 LDA INH get total 0242 FO 26 BEQ DEAD player loses 0244 69 0l ADC 4 divide m 1 by 4 0246 E9 04 SUB SBC 4 0248 FO OB BEQ DUMP O24A C9 OL 4 024
170. objects you can pick from Decide which pile you enter its identity A for the left hand pile through to for the right hand pile pile pou have selected will start to flash on and off Now enter the number of items you want to take from that pile will take its turn the same way you ll see the pile selected begin to flash and then some items will be taken away After the computer moves it s your turn again The winner is the player who takes the last object When this happens KIM will identify the winner new game can be started at any time by hitting GO 0200 20 40 1F START JSR KEYIN directional regs 0203 20 6A 1F JSR GETKEY 0206 C9 13 CMP 13 GO key 0208 DO 3A BNE NOGO nope skip 020A AD Oh 17 LDA TIMER get random nbr 020D A2 02 LDX 2 split into 3 020F SPLIT TAY save 0210 29 07 AND 7 extract 3 bits 0212 FO 03 BEQ ZINCH unless zero 0214 13 CLC add two 0215 69 02 ADC 2 0217 95 Oh ZINCH STA VALUE X store pile val 0219 98 bring back rand 021A 4A 4A LSRA LSRA LSRA 0210 CA DEX 021E 10 EF BPL SPLIT 0220 20 40 1F STALL JSR KEYIN wait for 0223 DO FB BNE STALL release 0225 AD Ol 17 LDA TIMER new random nbr 0228 A2 02 LDX 2 split 3 ways 022A A8 SPLAT TAY again 022B 29 07 AND 7 3 bits 0220 95 07 STA VALUE 3 X 022F 98 TYA 0230 HA HA HA LSRA LSRA LSRA 0233 CA DEX 0234 10 F4 BPL SPLAT 0236 85 O1 STA PILE pile zero 0233 35 02 STA MOVE it s your mo
171. ollows Stop 0 Go 1 Retum to KIM 4 Reset 2 4 INL 0200 9 04 BEGN LDA 00 0202 85 F9 STA INH ZERO DISPLAY 0204 85 FA STA POINTL 0206 85 0208 20 1F 1F HOLD JSR SCANDS LIGHT DISPLAY 0208 20 6A IF JSR GETKEY 020E C9 04 04 KEY 4 0210 DO 03 BNE CONT 0212 4C 64 1C JMP 1C64 RETURN TO KIM 0215 C9 02 CONT CMP 02 KEY 2 0217 F0 E7 BEQ BEGN BACK TO ZERO 0219 C9 01 01 KEY 1 021B 00 EB BNE HOLD 0210 A9 9C LDA 9 021F 8D 06 17 STA 1706 SET TIMER 0222 20 1F IF DISP JSR SCANDS DISPLAY VALUE 0225 AD 07 17 CLCK LDA 1707 CHECK TIMER 0228 FQ FB BEQ CLCK 022A 8D 00 1C STA ROM DELAY 4 0220 AQ 9C LDA 9 SET TIMER 022F 8D 06 17 STA 1706 0232 18 CLC 0233 F8 SED SET FLAGS 0234 As F9 LDA INH 0236 6901 ADC 01 INC 100THS 0238 85 F9 STA INH 023A As FA LDA POINTL i 023C 69 00 ADC 00 INC SECONDS 023E 85 FA STA POINTL 0240 C9 60 CMP 560 STOP AT 60 0242 00 OB BNE CKEY 0244 9 00 LDA 00 0246 85 FA STA POINTL ZERO SECONDS 0248 5 FB LDA POINTH 025A 18 CLC 0288 69 01 ADC 01 INC MINUTES 024D 85 FB STA POINTH 024F D8 CKEY CLD 0250 20 IF JSR GETKEY READ KEYBOARD 20255 C9 00 500 0 0255 00 DISP 0257 FO AF BEQ HOLD STOP J WUMPUS Description Wumpus lives in a cave of 16 rooms labeled 0 Each room has four tunnels leading to other rooms see the figure When the program is started at
172. operates in the input and which in the output mode These four Special memory locations can be accessed by KIM programs in the same way as any other location In addition the application port A in location 1700 and the appli cation port B in location 1702 are also accessible on connector pins They represent the physical interface of KIM monitoring the appropriate pins with a volt meter one can detect the data stored in memory locations 1700 and 1702 when KIM is in the output mode By setting the appropriate pins to ground or to 5 Volts one can feed data into KIM in the input mode As KIM is an 8 bit microprocessor each of the two ports A and B actually consists of eight independent inputs or outputs Each of the eight bit positions from through 7 appears on a different connector pin and is a port in itself The following are connector pin assignments for the and B application ports For example PAO represents the O th or the least sig nificant bit of port A and PA7 the 7 th or the most significant bit Pin A 14 means Application connector lower left the 14 th pin counting from the top on the upper side of the connector the lower side of the connector is designated by letters instead of numbers Connector Pin Assignments Port Pin Port Pin PAO A 14 PBO 1 4 PBI A 10 157 Port Pin Port Pin PA2 PB2 A 11 PA3 2 PB3 A 12 5 4 13 5 6 5
173. plug you plug into the tape recorder s earphone jack to applications pin 14 and adjust the control for O s or combinations of 7 s and L s on the display means the PLL TEST line is low and 7 means it s high The program generates a signal that alternates slightly below and slightly above theone generated by KIM at 1 6 The regular tape input channel is utilized and decoded to con trol the display 1780 49 07 BEGN LDA 07 Set the input 1782 8 42 17 STA SBD 1785 9 01 LDA 401 and output ports 1787 8D 01 17 STA PAO 1784 85 El STA El Initialize the toggle 178C A9 7F LDA 7F 178 8D 41 17 STA PADD Open display channels 1791 A2 09 MORE LDX 09 Start with the first 1795 AO 07 LDY 07 digit Light top amp right 1795 2c 42 17 BIT SBD if PLL output 1798 30 02 SEGS is high 1794 38 LDY 38 otherwise left amp bottom 1796 8C 40 17 SEGS STY SAD Turn on the segments 179F 8E 42 17 STX SBD and the digit 1742 2C 87 17 DELA BIT CLKRDI Half cycle done 1745 10 BPL DELA No wait for time up 1747 E6 E2 INC E2 Count the cycles 17 9 30 Oh BMI LOTO 128 cycles send low tone 17 A9 91 HITO LDA 91 128 cycles send hi tone 17AD DO 03 BNE CIK1 17AF A9 95 LOTO LDA 95 17Bl EA NOP Equalize the branches 17B2 8D 44 17 CLK1 STA CLK1T Set the clock 17B5 9 01 LDA 01 1787 45 El EOR El Flip the toggle register 1789 85 El STA El 1788 8D 00 17 STA Toggle the output port l7BE E8 INX 17BF E8 INX Next display digit 17CO EO 1
174. r lucky number of course but keep stepping with the key until you reach 0009 What will the next address be Most people would think that the next number should be 0010 and that would be correct if KIM used the familiar decimal numbering Scheme But KIM still has six more digits to go past 9 because it uses a computer numbering scheme called Hexadecimal Hit the key and you ll see address 000A come up Don t let the alphabetic confuse you to KIM is just the digit that comes after 9 And there are more digits to come Keep pressing the button and you ll see that A is followed by B C D E and Finally after address 000 you ll see address 0010 appear A word about pronunciation don t call address 0010 ten say one zero instead After all it isn t the tenth value after 0000 it s really the sixteenth the word Hexadecimal means based on sixteen If you don t understand why the letters appear don t worry about it too much Just understand for the moment that the alphabetics represent genuine numbers So if you re asked to look at address OlEB you ll know that it s legitimate address number like any other And if you re told to store a value of FA in there go right ahead you re just putting a number into memory When you get time you ll find lots of books that explain Hexadecimal numbering in detail There s even an appendix in your 6502 Programming Manual on the subject It makes important and worth wh
175. r most program libraries with some to spare So every program and data file would carry unique number and if you ve forgotten what s on a given tape just run DIRECTORY and get all the IDs Another thing that s handy to know is the starting address SA of program expecially if you want to copy it to another tape Ending add resses are easy just load the program then look at the contents of 17ED and 17EE Well DIRECTORY shows starting addresses too The program is fully relocatable so put it anywhere convenient Start at the first instruction 0000 in the listing Incidentally 0001 to of this program are functionally identical to the KIM monitor 188C 1901 After you start the program start your audio tape input When DI RECTORY finds a program it will display the Start Address first four digits and the Program ID Hit any key and it will scan for the next program 0000 8 GO CLD 0001 A9 07 LDA 07 Directional reg 0003 BD 42 17 STA SBD AX 0006 20 41 1A SW JSR RDBIT Scan thru bits 0009 46 F9 LSR INH shifting new bit 0008 05 F9 ORA INH left of OO0D 85 F9 STA INH INH OO0F C9 16 TST 816 SYNC character 0011 DO F3 BNE SYN no back to bits 0015 20 2h 1A JSR RDCHT get character 0016 C6 F9 DEC INH count 22 SYNC s 0018 10 F5 BPL TST C9 2 2 then test astk 0010 DO Fl BNE TST esor SYNC OOLE A2 FD LDX Z FD if asterisk 0020 20 F3 19 RD JSR RDB
176. ram should stop showing address 0010 There s nothing left to do but actually put the extra instruction 85 E1 into the program at 024E and O24F Now run the program Try deliberately running out of fuel and see if the display flips over to fuel mode automatically when you run out If you have followed the above successfully with your KIM it all seems very easy It s hard to realize that program RELOCATE has done so much work But if you check you ll find the following addresses have been automatically changed 0203 O24B 0256 8 0263 5 0265 7 02A5 7 Do you think that you d have caught every one of those addresses if you d tried to do the job manually 135 5 0200 0203 0205 0207 020 020C 020E 0211 0213 0216 0218 021A 0218 021D 021F 0221 0223 0 R by Jim Pollock This program will take any given block of data and arrange it in numerical sequence whether the data is hex or BCD or both Since the program uses relative branch addressing it can be located anywhere in memory without modification The instruction that determines whether data is arranged in ascending or descending order is 011F BO descending order 90 ascending order This is a bubble sort The top item is compared with succeeding items and if a larger number is found they are swapped The larger item now at the top is then used for comparisons as the process continues through the list After one complete pass the larges
177. rked START in the listing Now the display shows 0200 A5 and we re ready to go So hit GO And the program will run Doesn t take long does it The display will have changed to 020A xx the display shows any other address something s wrong Check that your SST switch is off left that the program is entered corre riya and that your vectors are OK Your program ran in less than a fifty thousandth of a second No wonder you didn t see the display flicker Now check that the program did indeed run correctly by looking at the contents of locations 0010 and 0011 You ll see that they have been exchanged 10 How it works Inside the Central Processor the heart of the computer are several temporary storages called registers You can LOAD many of these registers with the contents of memory and you can STORE the contents of the registers into memory The two registers we are using here are called A and X If we Load A from address 10 A now contains a copy of the contents of 0010 Location 0010 itself won t be changed it will also contain that number do the same thing when we Load X from address 0011 Now our A and X registers contain copies of the numbers in 0010 and 0011 respectively If we Store A into address 0011 that address will now contain a copy of the value in A which was originally the contents of address 0010 remember Finally we Store X into 0010 to complete the swap Look at the
178. rve SKORE LDX 4 position ball R 4 LDA DIRECT ASLA ASLA ASLA ASLA BPL OVER LDX FF position ball L LDA 1 OVER STX PLACE CLC ADC SCORE STA SCORE LDY 0 end game kill ball TLP TAX AND 5 get one score CMP 11 11 points BNE SKI STY DIRECT kill ball SKI TXA LSRA LSRA LSRA LSRA BNE TLP set serve speed spot log pause LDX 3 SRV LDA INIT X STA SPEED X DEX BPL SERVE reverse ball direction REVRS LDA DIRECT CLC EOR FF ADC 1 STA DIRECT RTS 98 tables in Hexadecimal format 0324 INIT 30 08 00 80 01 FF 00 01 00 032D PIX 00 06 30 00 0331 SPD 20 20 20 14 0335 SEG 08 40 01 49 0339 02 02 01 02 01 03 01 02 03 03 00 02 00 00 02 02 0349 78 B5 9E 76 6E Al AE 75 EB 8F 75 5B 56 7A 35 0359 end 7 Zero Page 80 SPEED speed ball travels 81 SPOT segment s ball lights x 82 LOG record of recent plays 83 PAUSE delay before ball moves 84 DIRECT direction of ball 85 PLACE position of ball 86 SCORE 87 PLEFT 0 for KIM to play left 88 PRITE 0 for KIM to play right Hex Dump Ping Pong 0200 20 40 1F 20 6A 1F C9 13 DO A2 08 BD 24 03 95 0210 80 CA 10 F8 C9 10 BO 22 AA 29 03 FO 04 C9 03 DO 0220 19 45 85 A8 29 04 DO 12 8A 45 84 29 02 FO OB 98 0230 29 02 DO 69 HA 20 B1 02 20 40 DO 27 C6 5 0240 83 10 23 AS 80 85 83 18 A5 85 65 84 85 85 29 04 0250 FO 14 A5 85 30 04 A5 88 10 02 A5 87 DO 3F 82 0260 BD 39 03 20
179. s JSR CARD deal card DEC MCNT inverted count LDX MONT use as r display pontr STY WINDOW 6 X into window LDY 10 ten count for aces BCC MOVER no ace STY MACE ace set 10 flag CLC SED ADC MTOT add points to STA MTOT point total CLD RTS 44 transfer number in to display 03A6 48 NUMDIS PHA save number 7 ISRA LSRA extract left digit 03A9 4A LSRA LSRA 03AB A8 TAY O3AC B9 iF LDA TABLE Y convert to segments O3AF 85 94 STA WINDOWt 4 0381 68 PLA restore digit 0382 29 OF AND 0F extract right digit 03B4 8 TAY 0385 B9 E7 iF LDA TABLE Y convert to segments 03B8 85 95 STA WINDOW 5 03BA 60 RTS tables in hex format 03BB 03 00 20 O1 02 03 04 05 06 07 08 09 10 10 10 10 0308 F7 DB CF E6 ED FD 87 FF EF F1 Fi F1 F1 03D8 ED F6 BE Fl Fi B8 FC F9 F8 D3 03 2 F8 DC F8 CO FC BE ED 87 F9 DE Rees graces 0200 A2 33 8A 95 40 CA 10 FA A2 02 BD BB 03 95 75 CA 0210 10 F8 AD 04 17 85 80 D8 A6 76 EO 09 BO 34 AD D8 0220 20 57 03 A0 33 84 76 20 30 03 38 A5 81 65 82 65 0230 85 85 80 2 04 B5 80 95 81 10 F9 29 C9 34 0240 BO E5 AA B9 40 00 48 B5 40 99 40 00 68 95 40 88 0250 10 05 0 DE 20 57 03 5 77 20 6 03 20 30 05 C9 0260 BO F9 AA 86 79 CA 30 F3 Eh 77 BO EF A2 0B AQ 0270 00 95 90 CA 10 FB 20 78 03 20 8F 03 20 78 03 20 0280 64 05 86 7A 20 28 03 20 30 05 AA CA 30 11 Et 96 0290 DO F5 20 78 03 C9 22 BO 40 EO 05 FO 53 DO E8 A5 02 0 95 48 A2 00 20 OF 03 A2 04 9 00 95 90
180. s instruments Though even with a simple on off control you can create sounds their acoustical range is very limited you connect an audio amplifier to one of the KIM ports and listen to the sound generated by gt the 5 Volt pulses of various length and at various repetition rates the sound will remind you only of a variety of buzz saws and not of musical instruments The next step therefore is to develop a digital to analog D A interface for your KIM Such an interface will for example translate an 8 bit binary number on ports through A7 into a voltage proportional to the numerical value stored in location 1700 Port A A number FFhex stored in 1700 could then generate 2 0 Volts while 20nex stored in the same location would generate 32 255 x 2 0 0 25 Volts Though we will not describe a D A converter in detail it 1 can easily be built with either separate amplifiers or with specially designed ICs An example of a rela tively inexpensive converter is MC1408L by Motorola 162 Similarly analog to digital A D converter inter face can be used to turn KIM into a measuring instrument such as a digital voltmeter thermometer or even a speech recognizer Applications of a microprocessor equipped with D A and A D converters are limited only by your imagination and by your wallet Interval Timer Many applications which interface KIM to the outside world benefit from the addition of a timer For exampl
181. s is the first instruction in your whole program including the part that doesn t move RELOCATE has to look through your whole program instruction by instruction correcting addresses and branches where neces sary Be sure your program is a continuous series of instruc tions don t mix data in RELOCATE will take a data value of 10 as a BPL instruction and try to correct the branch address and place a dud instruction FF behind your last program in struction This tells RELOCATE where to stop Place the program start address in locations EA and EB low order first as usual Don t forget the FF behind the last instruction it doesn t matter if you temporarily wipe out byte of data you can always put it back later Where relocation starts this is the first address in your program that you want to move If you re moving the whole program it will be the same as the program start address above This address is called the boundary Place the boundary address in locations EC and ED low order first How far you will want to relocate information above the bound ary This value is called the increment For example if you want to open up three more locations in your program the in crement will be 0003 If you want to close up four addresses the increment will be FFFC effectively a negative number Place the increment value in locations EB and E9 low order first 130 4 page limit above which relocatio
182. start the input tape When a program has been read from the input tape the display will light showing the start address of the program and its ID If you don t want to copy this program hit 0 Otherwise stop the input tape start the output tape on RECORD then hit 1 for Hypertape 6 for regular tape or any intermediate number The output tape will be written upon completion the display will light showing 0000 A2 Stop the output tape Now hit GO to copy the next program SUPER DUPE contains a Hypertape writing program which can be used independently this starts at address 0100 Basically SUPER DUPE saves you the work of setting up the SA EA and ID for each program and the trouble of arranging the Hypertape writer into a part of memory suitable for each program 0000 A2 03 START LDX 3 0002 B5 E2 LOOP LDA POINT2 X 0004 95 EO STA POINT X 0006 CA DEX 0007 10 F9 BPL LOOP 0009 A9 00 LDA 0 000B 85 F6 STA CHKSUM 000D 85 F7 STA CHKHI 000F D8 CLD 0010 A9 07 LDA 7 0012 8D 42 17 STA SBD 0015 20 41 1A SYN JSR RDBIT 0018 46 F9 LSR INH 001 05 F9 ORA INH 138 1 19 19 lF 1A 1A 1 19 19 LE 01 01 17 TST ADDR BYTE DUBL OVER WIND ELNK FLSH 139 STA CMP BNE JSR DEC BPL CMP BNE JSR STA LDX JSR STA JSR INX BMI LDX JSR CMP BEQ JSR BNE DEX BNE STA JSR INC BNE INC BNE JSR CMP BNE JSR CMP BNE JSR BEQ JSR STA ASL BEQ STA ADC
183. t 17 E6 Dl INC OSAH AND THE HIGH BYTE IF NEEDED 1700 E6 D4 NYET INC NSAL AND THE NEW ONE 1702 00 02 BNE COUNT 170 05 INC NSAH 1706 C6 08 COUNT DEC BCL TICK OFF THE BYTES 1708 DO 02 ENOUGH FINGERS 17DA C6 D9 DEC BCH USE THE OTHER HAND 1706 DO CC LOOP TIL THEY RE ALL DONE 17DE 00 DONE BRK BACK TO MONITOR i P S Don t forget to set the IRQ vector for the break KIM 1 00 at 17FE FF Hex Dump Movit 1780 D8 AO FF 38 A5 D2 E5 DO 85 08 A5 D E5 01 85 09 1790 18 AS 08 65 D4 85 06 AS 09 65 D5 85 D7 E6 D8 E6 17A0 09 38 A5 D4 E5 A5 05 E5 Dl A2 00 90 02 A2 02 1780 Al DO 81 D4 90 14 C6 02 98 45 02 DO 02 C6 D3 Cb 17 0 D6 98 45 06 DO 02 C6 D7 BO OC E6 DO DO 02 E6 D1 1700 E6 Dh DO 02 E6 D5 C6 08 DO 02 C6 09 DO CC 00 Addition The last address filled can be displayed after the program is complete by adding the following code 1 85 FA between instructions now at 1795 and 1797 2 85 FB between instructions now at 179B and 179D 3 replace the break at the end with 4C 1C Use Movit to move itself to another location and then again to open up the necessary spaces 128 PLL SET Having trouble loading from tape especially Suspect the PLL adjustment might be off but were afraid to adjust it or didn t have a meter or scope handy Use this program and KIM s built in hardware to make the adjustment Hold the tip of the
184. t of the problem has to do with address decoding The expansion connector is essentially an extension of the main arteries of the computer the address and data busses These carry signals between the CPU and memory The data bus carries information to or from a me mory location specified by the address bus The Central Processing Unit CPU on the KIM has the potential of addressing 64K however so you can see that we have barely begun to scratch the surface Decoding The complete address bus isn t available to each memory chip because there are just too many lines and not enough pins on the chips Instead there is some extra circuitry which looks 144 at the entire address bus and determines which block f i usually blocks of memory should be allowed to function 755 This is called decoding circuitry Sub addressing within blocks is handled by the lower address lines which are connected to all chips Decoding sufficient to select one of four 1K blocks already exists on the KIM and is brought out to the expansion connector If you add more than 4K of memory additional decoding will be required Usually this is built into the memory board Buffering If you start adding too many chips to the address and data busses the extra circuits begin to load down the bus and cause it to not function proverly Additional boards are sometimes isolated from the main busses with circuits called buffers which prevent
185. t a bit and 0010 46 F9 LSR INH eeSlip it into 0012 05 F9 eethe right hand 0014 85 F9 STA INH e Side 0016 8D 40 17 STA SAD Show bit flow on display 0019 C9 16 TST 16 15 it a SYNC 0018 DO E9 BNE SYN nope keep em rolling 0010 20 24 1A JSR RDCHT yup start grabbing 0020 C9 2A CMP 2A 8 bits at time and 0022 DO F5 BNE TST eeif it s not an 0024 AQ 00 STREAM LDA 00 then start showing 0026 8D E9 17 STA SAVX echaracters 1 at a time 0029 20 24 1A JSR RDCHT 0022 20 1 JSR PACKT eeconverting to hexadec OO2F DO D5 BNE SYN if legal 0031 A6 EO LDX POINT 0033 8 INX 0034 58 INX Move along to 0055 EO 15 CPX 815 display position 0037 DO 02 BNE OVER If last digit 0059 A2 09 LDX 809 eereset to first 003B 86 EO OVER STX POINT 0050 8E 42 17 STX SBD OOHO AA change character read 0041 BD E IF LDA TABLE X eto segments and 0084 8 HO 17 STA SAD send to the display 0047 DO DB BNE STREAM unconditional jump Checking Out Tapes Recorders Make a test tape containing an endless stream of SYNC characters with the following program 0050 BF GO LDY BF directional 0052 8c 43 17 STY PBOD eo registers 0055 A9 16 LP LDA Z 16 SYNC 0057 20 7A 19 JST OUTCH eee0ut to tape O05A DO F9 BNE LP Now use the program VUTAPE The display should show a steady Synchronization pattern consisting of segments b c and e on the right hand LED Try playing
186. t left f For example to generate a small letter t we would store 78 center upper left lower left bottom The segments will be 3 2 bottom lower right d e 1 7 A 1 upper right Sit in a delay loop for i NE top 1 6 4 Vei ih oos about 1 2 millisecond before moving on to the next digit THE KIM 1 ALPHABET Some letters like M and W just won t go onto a 7 segment display like T can only be done in lower case alphabet of possibles F7 FF 89 SBP F9 F1 BD 586 86 59 5 8 SBF SF3 SED SBE SEE B C D E F G H 1 J L S U Y gt Q rs ce lt SFC D8 SDE F1 EF SF4 84 S9E 86 504 SDC r3 D0 SF8 9C SEE o minus 169 86 DB SCF SE6 SED 587 SFF SEF SBF CO Some like E are only possible in capitals others So here s an a hg auti ei naL A uA cel v ww A on c p endian following is reprinted from the 1 User Manual with permission from MOS Technology Interval Timer 1 Capabilities N The 1 Interval Timer allows the user to specify a preset count of up to 25610 and a clock divide rate of 1 8 6h or 1024 by writing to a memory location
187. t number will have bubbled to the top The whole process is repeated using the second item to start then again starting with the third item Eventually the whole list will be sorted in sequence 17F5 START LO 17F6 START HIGH 17F7 END LO 17F8 END HI NOTE ENDING ADDRESS IS ONE PAST LAST ITEM AD F5 17 SORT LDA 17F5 TRANSFER START POINTER 85 E8 STA 00 8 TO ZERO PAGE 85 EA STA 00 AD F6 17 LDA 17F6 85 E9 STA 00 9 85 EB STA 00 AD F7 17 LDA 17F7 TRANSFER END POINTER 85 EC STA 00EC AD F8 17 LDA 17F8 85 ED STA 00ED A2 00 LDX 00 INDEX TO ZERO STAYS THERE D8 CLD Al E8 GET LDA 00 8 DATA INDIRECT 00 8 Cl EA CMP C00EA X GREATER THAN INDIR 00 BO 0C BCS INCN NO POINTER 00 1 E8 SWAP LDA 00 8 SWAP DATA IN POINTER 85 E7 STA 00 7 LOCATIONS 136 y 0225 Al EA LDA COOEA X 0227 81 8 STA 00 8 0229 As E7 LDA 00E7 022B 81 EA STA COOEA XD 022D E6 EA INCN INC 00EA SET UP NEXT COMPARISON 022F 00 02 BNE LASTN NO PAGE CHANGE 0231 E6 EB INC 00 PAGE CHANGE 0233 5 EA LASTN LDA 00 CK FOR LAST ITEM IN PASS 0235 C5 EC 00 0237 00 E2 0239 ED LDA 00ED IS THIS LAST PASS LOOP 0238 C5 EB 00 023D DO DC BNE GET NO 023F E8 INC OOE8 0241 00 02 BNE OVER NO PAGE CHANGE 0243 E6 E9 INC 00E9 PAGE CHANGE 0245 A5 E8 OVER LDA 00E8 INIT VALUE FOR NEXT PASS 0247 85 EA STA 0249 A5 E9 LDA OOE9 024B 85 E
188. t s a start and you ll learn quite a few things about getting KIM programs Before running this or any other program be sure that you have set the contents of the KIM vector address 10 to A address 11 to X A to address 11 X to address 10 stop the program The last two make the YOU MUST ALWAYS A listing usually That s Keep going on the same line Each line of the program listing may contain more than one value for more than one address The next value is 10 and it needs to go into 0201 You don t need to enter the address Just hit the key and there you are enter 1 0 and you ve got it Notice you didn t need to hit DA you stay in Data mode until you press the AD key Continue to the next line just hit 11 and keep going until you ve put the 00 in location 0208 Congratulations You ve loaded your first program Now go back and check it for correctness Hit AD 0 2 0 0 and use the key to step through and check the values Now let s run the program and see if it works First look at the contents of addresses 0010 and 0011 a note of them when the program runs it will swap those two values Keep in mind that loading the program doesn t make anything happen You have to run it to do the job and that s what we ll do next Running the Program Set address 0200 That s where the first instruction in the program is located you may have noticed that it s ma
189. tand 028E Eh 96 CPX UCNT N for card fn 0290 DO F5 BNE TRY nope ignore key Hit deal another card 0292 20 78 03 JSR YOU deal it 0295 C9 22 i CMP 22 22 or over 0297 BO 40 BCS UBUST yup you bust 0299 EO 05 5 5 0298 FO 53 BEQ UWIN you win 029D DO E8 BNE TRY nope keep going Stand show player s total 029 A5 95 HOLD LDA WINDOW 5 save KIM card 02A1 48 PHA on stack 02A2 A2 00 LDX 0 flag player 02A 20 OF 03 JSR SHTOT for total display 02A7 A2 04 LDX 4 02A9 A9 00 LDA 0 02 95 90 HLOOP STA WINDOW X clean window O2AD CA DEX 2 10 FB BPL HLOOP restore display card and hole card 0280 68 PLA display card 02B1 85 95 STA WINDOW 5 back to display 02B3 A6 7A LDX HOLE get hole card 02B5 20 6D 03 JSR CREC rebuild 02B8 20 92 03 JOR MEX play and display KIM plays here 0288 20 28 03 PLAY JSR WLITE pause to show cards O2BE A5 9A LDA MTOT point total 02CO C9 22 22 22 or over 02C2 BO 29 BCS IBUST yup KIM bust 02Cl 65 9B ADC MACE add 10 for aces 0206 91 LDX WINDOW 1 five cards 02C8 DO 18 BNE IWIN yes KIM wins 02 09 22 9922 22 including aces 02CC 90 02 BCC POV nope count ace high O2CE A5 9A LDA MTOT yup ace low 02DO C9 17 POV 17 17 or over 02D2 BO 2C BCS HOLD2 yes stand 02104 20 03 JSR ME no hit 0217 DO E2 BNE PLAY unconditional Branch KIM wins here 02D9 20 28 03 UBUST JSR WLITE Show player s hand 02DC 20 55
190. the A register that you will want to use after giving JSR SCANDS be sure to put it safely somewhere in memory or you ll lose it The same goes for other registers like X and Y Here s a simple program to show 0000 00 on the display Note that we must put the value 00 into addresses FB FA and F9 before we call JSR SCANDS 0200 A9 00 START LDA 0 zero into A 0202 85 FB STA POINTH first 2 digits 0204 85 FA STA POINTL next 2 digits 0206 85 F9 STA INH last 2 digits 0208 20 1F 1F LOOP JSR SCANDS light up 020B 4C 08 02 JMP LOOP do it again 19 This program never ends so eventually you ll have to stop it with the RS or ST keys See how the last instruction jumps back to address 0208 so the display is lit continuously Another interesting point see how the jump address at 020B is backwards 08 02 instead of 0208 This is called low order first addressing and you ll see a lot of it on the KIM System The single step feature doesn t work too well on Monitor subroutines That s normal and it s not serious These subroutines are well tested and dependable so you shouldn t need to use SST with them Exercises 1 Can you change the program to make the display show 5555 55 2 Can you write a program to make the display show 1234 56 3 How about a program to show the word EFFACE or FACADE or COOCOO 20 MINI PROGRAM D reading the keypad To read the KIM pushbuttons you have another Monitor subrouti
191. the edge of the board Another example address 1704 connects to a very fast timer look at that address and you ll see time going by as a blur M ee ee amp MINI PROGRAM A Swap the contents of two locations This is our first beginner s program It doesn t do much locations 0010 and 0011 going CAUTION locations as follows Set Set Set Set address address address address The first two switch and ST SYSTEM 17FA to 17FB to 17FE to 17FF to locations are needed so that your SST key will work right BRK break instruction behave properly SET UP THESE LOCATIONS AS SOON AS YOU TURN ON YOUR KIM Loading the Program We ll take time to describe how the program works later let s see how to load it looks something like this First 0200 A5 0202 A6 0204 85 0206 86 0208 00 10 11 11 10 The business end of the program the part that goes into the computer is the group of numbers on the left hand The stuff on the right helps explain what the side program does If you look at the numbers on the left you ll see that START the first one 0200 AD 0200 contents that we ve put it in LDA LDX STA STX BRK 10 11 11 10 looks like an address exactly what it is and we can start by entering it with The next number is A5 and that will be its So hit DA 5 and the display will confirm just exchanges the contents of But i
192. this from happening Some memory boards have buffers built in Speed Another problem you should be aware of has to do with how fast the CPU runs and how fast memory chips respond Some CPU s have a wait state so that if the memory is a little slow in responding to entry or retrevial of information the CPU can wait for it The 6502 processor in KIM doesn t have this feature This means that the memory used has to be fast enough to work with the processor lt 4595 What Board We see then that memory expansion can get a little complicated Further details are given in sections 3 2 and 6 1 of the Kim User s Manual Perhaps the easiest way to get around these problems is to buy an assembled board made especially for the KIM decoding buffering etc should already have been taken care of in this case If you build from a kit there are many solder connections that are very close to each other it s easy to make mistakes Kit i or assembled board however you should follow the instructions of someone who has already done it What does it cost Here s the good part Memory prices have been dropping and are continuing to drop Recently boards have been coming out using 4K memory chips which have more bits per chip than the older 1 This reduces the cost further especially on boards having a lot of memory 145 EM Xm Any price quoted would soon be out of date and the price per byte depends heavily
193. to make it perform a simple trick of a different kind e g ring a bell after comple ting the 150th iteration No way A calculator is a closed system In general it is not possible to attach to it external devices not envisioned during the original design microprocessor such as KIM is quite different in this respect In fact frequently its main functions are not to crunch numbers but to receive signals from various sensors such as photocells thermostats switches or pressure transducers to do a small amount of processing of these inputs and then to control devices such as lights motors relays or even to play music In this chapter we will try to show you how easy it is for KIM to perform operations of the type described KIM via its input output ports can receive and transmit control signals Its built in precision quartz crystal controlled time reference and a built in interval timer further simplify various controlling tasks KIM Ports KIM Talks and Listens KIM has four special memory locations which are used for input output and various applications Great things happen if you store numbers in these locations 156 Location 1700 Contents of Application Port A 1701 Data Direction of Port A 1702 Contents of Application Port B 1703 Data Direction of Port B The data contents locations 1700 and 1702 store the data transmitted to or from KIM while the data direction locations 1701 and 1703 determine which port
194. tring have used 0012 to 0017 in the above coding You often don t want a random number that goes all the way up to 255 Hexadecimal FF There are two ways of reducing this range You can AND out the bits you don t want for example AND 7 reduces the range to 0 7 only Alternatively you can write small divide routine and the remainder becomes your random number examples of this can be seen in programs such as BAGEIS 172 lt wis The one publication that devotes all of its space to the KIM 1 6502 machines is KIM 1 6502 USER NOTES 109 Centre Ave W Norriton 19401 Six issues of this bimonthly newsletter costs U S 5 00 for North American subscribers and U S 10 00 for international subscribers Here s some pointers to other KIM 1 6502 articles BYTE November 1975 p 56 Son Of Motorola description of the 6502 instruction set and comparison with the 6800 May 1976 8 Date With KIM n in depth description of KIM D ua abe inteso August 1976 p 44 True Confessions How I Relate To KIM How to use cheap memories with KIM by stretching the clock expand memory implement interrupt prioritizing logic sim ulate a HALT instruction March 1977 p 36 6502 op code table March 1977 p 70 Simplified Omega Receiver Details Using the 6502 for signal processing in low cost navigation receiver Mini Omega April 1977 p 89 Kim Goes
195. ur point total and then will show and play its own hand KIM too might go BUSTED or win on a five card hand Otherwise the most points wins From time to time KIM will advise SHUFFL when the cards start to run low Remember that you have a good chance to beat KIM at this game Keep track of the cards that have been dealt especially aces and face cards and you re likely to be a winner 0200 A2 33 START LDX 51 52 cards in deck 0202 8A DKi TXA Create deck 0203 95 40 STA DECK X inserting cards 0205 CA DEX into deck 0206 10 FA BPL DK1 in sequence 0208 A2 02 LDX 2 Set up 3 locations 020A BD 03 INLOP LDA INIT X eointo 020D 95 75 STA PARAM X zero page 020F CA DEX addresshi dpt amt 40 0210 0212 0215 0217 0218 021A 021C 021 0220 0223 0225 0227 022 022B 022D 022F 0231 0233 0235 0237 0239 023A 023C 023E 0240 0242 0243 0246 0247 0249 0210 0240 O24F 0250 0252 0254 0257 0259 025C 025F 0261 0263 0264 0266 0267 0269 026B 026D 026F 0271 0273 0274 ho 40 40 40 D5 DE 57 77 30 F9 79 F3 77 OB 00 90 FB 17 DEAL BPL INLOP LDA TIMER use random timer STA RND to seed random chain GLD main loop repeats here LDX DPT next card pointer CPX Z9 less than 9 cards BCS NOSHUF 9 or more don t shuffl Shuffle deck 03 03 SHLP RMOV Swap 00 00 LDY SHUF 300 Set up SHUFFL msg JSR FILL
196. ve 023A A2 06 LDX Z6 for each pile 73 023C 023E 0241 0242 0214 0246 0243 O24A 024C 024E 0250 0252 0254 0255 0257 0259 025B 025C 025E 0260 0262 0264 0266 0263 026A 026C 026E 0270 0272 0274 0277 0279 027C 027E 0231 0233 0285 0287 0239 029B 028D 028 0292 0294 0296 0293 0298 029 0230 0232 02Al 02A5 02A7 02A9 03 03 03 03 17 DRESS LDA VALUE 1 X change to JSR SEG segments DEX BNE DRESS NOGO LDX MOVE whose move BNE NOKEY computer s skip CMP 10 hex digit keyed BCS NOKEY no skip CMP 0 zero key BEQ NOKEY yes skip CMP 0A alphabetic BCC NUM no numeric SEC change A F SBC 9 to 1 6 LDX PILE pile already BNE NOKEY Selected TAX LDA FLASHR X L BEQ NOKEY nothing in pile STX PILE OK mark pile STA FLASHR store flash code BCS NOKEY unconditional NUM LDX PILE BEQ NOKEY no pile selected STA TEMP save number LDA VALUE 1 X pile value CMP TEMP pile big enough BCC NOKEY nope SBC TEMP yes take out JSR SEG compute segments INC MOVE computer s move JSR SURVEY end of game BNE NOKEY no keep going JSR MESSAG yes show messg STA WINDOW I 105 LSR IQ get smart all routines join here display NOKEY LDX PILE LDA FLASHR flash pile EOR FLASHR X STA FLASHR X LDA 7F STA PADD LIGHT LDY 13 LDX 5 LITE LDA WINDOW X STA SAD STY SBD LITEX INC CUE BNE LITEX DEY DEY DEX BPL LITE INC WAIT BNE LIGHT 74 02AB 02AD 02AF 0281
197. which you may change to any convenient location For those interested in the theory of the thing T should mention HYPERTAPE is not the limit If you wished to abandon KIM 1 monitor compatibility you could continue to speed up tape by a factor of 4 or 5 times more Can you imagine reading 1K in four seconds For the moment however HYPERTAPE 1 plenty fast for me this program also included in Super dupe A9 AD DUMP LDA SAD 8D EC 17 STA VEB 20 32 19 JSR INTVEB set up sub A9 27 27 85 F5 STA GANG flag for SBD A9 BF LDA SBF 8D 43 17 STA PBDD A2 64 LDX 64 9 16 LDA 8516 20 61 01 JSR HIC A9 2A LDA 2 20 88 01 JSR OUTCHT AD F9 17 LDA ID 20 70 01 JSR OUTBT AD F5 17 LDA SAL 119 JSR LDA JSR DUMPT4 JSR JSR JSR LDA CMP LDA SBC BCC LDA JSR LDA JSR LDA EXIT JSR LDX LDA JSR JMP OUTBTC SAH OUTBTC VEB OUTBTC INCVEB 1 EAL 2 DUMPT4 5 2F OUTCHT CHKL OUTBT CHKH OUTBT 02 04 HIC DISPZ Subroutines HIC STX JSR PLA DEC BNE RTS OUTBTC JSR OUTBT PHA LSR LSR LSR LSR JSR PLA JSR RTS HEXOUT AND CMP CLC BMI ADC 1 ADC OUTCHT LDY STY TRY LDY STY ZON LDX PHA 120 TIC OUTCHT TIC CHKT A A 0 50 HEXl 507 930 507 COUNT 02 TRIB NPUL Y 0194 2C 47 17 70 1 BIT CLKRDI 0197 10 FB 20
198. xecute If we wanted to pinpoint the trouble we could flip over to SST now and track the problem down step by step A last comment on the ST button If the display goes dark and pressing ST doesn t relight it the computer has a different problem It has gone berserk due to a completely illegal Op Code Press the RS Reset button now you ll need to start over and use the BRK and SST features to track down the trouble 18 O MINI PROGRAM C Displaying values KIM has a 6 digit display You can show information on the display quite easily if you know how In the KIM Monitor programs there are several packages called subroutines that you can call upon to do certain jobs You could write the same coding for these jobs yourself but use the Monitor subroutines to Save time and trouble When you give the command JSR SCANDS coded 20 1F IF the Monitor will briefly light the display with the data it finds in addresses 00 OOFA and OOF9 That s three locations each displaying as two digits SO the full six digit display is filled Briefly means exactly that The display lights for split second To get a steady display you must repeat the JSR SCANDS command over and over again Use a loop of course no point in filling up your program with JSR SCANDS instructions You should also know that when you call this Monitor subroutine the contents of your registers are wiped out So if you have something important in
199. y connected through the serial port are stand alone video terminals These units contain a cathode ray T V tube Teletype is a trademark of Teletype Corp 147 CRT keyboard and all necessary guts to display a large number of lines of characters on the screen at orce Common are 12 or 24 lines of 80 characters each With 80 characters a full 72 character Teletype line can be duplicated making the unit indeed a Glass Teletype Fewer Characters Lower Price The price of most video terminals is still up around 1000 even in kit form One way to reduce the cost is to reduce the number of characters and display the results on an ordinary T V set 16 lines of 32 or 64 characters are common This type of unit can be purchased as a video board alone or along with a keyboard in a nice case If purchased seperately you will also need a serial interface board Serial Parallel Conversion Remember that we had planned to use the serial I O ports on KIM The video board or the keyboard is more than likely hooked up to input or output in bytes parallel input or output A whole byte appears on 8 seperate pins along with a timing pulse called a strobe on yet another pin The strobe is used to indicate when data is valid We have to convert this type of input or output to the sequential bit by bit information required by the serial port Luckily there are chips designed especially to do this They are called UART s a
Download Pdf Manuals
Related Search
Related Contents
Mercedes Benz 2002 E 320 User's Manual Mode d`emploi - iHealth Cartouches de filtration standard et mini Uniden BTS150 User's Manual AC-1000E, AC-1000E-C AC-1500E, AC-1500E-C M511W User Manual 0 Ricoh BIZWORKS 106 User's Manual Radio reloj despertador AM/FM y USB Modelo BRD-900 Rollei 21558 tripod accessory Copyright © All rights reserved.
Failed to retrieve file