Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use binary literals and consts for CPU constants #21

Open
SubstituteR opened this issue Nov 4, 2020 · 0 comments
Open

Use binary literals and consts for CPU constants #21

SubstituteR opened this issue Nov 4, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@SubstituteR
Copy link
Collaborator

SubstituteR commented Nov 4, 2020

For things that are constant in the CPU, such as CC max (binary 11) we can use constant literals to make code easier to digest for new contributors.

Example:

// definition
public const byte CC_Max = 0b11 << 6;
// OR
public const byte CC_Max = 0b11000000;
//
// later in the code
//
case 0x30: //   JEQ 
    if ((SW & CC_Max) == 0)
    {
        PC = TA;
    }
    else { this.PC += 3; }
    break;

Alternatively, we can consider making them static and initializing them using their actual values, e.g.

public static byte CC_Max = 0b11;

and later either translate them as needed or simply doing the conversion during the declaration, not sure, we can get creative.

@SubstituteR SubstituteR added the enhancement New feature or request label Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant