Regarding C program convert to disassembly

Hello,
I have written simple program for subtraction in keil by selecting the LPC2148 from NXP family. When i observe the disassembly window my subtraction c program convert to instruction SUB R2,R0,R1 which is not affecting the flags. If i want to convert disassembly in to SUBS R2,R0,R1 which thing i require to do. How compiler decide whether it has to use SUB or SUBS when it convert to disassembly?

Parents
  • You really should not care what instructions the compiler uses. That isn't part of the "contract" between you and the compiler.

    On the other hand, you can change the probability of the compiler doing things dependingo on your code constructs. If you have a statement:

    if ((b - a) < 0) { ... }
    


    Then the compiler can see a reason to care about the result being zero, above zero or below zero.

Reply
  • You really should not care what instructions the compiler uses. That isn't part of the "contract" between you and the compiler.

    On the other hand, you can change the probability of the compiler doing things dependingo on your code constructs. If you have a statement:

    if ((b - a) < 0) { ... }
    


    Then the compiler can see a reason to care about the result being zero, above zero or below zero.

Children
More questions in this forum