In this context, ``set'' means a value of 1, ``cleared'' means a value of 0. ``Skip'' requires a little more explanation.
Normally, instruction executes one after another consecutively. See our sample program in the previous section. However, sbic and sbis allows the processor to skip or jump over one instruction depending on the state of a bit of an I/O location.
Consider the following program snippet (a portion of a program):
sbic PINA,3 blah yada
Of course, blah and yada are not real instructions. Nonetheless, the focus is on sbic. If bit 3 of I/O location PINA is cleared, the program skips the next instruction and jumps straight to continue execution at yada. However, if bit 3 of I/O location PINA is set, the program does not skip and executes blah instead.
The next question is: do we have to execute yada after executing blah? Afterall, if this were the case, sbic would not have been a useful instruction.
Let us introduce another instruction, rjmp. rjmp means
``relative jump'', but we can ignore the ``relative'' part for now.
rjmp requires just one piece of information: where to jump to.
The location to jump to (to continue execution at) is often specified as
a label. For example, rjmp there means continue execution at a
label called there.
In order to define a label called there, we need one line in the program that looks like this:
there:
Whenever you put a colon after a symbol, it defines the symbol to be a label that marks a location.
Now, let us consider the following snippet:
again: sbic PINA,3 rjmp there cbi PORTA,0 rjmp thereafter there: sbi PORTA,0 thereafter: rjmp again
What does this snippet do? You can assume pin 3 of port A was previously configured as input, and pin 0 of port A was previously configured as output.
Figure 1 illustrates how instructions are executed when bit 3 of PINA is cleared, where as figure 2 illustrates how instructions are executed when bit 3 of PINA is set.