Romhacking.net

Romhacking => Programming => Topic started by: Dr. Floppy on February 13, 2015, 09:10:25 am

Title: BNE/BEQ --> BZC/BZS
Post by: Dr. Floppy on February 13, 2015, 09:10:25 am
It occurred to me the other day that the Branch on iNEquality & Branch on EQuality commands are more accurately described as Branch on Z-flag Clear & Branch on Z-flag Set (respectively). Anybody know why Peddle/Mensch went with the BNE/BEQ terminology instead of the conceptually-clearer (and cooler looking) BZC/BZS?
Title: Re: BNE/BEQ --> BZC/BZS
Post by: Gideon Zhi on February 13, 2015, 12:58:19 pm
If I had to hazard a guess, it'd be that the most common use-case goes something like this:

CMP #$F0
BEQ

How does "Branch if zero clear" make this easier to understand?
Title: Re: BNE/BEQ --> BZC/BZS
Post by: FAST6191 on February 14, 2015, 01:40:53 pm
Do we have an official/common old assembler listing? Such things are usually the reason for it. I doubt anybody will change it either as it can be a dangerous move to simply change the instruction ordering (instruction, source, destination -> instruction, destination, source sort of thing).

Or if you prefer when was the last time you encountered an instruction set where mov actually moved something rather than copied it.
Title: Re: BNE/BEQ --> BZC/BZS
Post by: Dr. Floppy on February 14, 2015, 04:58:21 pm
I suspect that's what was involved with all the Transfer commands (which are more accurately dubbed "Copy" commands).

As for BEQ/BNE, Gideon's probably right. I just got so used to viewing all CMP's as theoretical subtractions and mentally appending "...to zero" to any subsequent BEQ/BNE. This resulted in much confusion a few weeks back when a BNE command was being skipped despite A, X, and Y all containing non-zero values. (Turns out I'd inserted a JMP patch to a special-handling routine elsewhere, the final portion of which was "CMP #26" with just enough space remaining for the JMP-back. The original routine, not having that special handler, used that BNE as a specific test for the contents of A-reg.)