Giter Club home page Giter Club logo

chip8compilerjs's Introduction

CHIP-8 Compiler

This is a CHIP8 Compiler developed using JavaScript. It allows you to write code, compile, and see it in the emulator afterwards.

Usage

Compiler Screenshot

Click the Compile button to compile the code. Click Start or Step to run your code in the emulator. You can click Stop to stop the emulator, and you can click Reset to reset it. Clicking the Save button on the left will allow you to download the compiled binary file.

Language

Insturction names and descriptions are taked from Cowgod's Chip-8 Technical Reference v1.0.

Opcode Instruction Description
0nnn SYS addr Jump to a machine code routine at nnn.
00E0 CLS Clear the display.
00EE RET Return from a subroutine.
1nnn JP addr Jump to location nnn.
2nnn CALL addr Call subroutine at nnn.
3xkk SE Vx, byte Skip next instruction if Vx = kk.
4xkk SNE Vx, byte Skip next instruction if Vx != kk.
5xy0 SE Vx, Vy Skip next instruction if Vx = Vy.
6xkk LD Vx, byte Set Vx = kk.
7xkk ADD Vx, byte Set Vx = Vx + kk.
8xy0 LD Vx, Vy Set Vx = Vy.
8xy1 OR Vx, Vy Set Vx = Vx OR Vy.
8xy2 AND Vx, Vy Set Vx = Vx AND Vy.
8xy3 XOR Vx, Vy Set Vx = Vx XOR Vy.
8xy4 ADD Vx, Vy Set Vx = Vx + Vy, set VF = carry.
8xy5 SUB Vx, Vy Set Vx = Vx - Vy, set VF = NOT borrow.
8xy6 SHR Vx Vy Set Vx = Vx SHR 1.
8xy7 SUBN Vx, Vy Set Vx = Vy - Vx, set VF = NOT borrow.
8xyE SHL Vx Vy Set Vx = Vx SHL 1.
9xy0 SNE Vx, Vy Skip next instruction if Vx != Vy.
Annn LD I, addr Set I = nnn.
Bnnn JP V0, addr Jump to location nnn + V0.
Cxkk RND Vx, byte Set Vx = random byte AND kk.
Dxyn DRW Vx, Vy, nibble Display n-byte sprite starting at memory location I at (Vx, Vy), set VF = collision.
Ex9E SKP Vx Skip next instruction if key with the value of Vx is pressed.
ExA1 SKNP Vx Skip next instruction if key with the value of Vx is not pressed.
Fx07 LD Vx, DT Set Vx = delay timer value.
Fx0A LD Vx, K Wait for a key press, store the value of the key in Vx.
Fx15 LD DT, Vx Set delay timer = Vx.
Fx18 LD ST, Vx Set sound timer = Vx.
Fx1E ADD I, Vx Set I = I + Vx.
Fx29 LD F, Vx Set I = location of sprite for digit Vx.
Fx33 LD B, Vx Store BCD representation of Vx in memory locations I, I+1, and I+2.
Fx55 LD I, Vx Store registers V0 through Vx in memory starting at location I.
Fx65 LD Vx, I Read registers V0 through Vx from memory starting at location I.

Dependencies

Resources

License

The source code is provided under MIT License.

chip8compilerjs's People

Contributors

cinar avatar

Watchers

 avatar  avatar

chip8compilerjs's Issues

Wrong code flow

I put the following code on emulator to test it:

LD V0 0x5

SE V0 0x5 //skip if vx equal kk
JP L1
JP L2

L1:
.... LD V1 0x1
.... JP L1`

L2:
.... LD V1 0x2
.... JP L2

In this code, only the loop code starting at the "L2" label would be executed, but that is not what is happening, SE is not skipping the next instruction, causing L1 to always be executed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.