What does the BEQ statement do?

I have the following assembly code snippet that I am trying to understand. This is the assembly for the MC68332 microcontroller.

LOOP some instructions some more instructions BEQ LOOP 

I have a googled BEQ, and I found that this means branching to zero result, but I still don't quite understand what it is doing. Does the result of the last command compare with 0, and if it is 0, does it return to the LOOP line?

+6
source share
2 answers

In the Motorola 68k family, this means "branch if it is equal to", which means "go to the given address if the zero flag is set" (for example, when the previous comparison was successful).

However, 68332 seems to be different from this and is based on "uppercase syntax", it could be a macro wrapper around another instruction that essentially does the same thing.

Assembly programmers who use code from other systems can use similar macros to facilitate the transfer process.

+4
source

The exact answer will depend on which microcontroller you are using. In the general case, if there are no operands, it is expected that BEQ will branch if the Battery is 0. This is most likely on simple microcircuits, where the Battery is the main register for calculations.

Which microcontroller are you using? You should find the definition of BEQ instruction in the manual for this micro.

+1
source

Source: https://habr.com/ru/post/907714/


All Articles