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

[Breaking] MOS: 65816 assembler fixes, part 2 #456

Merged

Conversation

asiekierka
Copy link
Contributor

@asiekierka asiekierka commented Mar 10, 2024

More fixes for #454 . These come after #455 .

  • The immediate and address modifiers (#<, #>, #^, <, !, >) now adhere to WDC recommendations as documented in the 65816 datasheet.
    • In particular, this means the behaviour of "lda >addr" changes, while "lda !addr" and "lda #^addr" have been introduced.
  • Immediate expressions now emit R_MOS_IMM8 and R_MOS_IMM16, while address expressions now emit R_MOS_ADDR8 and R_MOS_ADDR16 relocations.
  • Some error messages have been adjusted to more accurately represent the assembler's limitations.
  • Bugs/limitations in the SPC700 assembler's handling of "addr + X" and "addr + Y" addressing mode syntaxes have been fixed, and a test has been added.
  • "S" and "R" can now be used as register names in stack-relative addressing modes instead of "SP" and "RP". This matches WDC 65816 and 65EL02 documentation/recommendations, respectively.
  • Extensive tests have been added to test for addressing mode and modifier handling.

Note that this includes breaking changes for the following expressions:

  • "lda >addr" was previously interpreted as "lda mos16hi(addr)", but now will be interpreted as "lda mos24(addr)". This is unlikely to break production code.
  • "lda <addr8" was previously interpreted as "lda mos16lo(addr)", but now will be interpreted as "lda mos8(addr)". As the two relocations are functionally (but not semantically) equivalent, this should not break production code.
  • Likewise, functional (but not semantic) changes involve the relocations emitted by immediate expressions ("lda #val").

; CHECK: R_MOS_ADDR16 .text+0x1
lda !addr16 ; CHECK: ad 00 00
; CHECK: R_MOS_ADDR16 .text+0x202
; TODO: lda addr16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently lack a 16-bit equivalent to .zeropage. I've left these for a later PR.

lda #^addr24 ; CHECK: a9 00
; CHECK: R_MOS_ADDR24_BANK .text+0x30303

; TODO: Immediate (16-bit)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently lack a way to appropriately tell the assembler to force 16-bit immediates, without using mos16(). I've left these for a later PR.

@mysterymath mysterymath changed the title MOS: 65816 assembler fixes, part 2 [Breaking] MOS: 65816 assembler fixes, part 2 Mar 10, 2024
@mysterymath
Copy link
Member

After merging the previous change, it looks like this branch has conflicts now and needs to be synced.

- The immediate and address modifiers (#<, #>, #^, <, !, >) now adhere to
  WDC recommendations as documented in the 65816 datasheet.
  - In particular, this means the behaviour of "lda >addr" changes, while
    "lda !addr" and "lda #^addr" have been introduced.
- Immediate expressions now emit R_MOS_IMM8 and R_MOS_IMM16, while address
  expressions now emit R_MOS_ADDR8 and R_MOS_ADDR16 relocations.
- Some error messages have been adjusted to more accurately represent the
  assembler's limitations.
- Bugs in the SPC700's handling of "addr + X" and "addr + Y" addressing mode
  syntaxes have been fixed.
- Extensive tests have been added to test for addressing mode and modifier
  handling.

Note that this includes breaking changes for the following expressions:

- "lda >addr" was previously interpreted as "lda mos16hi(addr)", but now will
  be interpreted as "lda mos24(addr)". This is unlikely to break production
  code.
- "lda <addr8" was previously interpreted as "lda mos16lo(addr)", but now will
  be interpreted as "lda mos8(addr)". As the two relocations are functionally
  (but not semantically) equivalent, this should not break production code.
- Likewise, functional (but not semantic) changes involve the relocations
  emitted by immediate expressions ("lda #val").
This matches WDC 65816 and 65EL02 recommendations, respectively.
@asiekierka asiekierka force-pushed the upstream/pr/assembler-65816-2 branch from 8fe7435 to abb9201 Compare March 11, 2024 04:45
@asiekierka
Copy link
Contributor Author

Ah, sorry; should be fixed now.

@mysterymath mysterymath merged commit de93d8f into llvm-mos:main Mar 14, 2024
3 checks passed
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.

2 participants