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

TickCount mistake in Indexed addressing calc? #84

Open
ecurtz opened this issue May 6, 2021 · 5 comments
Open

TickCount mistake in Indexed addressing calc? #84

ecurtz opened this issue May 6, 2021 · 5 comments
Assignees

Comments

@ecurtz
Copy link

ecurtz commented May 6, 2021

You'll have to double check this, but I believe there's an error in the cycle count for index address mode 0x0F. TickCount is increased by 5, which is the correct total, but this case is only available as indirect which will add another 3 cycles.

This is around line 595 of cpu6809.js:

        case 0x0F: // EA = ADDRESS
          EA = this.fetch16();
          this.tickCount += 5;
          break;
        default: {
          const mode = postByte & ADDRESSINGMODE_FIELD;
          throw new Error('INVALID_ADDRESS_MODE_' + mode);
        }
      }

      EA &= 0xFFFF;
      if (postByte & INDIRECT_FIELD) {
        /* TODO: Indirect "Increment/Decrement by 1" is not valid
        const adrmode = postByte & ADDRESSINGMODE_FIELD
        if (adrmode === 0 || adrmode === 2) {
          throw new Error('INVALID_INDIRECT_ADDRESSMODE_', adrmode);
        }
        */
        // INDIRECT addressing
        EA = this.ReadWord(EA);
        this.tickCount += 3;
      }
@neophob neophob self-assigned this May 10, 2021
@neophob
Copy link
Owner

neophob commented May 11, 2021

Thenks @ecurtz .. I quickly checked http://gtoal.com/SBTPROJECT/6809sbt/reference-emulators/larry-bank/6809.C - there also 5 and 3 cycles are used for this call...

also mame looks like they use 5 or 8 cycles ( case 0xff: IMMWORD(ea); EAD=RM16(EAD); m6809_ICount-=8; break;).

But I'm not that knee deep into the cpu6809 at the moment so this make's me wonder how did you find out?

@ecurtz
Copy link
Author

ecurtz commented May 11, 2021

I was looking into doing a version that works with the real 6809 quad clock timing rather than abstract cycle counts so I was going through the instructions and that one didn't seem to match. This chart is from the data sheet, I believe bottom right is the op in question. https://drive.google.com/file/d/1GmlqhsqqrwYNgE2mRUsZC9HS0Hply8xc/view?usp=sharing

@neophob
Copy link
Owner

neophob commented May 12, 2021

thanks, this looks interesting.. do you have time for a pr? this would be fantastic!

@ecurtz
Copy link
Author

ecurtz commented May 12, 2021

I have a PCB on order that should let me test it on a real 6809 and I'll report back whenever that arrives. It would just be changing a single number, so not much of a PR, but I'll be happy to do so if it turns out the current one is wrong.

@neophob
Copy link
Owner

neophob commented May 12, 2021

would be fantastic, thanks! I do have some in depth tests that run and where we can see what the actual difference is (like https://github.com/neophob/wpc-emu-dumps)

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