Giter VIP home page Giter VIP logo

8js's People

Contributors

heavenvolkoff avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

8js's Issues

Both shift instructions implementations are wrong

According to this documentations:
https://github.com/mattmikolay/chip-8/wiki/CHIP%E2%80%908-Instruction-Set
https://johnearnest.github.io/Octo/docs/chip8ref.pdf

The 8XY6 and 8XYE operations store the result of shifting the Vy register in Vx register.
Operating over Vx seems to be an incorrect descriptions of this operations behavior found in the S-CHIP original documentation. However this is not compatible with the original CHIP-8 implementation.

8js/src/CPU.js

Lines 516 to 542 in fb64163

/**
* 8xy6 - SHR Vx {, Vy}
*
* Set Vx = Vx SHR 1.
* If the least-significant bit of Vx is 1, then VF is set to 1, otherwise 0. Then Vx is divided by 2.
*
* @param reg
*/
CPU.prototype.shr = function shiftRigth(reg) {
this.reg.writeUInt8(this.reg[reg] & 0x1, 0xF);
this.reg.writeUInt8(this.reg[reg] >> 1, reg);
this.nextInstruction();
};
/**
* 8xyE - SHL Vx {, Vy}
*
* Set Vx = Vx SHL 1.
* If the most-significant bit of Vx is 1, then VF is set to 1, otherwise to 0. Then Vx is multiplied by 2.
*
* @param reg
*/
CPU.prototype.shl = function shiftLeft(reg) {
this.reg.writeUInt8(this.reg[reg] >> 7, 0xF);
this.reg.writeUInt8(this.reg[reg] << 1, reg, true);
this.nextInstruction();
};

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.