RCA CDP18S711 manual III.CHIP-8Language Programming, Branch Instructions

Page 12
III.CHIP-8 Language Programming

III.CHIP-8 Language Programming

CHIP-8 is an easy-to-learn programming language that lets you write your own programs. To use the CHIP-8 language, you must first store the 512-byte CHIP-8 language program at memory locations 0000 to 01FF. The CHIP-8 language program is shown in Appendix C in hex form so you can enter it directly in memory using the hex keyboard. You can then record it on a memory cassette for future use. Each CHIP-8 instruction is a two-byte (4-hex-digit) code. There are 31, easy-to-use CHIP-8 instructions as shown in Table L

When using CHIP-8 instructions your program must always begin at location 0200. There are 16 one-

byte variables labeled 0-F. VX or VY refers to the value of one of these variables. A 63FF instruction sets variable 3 to the value FF (V3=FF). I is a memory pointer that can be used to specify any location in RAM. An A232 instruction would set I= 0232. 1 would then address memory location 0232.

Branch Instructions

There are several types of jump or branch instructions in the CHIP-8 language. Instruction 1242 would cause an unconditional branch to the instruction at memory location 0242. Instruction BMMM lets you index the branch address by adding the value of variable 0 to it before branching. Eight conditional skip instructions let you test the values of the 16 one-byte variables or determine if a specific hex key is being pressed. This latter capability is useful in video game programs. (Only the least significant hex digit of VX is used to specify the key.)

A 2570 instruction would branch to a subroutine starting at location 0570. 00EE at the end of this subroutine will return program execution to the

instruction following the 2570. The subroutine itself could use another 2MMM instruction to branch to (or call) another subroutine. This technique is known as subroutine nesting. Note that all subroutines called (or branched to) by 2MMM instructions must end with 00EE. Ignoring this rule will cause hard-to-find program bugs.

How to Change and

Use the Variables

The CXKK instruction sets a random byte value into VX. This random byte would have any bits matching 0 bit positions in KK set to 0. For example, a C407 instruction would set V4 equal to a random byte value between 00 and 07.

A timer (or real-time clock) can be set to any value between 00 and FF by a FX15 instruction. This timer is automatically decremented by one, 60 times per second until it reaches 00. Setting it to FF would require about 4 seconds for it to reach 00. This timer can be examined with a FX07 instruction. A FX18 instruction causes a tone to be sounded for the time specified by the value of VX. A value of FF would result in a 4-second tone. The minimum time that the speaker will respond to is that corresponding to the variable value 02.

A FX33 instruction converts the value of VX to decimal form. Suppose 1=0422 and V9=A7. A F933 instruction would cause the following bytes to be stored in memory:

0422 01

0423 06

0424 07

Since A7 in hex equals 167 in decimal, we see that the

Image 12
Contents Page RCA COSMAC VIP CDP18S711 Instruction Manual VIP-311ACKNOWLEDGMENT Contents Contents Continued 1. Getting Started What This Manual CoversThe Power Supply What You See Turning It On1. Getting Started Using the Operating System 11.COSMAC VIP OperationMemory Write Memory Read Tape WriteTape Read Testing Your Cassette System 11.COSMAC VIP OperationHow to Change and Use the Variables III.CHIP-8Language ProgrammingBranch Instructions Using the Display Instructions III. CHIP-8 Language Programming 0200 A20A I=020A 0202 6100 V1=00 0204 6200 V2=000206 D125 SHOW 5MI@VlV2 0208 1208 GO 020A F090 020C F090 020E F000Applying CHIP-8 Some Program Ideas 111. CHIP-8Language Programming25.PROGRAMMED SPOT - Introduce children to programming concepts by letting them preprogram the movements of a spot or object on the screen IV. Machine Language Programming VIP Machine CodingMachine Language Programming Summed Up V. Logic Description How Memory Is AddressedHow the Input/Output Works pressed. A 62 machine instruction causes the least significant 4 bits of memory byte to be latched into U13. These 4 bits are decoded to bring one of the 16 U13 output lines low. If the key that corresponds to this output line is pressed, the CDPI802 EF3 input will go low. The 4-bitcodes latched into U13 correspond to the equivalent key positions. After the program send8 a 4-bitcode to U13, it subsequently examines the EF3 line to see if the key corresponding to this code is pressed or not. In this manner, a program can determine when any specific key is pressed or can sequentially scan all keys while waiting for any one to be pressed. Key debounce delays must be provided in the program when required. A program can also cause a speaker tone to occur when a key is pressed. Only one key at a time should be pressed with this method of interfacing the keyboard Using the Byte Input/Output V1. Expansion Considerations and ConnectionsUsing the Expansion Interface Some Expansion IdeasI RCA COSMAC VIP Instruction Manual Pin Signal V1. Expansion Considerations and ConnectionsTable III - External Option Terminal Connections 2.Composing poetry or pictures with printer output VIL Troubleshooting Hints Other ProblemsSignal Tracing No SoundLast Resorts Appendix A - Test and Operating Data Byte Pattern for Displaying COSMACBeeper Program Cassette Attachment Diagram Cassette Phase Test SignalsTest Program Cassette Data Test Cassette Recording Guidelines Memory Test ProgramAppendix B - Operating System Operating System ListingOperating System Register Table Operating System SummaryR3 = Machine Language Subroutine Program Counter Appendix C - CHIP-8Interpreter CHIP-8Interpreter ListingCHIP-8Memory Map CDP1802 Register Use for CHIP-8Interpreter Appendix C - CHIP-8Interpreter CHIP-8User Notes RCA COSMAC VIP Instruction ManualPage 1. VIP Kaleidoscope 2. VIP Video Display Drawing Game Appendix E - Logic Diagrams Fig. E-5Power Supply Circuit and ByteFig. E-1Microprocessor and Display Interface CircuitsPage Fig. E-2- ROM Circuits and Expansion Interface Appendix E - Logic DiagramsPage Fig. E-4- RAM Circuits Appendix E - Logic DiagramsRCA COSMAC VIP Instruction Manuel RCA COSMAC VIP Instruction Manual Board Layout, Parts List, and Expansion Notes Appendix F2.Parts List for RCA COSMAC VIP CDP18S711 1.Printed Circuit Board LayoutRCA COSMAC VIP Instruction Manual Page 2. Parts List for RCA COSMAC VIP CDP18S711 Page RCA COSMAC VIP Instruction Manual Resistors - Supplied 1 /4 W except as notedPage 3. COSMAC VIP Expansion Notes