I have the following assembly code snippet I am trying to understand. It is assembly for a MC68332 microcontroller.
LOOP
some instructions
some more instructions
BEQ LOOP
I've googled BEQ and I have found it means branch on result zero, but I still don't really understand what it does. Does it compare the result of the last instruction to 0, and if it is 0, it goes back to the LOOP line?
On Motorola 68k family, it stands for "branch if equal" which means "jump to given address if zero flag is set" such as when previous comparison is successful.
However, 68332 seems to be different. Based on uppercase syntax, it could be a macro around another instruction which essentially does the same thing.
Assembly programmers who port code from other systems can make use of similar macros to ease the porting process.
The exact answer will depend on which microcontroller you are using. In general, if there are no operands, BEQ would be expected to branch if the Accumulator is 0. This is most likely on simple micros where the Accumulator is the primary register for calculations.
Which microcontroller are you using? You should be able to find a definition for the BEQ instruction in the manual for that micro.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With