This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Could you explain BCC command to me?

Hi,

I find C code not executing in the desired way. Then I step in assembly code of Tiva-C M4F core. Below is the disassembly code:

$C$L5:   nop

0000033a:   280A     CMP             R0, #10

0000033c:   D3C9     BCC             $C$L5

here_label:

R0 is '0'. It is found that after BCC exec, the core  goes $C$L5, not goes to here_label.

In xPSR, 'C' is '0'. I want to know BCC in detail, but the found description online is ambiguous to me. Especially the last column comments on Arithmetic. Could you explain the disassembly code running when flag 'C'=0, it goes to $C$L5, not here_label?


Thanks,

BCSC=1Carry setArithmetic operation gave carry out
BCCC=1Carry clearArithmetic operation did not produce a carry
Parents
  • Normally, an assembly-programmer would not use BCC and BCS with CMP.

    This is because the carry flag operates in the oposite way on ARM than on most other architectures.

    The BCC and BCS still works the same way as on other architectures, but the CMP does not generate a carry when the first operand is less than the second operand for instance; instead it starts by setting the carry flag and uses it as a 32th bit on subtraction (and thus also CMP, because CMP is in fact a SUBS where the result is thrown away).

    CC means Carry Clear (C=0, borrow)

    CS means Carry Set (C=1, no borrow)

    See this great 4-part article by Jacob Bramley.

Reply
  • Normally, an assembly-programmer would not use BCC and BCS with CMP.

    This is because the carry flag operates in the oposite way on ARM than on most other architectures.

    The BCC and BCS still works the same way as on other architectures, but the CMP does not generate a carry when the first operand is less than the second operand for instance; instead it starts by setting the carry flag and uses it as a 32th bit on subtraction (and thus also CMP, because CMP is in fact a SUBS where the result is thrown away).

    CC means Carry Clear (C=0, borrow)

    CS means Carry Set (C=1, no borrow)

    See this great 4-part article by Jacob Bramley.

Children