CHIP-8 is an interpreted programming language, developed by Joseph Weisbecker made on his 1802 Microprocessor. It was initially used on the COSMAC VIP and Telmac 1800 8-bit microcomputers in the mid-1970s. CHIP-8 programs are run on a CHIP-8 virtual machine. It was made to allow video games to be more easily programmed for these computers. The simplicity of CHIP-8, and its long history and popularity, has ensured that CHIP-8 emulators and programs are still being made to this day.
Roughly fifteen years after CHIP-8 was introduced, derived interpreters appeared for some models of graphing calculators (from the late 1980s onward, these handheld devices in many ways have more computing power than most mid-1970s microcomputers for hobbyists).
An active community of users and developers existed in the late 1970s, beginning with ARESCO's "VIPer" newsletter whose first three issues revealed the machine code behind the CHIP-8 interpreter. [1]
There are a number of classic video games ported to CHIP-8, such as Pong , Space Invaders , Tetris , and Pac-Man . There are also applications like a random maze generator and Conway's Game of Life.
During the 1970s and 1980s, CHIP-8 users shared CHIP-8 programs, but also changes and extensions to the CHIP-8 interpreter, in the COSMAC VIP users' newsletter, VIPER magazine. These extensions included CHIP-10 and Hi-Res CHIP-8, which introduced a higher resolution than the standard 64x32, and CHIP-8C and CHIP-8X, which extended the monochrome display capabilities to support limited color, among other features. [2] These extensions were mostly backwards compatible, as they were based on the original interpreter, although some repurposed rarely used opcodes for new instructions. [3]
In 1979, Electronics Australia ran a series of articles on building a kit computer similar to the COSMAC VIP, based on the Motorola 6800 architecture. [4] This computer, the DREAM 6800, came with its own version of CHIP-8. A newsletter similar to VIPER, called DREAMER [5] , was used to share CHIP-8 games for this interpreter. In 1981, Electronics Today International (ETI) ran a series of articles on building a computer, the ETI-660, which also was very similar to the VIP (and used the same microprocessor). ETI ran regular ETI-660 and general CHIP-8 columns [6] until 1985.
In 1990, a CHIP-8 interpreter called CHIP-48 was made for HP-48 graphing calculators so games could be programmed more easily. Erik Bryntse later created another interpreter based on CHIP-48, called SCHIP, S-CHIP or Super-Chip. SCHIP extended the CHIP-8 language with a larger resolution and several additional opcodes meant to make programming easier. [7] If it were not for the development of the CHIP-48 interpreter, CHIP-8 would not be as well known today.[ citation needed ]
David Winter's emulator, disassembler, and extended technical documentation popularized CHIP-8/SCHIP on many other platforms. It laid out a complete list of undocumented opcodes and features [8] , and was distributed across many hobbyist forums. Many emulators used these works as a starting point.
However, CHIP-48 subtly changed the semantics of a few of the opcodes, and SCHIP continued to use those new semantics in addition to changing other opcodes. Many online resources about CHIP-8 propagate these new semantics, so many modern CHIP-8 games are not backwards compatible with the original CHIP-8 interpreter for the COSMAC VIP, even if they do not specifically use the new SCHIP extensions. [9]
There is a CHIP-8 implementation for almost every platform, as well as some development tools. Games are still being developed and cataloged for CHIP-8 today, in addition to older games resurfacing online in digital archives. [10] [11]
While CHIP-8 and SCHIP have commonly been implemented as emulators, a pure hardware implementation (written in the Verilog language) also exists for certain FPGA boards.
CHIP-8 was most commonly implemented on 4K systems, such as the Cosmac VIP and the Telmac 1800. These machines had 4096 (0x1000) memory locations, all of which are 8 bits (a byte) which is where the term CHIP-8 originated. However, the CHIP-8 interpreter itself occupies the first 512 bytes of the memory space on these machines. For this reason, most programs written for the original system begin at memory location 512 (0x200) and do not access any of the memory below the location 512 (0x200). The uppermost 256 bytes (0xF00-0xFFF) are reserved for display refresh, and the 96 bytes below that (0xEA0-0xEFF) were reserved for the call stack, internal use, and other variables.
In modern CHIP-8 implementations, where the interpreter is running natively outside the 4K memory space, there is no need to avoid the lower 512 bytes of memory (0x000-0x1FF), and it is common to store font data there.
CHIP-8 has 16 8-bit data registers named V0 to VF. The VF register doubles as a flag for some instructions; thus, it should be avoided. In an addition operation, VF is the carry flag, while in subtraction, it is the "no borrow" flag. In the draw instruction VF is set upon pixel collision.
The address register, which is named I, is 12 bits wide and is used with several opcodes that involve memory operations.
The stack is only used to store return addresses when subroutines are called. The original RCA 1802 version allocated 48 bytes for up to 12 levels of nesting; [12] modern implementations usually have more. [13] [14]
CHIP-8 has two timers. They both count down at 60 hertz, until they reach 0.
Input is done with a hex keyboard that has 16 keys ranging 0 to F. The '8', '4', '6', and '2' keys are typically used for directional input. Three opcodes are used to detect input. One skips an instruction if a specific key is pressed, while another does the same if a specific key is not pressed. The third waits for a key press, and then stores it in one of the data registers.
Original CHIP-8 Display resolution is 64×32 pixels, and color is monochrome. Graphics are drawn to the screen solely by drawing sprites, which are 8 pixels wide and may be from 1 to 15 pixels in height. Sprite pixels are XOR'd with corresponding screen pixels. In other words, sprite pixels that are set flip the color of the corresponding screen pixel, while unset sprite pixels do nothing. The carry flag (VF) is set to 1 if any screen pixels are flipped from set to unset when a sprite is drawn and set to 0 otherwise. This is used for collision detection.
As previously described, a beeping sound is played when the value of the sound timer is nonzero.
CHIP-8 has 35 opcodes, which are all two bytes long and stored big-endian. The opcodes are listed below, in hexadecimal and with the following symbols:
There have been many implementations of the CHIP-8 instruction set since 1978. The following specification is based on the SUPER-CHIP specification from 1991 (but without the additional opcodes that provide extended functionality), as that is the most commonly encountered extension set today. Footnotes denote incompatibilities with the original CHIP-8 instruction set from 1978.
Opcode | Type | C Pseudo | Explanation |
---|---|---|---|
0NNN | Call | Calls machine code routine (RCA 1802 for COSMAC VIP) at address NNN. Not necessary for most ROMs. [13] | |
00E0 | Display | disp_clear() | Clears the screen. [13] |
00EE | Flow | return; | Returns from a subroutine. [13] |
1NNN | Flow | gotoNNN; | Jumps to address NNN. [13] |
2NNN | Flow | *(0xNNN)() | Calls subroutine at NNN. [13] |
3XNN | Cond | if(Vx==NN) | Skips the next instruction if VX equals NN (usually the next instruction is a jump to skip a code block). [13] |
4XNN | Cond | if(Vx!=NN) | Skips the next instruction if VX does not equal NN (usually the next instruction is a jump to skip a code block). [13] |
5XY0 | Cond | if(Vx==Vy) | Skips the next instruction if VX equals VY (usually the next instruction is a jump to skip a code block). [13] |
6XNN | Const | Vx=NN | Sets VX to NN. [13] |
7XNN | Const | Vx+=NN | Adds NN to VX (carry flag is not changed). [13] |
8XY0 | Assig | Vx=Vy | Sets VX to the value of VY. [13] |
8XY1 | BitOp | Vx|=Vy | Sets VX to VX or VY. (bitwise OR operation). [13] |
8XY2 | BitOp | Vx&=Vy | Sets VX to VX and VY. (bitwise AND operation). [13] |
8XY3 [lower-alpha 1] | BitOp | Vx^=Vy | Sets VX to VX xor VY. [13] |
8XY4 | Math | Vx+=Vy | Adds VY to VX. VF is set to 1 when there's an overflow, and to 0 when there is not. [13] |
8XY5 | Math | Vx-=Vy | VY is subtracted from VX. VF is set to 0 when there's an underflow, and 1 when there is not. (i.e. VF set to 1 if VX >= VY and 0 if not). [13] |
8XY6 [lower-alpha 1] | BitOp | Vx>>=1 | Stores the least significant bit of VX in VF and then shifts VX to the right by 1. [lower-alpha 2] [13] |
8XY7 [lower-alpha 1] | Math | Vx=Vy-Vx | Sets VX to VY minus VX. VF is set to 0 when there's an underflow, and 1 when there is not. (i.e. VF set to 1 if VY >= VX). [13] |
8XYE [lower-alpha 1] | BitOp | Vx<<=1 | Stores the most significant bit of VX in VF and then shifts VX to the left by 1. [lower-alpha 2] [13] |
9XY0 | Cond | if(Vx!=Vy) | Skips the next instruction if VX does not equal VY. (Usually the next instruction is a jump to skip a code block). [13] |
ANNN | MEM | I=NNN | Sets I to the address NNN. [13] |
BNNN | Flow | PC=V0+NNN | Jumps to the address NNN plus V0. [13] |
CXNN | Rand | Vx=rand()&NN | Sets VX to the result of a bitwise and operation on a random number (Typically: 0 to 255) and NN. [13] |
DXYN | Display | draw(Vx,Vy,N) | Draws a sprite at coordinate (VX, VY) that has a width of 8 pixels and a height of N pixels. Each row of 8 pixels is read as bit-coded starting from memory location I; I value does not change after the execution of this instruction. As described above, VF is set to 1 if any screen pixels are flipped from set to unset when the sprite is drawn, and to 0 if that does not happen. [13] |
EX9E | KeyOp | if(key()==Vx) | Skips the next instruction if the key stored in VX is pressed (usually the next instruction is a jump to skip a code block). [13] |
EXA1 | KeyOp | if(key()!=Vx) | Skips the next instruction if the key stored in VX is not pressed (usually the next instruction is a jump to skip a code block). [13] |
FX07 | Timer | Vx=get_delay() | Sets VX to the value of the delay timer. [13] |
FX0A | KeyOp | Vx=get_key() | A key press is awaited, and then stored in VX (blocking operation, all instruction halted until next key event). [13] |
FX15 | Timer | delay_timer(Vx) | Sets the delay timer to VX. [13] |
FX18 | Sound | sound_timer(Vx) | Sets the sound timer to VX. [13] |
FX1E | MEM | I+=Vx | Adds VX to I. VF is not affected. [lower-alpha 3] [13] |
FX29 | MEM | I=sprite_addr[Vx] | Sets I to the location of the sprite for the character in VX. Characters 0-F (in hexadecimal) are represented by a 4x5 font. [13] |
FX33 | BCD | set_BCD(Vx)*(I+0)=BCD(3);*(I+1)=BCD(2);*(I+2)=BCD(1); | Stores the binary-coded decimal representation of VX, with the hundreds digit in memory at location in I, the tens digit at location I+1, and the ones digit at location I+2. [13] |
FX55 | MEM | reg_dump(Vx,&I) | Stores from V0 to VX (including VX) in memory, starting at address I. The offset from I is increased by 1 for each value written, but I itself is left unmodified. [lower-alpha 4] [13] |
FX65 | MEM | reg_load(Vx,&I) | Fills from V0 to VX (including VX) with values from memory, starting at address I. The offset from I is increased by 1 for each value read, but I itself is left unmodified. [lower-alpha 4] [13] |
The MOS Technology 6502 is an 8-bit microprocessor that was designed by a small team led by Chuck Peddle for MOS Technology. The design team had formerly worked at Motorola on the Motorola 6800 project; the 6502 is essentially a simplified, less expensive and faster version of that design.
The 6800 is an 8-bit microprocessor designed and first manufactured by Motorola in 1974. The MC6800 microprocessor was part of the M6800 Microcomputer System that also included serial and parallel interface ICs, RAM, ROM and other support chips. A significant design feature was that the M6800 family of ICs required only a single five-volt power supply at a time when most other microprocessors required three voltages. The M6800 Microcomputer System was announced in March 1974 and was in full production by the end of that year.
The 68HC11 is an 8-bit microcontroller family introduced by Motorola Semiconductor in 1984. It descended from the Motorola 6800 microprocessor by way of the 6801. The 68HC11 devices are more powerful and more expensive than the 68HC08 microcontrollers and are used in automotive applications, barcode readers, hotel card key writers, amateur robotics, and various other embedded systems. The MC68HC11A8 was the first microcontroller to include CMOS EEPROM.
The Original Chip Set (OCS) is a chipset used in the earliest Commodore Amiga computers and defined the Amiga's graphics and sound capabilities. It was succeeded by the slightly improved Enhanced Chip Set (ECS) and the greatly improved Advanced Graphics Architecture (AGA).
The Intel MCS-51 is a single chip microcontroller (MCU) series developed by Intel in 1980 for use in embedded systems. The architect of the Intel MCS-51 instruction set was John H. Wharton. Intel's original versions were popular in the 1980s and early 1990s, and enhanced binary compatible derivatives remain popular today. It is a complex instruction set computer, but also has some of the features of RISC architectures, such as a large register set and register windows, and has separate memory spaces for program instructions and data.
The Intel 8085 ("eighty-eighty-five") is an 8-bit microprocessor produced by Intel and introduced in March 1976. It is software-binary compatible with the more-famous Intel 8080 with only two minor instructions added to support its added interrupt and serial input/output features. However, it requires less support circuitry, allowing simpler and less expensive microcomputer systems to be built. The "5" in the part number highlighted the fact that the 8085 uses a single +5-volt (V) power supply by using depletion-mode transistors, rather than requiring the +5 V, −5 V and +12 V supplies needed by the 8080. This capability matched that of the competing Z80, a popular 8080-derived CPU introduced the year before. These processors could be used in computers running the CP/M operating system.
In computer engineering, Halt and Catch Fire, known by the assembly language mnemonic HCF, is an idiom referring to a computer machine code instruction that causes the computer's central processing unit (CPU) to cease meaningful operation, typically requiring a restart of the computer. It originally referred to a fictitious instruction in IBM System/360 computers, making a joke about its numerous non-obvious instruction mnemonics.
Fetching the instruction opcodes from program memory well in advance is known as prefetching and it is served by using a prefetch input queue (PIQ). The pre-fetched instructions are stored in a queue. The fetching of opcodes well in advance, prior to their need for execution, increases the overall efficiency of the processor boosting its speed. The processor no longer has to wait for the memory access operations for the subsequent instruction opcode to complete. This architecture was prominently used in the Intel 8086 microprocessor.
The Netronics ELF II was an early microcomputer trainer kit featuring the RCA 1802 microprocessor, 256 bytes of RAM, DMA-based bitmap graphics, hexadecimal keypad, two digit hexadecimal LED display, a single "Q" LED, and 5 expansion slots. The system was developed and sold by Netronics Research and Development Limited in New Milford, CT, USA.
The COSMAC is an 8-bit microprocessor family introduced by RCA. It is historically notable as the first CMOS microprocessor. The first production model was the two-chip CDP1801R and CDP1801U, which were later combined into the single-chip CDP1802. The 1802 represented the majority of COSMAC production, and today the entire line is known simply as the RCA 1802.
The COSMAC VIP (1977) was an early microcomputer that was aimed at video games. Essentially, it was a COSMAC ELF with a supplementary CDP1861/CDP1864 video display chip. For a price of US$275, it could be purchased from RCA by mail order. It came in kit form, and had to be assembled. Its dimensions were 22 x 28 cm, and it had an RCA 1802 processor; along with a crystal clock operating at 1.76 MHz. It had 2 KB of RAM, which could be expanded to 4 KB on board, and 32 KB via an expansion slot. Its 5V DC CDP18S023 power supply had an output of 600 mA. I/O ports could be added to connect to sensors, interface relays, an ASCII keyboard, or a printer.
The COSMAC Elf was an RCA 1802 microprocessor-based computer described in a series of construction articles in Popular Electronics magazine in 1976 and 1977. Through the back pages of electronics magazines, both Netronics and Quest Electronics offered low-priced, enhanced kits that were based on this design. The system was a very early single-board personal computer. It was operated without built-in ROMs and programs were entered directly with help of the CPU integrated DMA using 8 toggle switches and an Input push button.
The Fairchild F8 is an 8-bit microprocessor system from Fairchild Semiconductor, announced in 1974 and shipped in 1975. The original processor family included four main 40-pin integrated circuits (ICs); the 3850 CPU which was the arithmetic logic unit, the 3851 Program Storage Unit (PSU) which contained 1 KB of program ROM and handled instruction decoding, and the optional 3852 Dynamic Memory Interface (DMI) or 3853 Static Memory Interface (SMI) to control additional RAM or ROM holding the user programs or data. The 3854 DMA was another optional system that added direct memory access into the RAM controlled by the 3852.
TLCS is a prefix applied to microcontrollers made by Toshiba. The product line includes multiple families of CISC and RISC architectures. Individual components generally have a part number beginning with "TMP". E.g. the TMP8048AP is a member of the TLCS-48 family.
The Intersil 6100 is a single-chip microprocessor implementation of the 12-bit PDP-8 instruction set, along with a range of peripheral support and memory ICs developed by Intersil in the mid-1970s. It was sometimes referred to as the CMOS-PDP8. Since it was also produced by Harris Corporation, it was also known as the Harris HM-6100. The Intersil 6100 was introduced in the second quarter of 1975, and the Harris version in 1976.
RL78 Family is a 16-bit CPU core for embedded microcontrollers of Renesas Electronics introduced in 2010.
The Electronic Arrays 9002, or EA9002, was an 8-bit microprocessor released in 1976. It was designed to be easy to implement in systems with few required support chips. It included 64 bytes of built-in RAM and could be directly connected to TTL devices. It was packaged in a 28-pin DIP which made it less expensive to implement than contemporary designs like the 40-pin MOS 6502 and Zilog Z80. Today it would be known as a microcontroller, although that term did not exist at the time.
The Gigatron TTL is a retro-style 8-bit computer, where the CPU is implemented by a set of TTL chips instead of a single microprocessor, imitating the hardware present in early arcades. Its target is the computing enthusiasts, for studying or hobby purposes.
The COP400 or COP II is a 4-bit microcontroller family introduced in 1977 by National Semiconductor as a follow-on product to their original PMOS COP microcontroller. COP400 family members are complete microcomputers containing internal timing, logic, ROM, RAM, and I/O necessary to implement dedicated controllers. Some COP400 devices were second-sourced by Western Digital as the WD4200 family. In the Soviet Union several COP400 microcontrollers were manufactured as the 1820 series.