= Branching in the 68HC11 =
Branching controls the flow of a program. It allows you to take different paths depending on what is going on with the engine.
Branches are often used to skip steps in a routine if they are deemed unnecessary for the conditions. For example, if the VATS enable bit is clear (VATS is disabled,) a branch command can be used to skip the VATS routine altogether. That would look something like this:
LA43C? : LDAA
L86B5? ; load option word
LA43F? : BITA #$08 ; test bit4 (vats enable)
'''LA441: BEQ LA467 ; branch to "VATS passed" if b4=0 (vats disabled) ...if not, then'''
'''LA443: BRCLR
L002F? ,#$08,LA44F ; branch to "VATS test"''' if b4 at
L002F? is clear ...if not, then
When a branch command is encountered, the processor will check for the required conditions of the branch. (i.e. BEQ will branch if the zero condition code flag is set) If these conditions are present, it will jump to the specified address. If the conditions are NOT present, it will continue with the next line of code.
--
AlexHarford - 30 Jun 2006
Topic revision: r1 - 30 Jun 2006 - 22:46:31 -
AlexHarford