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

Program Counter Relative Addressing? #1

Closed
ceharris opened this issue Jul 28, 2024 · 3 comments
Closed

Program Counter Relative Addressing? #1

ceharris opened this issue Jul 28, 2024 · 3 comments

Comments

@ceharris
Copy link

I'm trying to use program counter relative addressing and getting an unexpected assembler error.

hello.asm:

        org $ff00

        ; this instruction should produce 30 8D 00 00
        ; but instead causes an error
        leax message,pcr

message:
        fcc 'Hello, world.'
        fcb $0d
        fcb $0a
        fcb 0
$ 6809 -r -d -b hello.asm
INFO: Assembling hello.asm
Pre-processing...
line 6 register missing after offset
Error: cpu::Error: line 6 register missing after offset
gorsat added a commit that referenced this issue Jul 29, 2024
@gorsat
Copy link
Owner

gorsat commented Jul 29, 2024

Great catch! Thanks for finding this. I hadn't implemented PC-based indexing at all in the assembler. Strange that I never ran into it after all the code I assembled. I think I've adopted the standard syntax for this but please let me know if not.

; for PC-relative addressing
   LEAX target,PCR
; for regular old indexed addressing using the program counter
   LDX offset,PC

...and it turns out I also had a bug in the emulator side as well where I wasn't properly adding the instruction size to the offset in the case of a 16-bit PCR offset.

One thing to note, though. You said you expected leax message,pcr to become 30 8d 00 00 but my code outputs 30 8c 00 because the offset fits into 8 bits.

You can try test/issue1.asm to see what it's doing:
cargo run -- -v -l -r --acia-disable test/issue1.asm

I see there are a ton of warnings now using the latest toolchain so I'll clean it up tomorrow.

@ceharris
Copy link
Author

One thing to note, though. You said you expected leax message,pcr to become 30 8d 00 00 but my code outputs 30 8c 00 because the offset fits into 8 bits.

Of course -- makes sense.

Thanks for the quick turnaround! I'll give it whirl later today...

And thanks for putting this emulator together. Super helpful to have an emulator for testing and debugging before writing to EEPROM for my 6809-based retro-computing project. 😄

@ceharris
Copy link
Author

Just to follow-up... PCR is working now as expected.

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