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

Implement the prefix RL & RR instructions #24

Open
bleasey opened this issue Feb 1, 2024 · 0 comments
Open

Implement the prefix RL & RR instructions #24

bleasey opened this issue Feb 1, 2024 · 0 comments
Assignees

Comments

@bleasey
Copy link
Collaborator

bleasey commented Feb 1, 2024

Things to be done

Refer to the last portion here for additional details. Also refer this pdf for details on the instructions.

Decode the instruction

  • The first two bits of op will determine which family of instructions to execute. 00 corresponds to the Rotate/Shift family of instructions.
  • The next three bits determine the exact function (010 corresponds to RL & 011 corresponds to RR).
  • The last three bits determine the register whose value should be checked. The data member register_operands_map (note that it is renamed, no pfx word) of the CPU class can be used for this purpose.

Description

RL: Rotate n left through Carry flag.

RR: Rotate n right through Carry flag.

Flags affected in both cases:

  • Z - Set if result is zero.
  • N - Reset.
  • H - Reset.
  • C - Contains old bit 7 data.

Create the methods

Follow a similar approach as you did last time!

Files to be edited

  • CPU.h
  • ins_prefix.cpp

Read this again!

Again, since everyone is working on the same file simultaneously, we will follow certain conventions to reduce merge conflicts and ensure uniformity in code.

  • Use only simple nested if-s for decoding. Although not optimal, we can later optimize these and convert them to if-else ladders or switch case statements in another issue. For example:
void PFX()
{
    ...
    if( <check if first two bits correspond to 0b00 for Rotate-Shift family>)
    {
        ...
        if(<check for 0b100: SLA> { ... }
        ...
        if(<Add your if condition here>) { ... }
        ...
    }
    ...
}

Note: Among the above nested, the final one is meant to throw an error to check if SLA (0b100) was not found as that was the only instruction implemented in the last commit. REMOVE THIS IF STATEMENT AND ADD YOURS AT THE END. Also make sure to use the variables already available unless necessary.

Reminders

  • Add (if) any new data members you create in the private section at the bottom of the CPU.h file. Avoid if not necessary as variables are already available.
  • Add any new member functions you create along with the other functions similar to them in the header file. For example, define any prefix related functions in the header file in the Prefix Instructions section.
  • No global/static variables unless there's a very good reason
  • Add only brief comments to clarify things if the code is not very intuitive or involves tricks, for other cases, try using long descriptive names for the variables instead so comments aren't very necessary.
  • Use camel case only for type/class/structure names and snake case for everything else.
  • Proper indentation xD
@Madhav160804 Madhav160804 self-assigned this Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants