Git Product home page Git Product logo

6809js's Introduction

6809js

An JavaScript emulation of Motorola 6809 CPU

Used in all emulations at ASM80 online IDE

You can use 6809js also as Node.js or AMD module.

Usage

(a.k.a. The API)

  • window.CPU6809 - main object (instantiated at the start - it shall change)
  • CPU6809.init(memoryTo,memoryAt,ticker) - Initializes the whole system. All parameters are callback functions for port / memory access:
    • memoryTo(addr,value) - store byte to given address
    • memoryAt(addr) - read byte from given address
    • ticker(T) - unused now. For future use
  • CPU6809.T() - returns clock ticks count from last init (or reset)
  • CPU6809.reset() - does a CPU reset
  • CPU6809.set(register, value) - sets internal register (named PC, SP, U, A, B, X, Y, DP, FLAGS) to a given value (SP means S, it's for compatibility)
  • CPU6809.status() - Returns a object {pc, sp, u, a, b, x, y, dp, flags} with actual state of internal registers
  • CPU6809.steps(N) - Execute instructions as real CPU, which takes "no less than N" clock ticks.
  • CPU6809.disasm(a, b, c, d, e, pc) - Disassembler. Takes 5 successive values (the longest 6809 opcode takes 5 bytes) and value of program counter (for evaluating relative jumps). Returns array of two values - mnemo code and instruction length in bytes, eg. ["TFR X,S",2].

Tests

6809js is slightly tested with qUnit - just a basic functionality at this moment

Roadmap

  • full interrupts support
  • full CWAI emulation
  • HD6309 extended mode

Support

Become a Patron!

6809js's People

Contributors

maly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

6809js's Issues

Bug in NEG

First - Thank you for this great piece of work; it has allowed me to mock-up a system very quickly.

There is a bug in the NEG op, however, where the carry flag isn't set correctly - a quick fix (Not tested completely) has got it working for me (YMMV):

if(b === 0) { CC |= F_ZERO; } else { CC |= F_CARRY; } if(b & 0x80) { CC |= F_NEGATIVE; }

Invalid carry flag after DAA

Steps to reproduce:

Assemble and run the following code:

LDA #$91
ADD #$91
DAA

What happened?

Carry was reset.

When similar code was used for multi-byte decimal addition, it yielded incorrect results.

What was expected?

Carry should be set. DAA keeps the carry flag set if it was set beforehand, see the mc6809 emulator sources for comparison: https://github.com/spc476/mc6809/blob/master/mc6809.c#L420 or the official Programming Manual: https://archive.org/details/bitsavers_motorola68_13419254/page/n83/mode/2up

C โ€“ Set if a carry is generated or if the carry bit was set before the operation; cleared otherwise.

After some research, I noticed that this is a common bug in many 6809 emulators.

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.