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

[#768] msp430x: Fix immediate addressing #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

peroxyacyl
Copy link

@peroxyacyl peroxyacyl commented Mar 18, 2025

This PR fixes renode/renode#768

Description

The way MSP430X handles immediate values in the instruction is complicated because of the 20-bit extension.
The immediate addressing is represented in the instructions as @PC+. The current implementation is written along with @Rn+. It is valid for 16-bit mode but not what is expected for 20-bit mode.

The current implementation for @PC+ here acts like:

  1. get value at PC, which is the address of the immediate operand in the instruction
  2. append the 4-bit address extension
  3. increment PC by 2
  4. access the operand by the 20-bit address
  5. return the operand

Expected behaviour

The address extension should be appended after fetching the immediate operand word.

  1. get value at PC, which is the address of the immediate operand in the instruction
  2. access the operand by the 16-bit address
  3. append the 4-bit address extension
  4. increment PC by 2
  5. return the 20-bit operand

@CLAassistant
Copy link

CLAassistant commented Mar 18, 2025

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

MSP430X: Immediate addressing
2 participants