M6809-Docs / m6809pm

MC6809-MC6809E 8-Bit Microprocessor Programming Manual [M6809PM/AD]
3 stars 0 forks source link

The descriptions for BGT is confusing and wrong #4

Closed cmarrin closed 1 month ago

cmarrin commented 6 months ago

In appendix A the descriptions of the branch condition for BGT is:

IFF Z ∧ [N ⊕ V] = 0 then PC' ← PC + TEMP

This is confusing. Is it saying (Z ∧ [N ⊕ V]) = 0 or Z ∧ ([N ⊕ V] = 0)? Either way it gives the wrong results. If all CC flags are zero it means that in the last test the result was neither zero nor negative, so the number is positive and it should take the branch. But both ways fails in this case.

This branch is the converse of BLE, which has the condition:

IFF Z ∨ [ N ⊕ V ] = 1 then PC' ← PC + TEMP

So it should be the same formula but where the result equals 0 rather than 1. So the right formula for BGT would be:

 IFF Z ∨ [N ⊕ V] = 0 then PC' ← PC + TEMP

which implies parens around everything but the ' = 0'. But I think it would be more clear to add parens to both the BGT and BLE cases.

maddes-b commented 6 months ago

Motorola tried to negate the formula from the description for an easier version, but then forgot to negate AND to OR.

The description is: ( NOT( Z ) and NOT( N xor V) ) = 1 Translated to a negated more readable formula: ( Z or ( N xor V ) ) = 0

So the errata is: IFF [ Z ∨ [N ⊕ V] ] = 0 then PC' ← PC + TEMP

P.S.: A-15 = page 63 in the PDF

maddes-b commented 6 months ago

Btw BLE is missing outer parenthesis too. And usage of parenthesis differs for BLS.

What shall we go for?

Those changes would fit in the related pull request.

cmarrin commented 6 months ago

Yes I saw that too. But at least it has the right operators. I finally got my emulator working well enough for it to pass all the tests in test09.asm, a little test program I found somewhere (and I need to add to the list of things I’ve gotten from around the web). ~ChrisOn May 10, 2024, at 3:40 AM, Maddes @.***> wrote: Btw BLE is missing outer parenthesis too. And usage of parenthesis differs, see BLS.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

cmarrin commented 6 months ago

I'm fine with either parentheses. Do you want to open the issue?