Giter VIP home page Giter VIP logo

gb-rs's People

Contributors

larttyler avatar

Stargazers

 avatar

Watchers

 avatar  avatar

gb-rs's Issues

Should instructions with limited source variants only allow those variants?

Currently, binary instructions (those that have a left- and right-hand side) are being implemented to follow a specific pattern: The target field matches the type named by the struct (e.g. Pair for Load::Pair), and the source is an enum listing all possible source variants. For example:

pub struct PairLoad {
    pub target: Pair,
    pub source: PairLoadSource,
}

pub enum PairLoadSource {
    Register(Register),
    Data(Data<u8>),
    // etc...
}

However, for some instructions (such as Load::DataPointerLoad), there's really only two possible source variants: either Register::A or Pair::SP. The CPU doesn't include opcodes for any other variants of a data-pointer load.

Which raises the question: is it better to stick with the established pattern for a consistent API, and implement the Load::DataPointerLoad instruction's source as follows, despite the fact that most inner values for each variant will never be used:

pub enum DataPointerLoadSource {
    Register(Register),
    Pair(Pair),
}

Or, does it make more sense to implement it as follows:

pub enum DataPointerLoadSource {
    SP,
    A,
}

Which would clearly indicate that there cannot possibly be any other sources aside from those two.

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.