Skip to main content
matthiasjunge9
Associate II
July 29, 2008
Question

INC /DEC

  • July 29, 2008
  • 2 replies
  • 712 views
Posted on July 29, 2008 at 11:24

INC /DEC

    This topic has been closed for replies.

    2 replies

    matthiasjunge9
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:40

    an expression like

    unsigned int i;

    i--;

    is compiled as

    LDR

    SUBS

    STR

    is there any sort of INC / DEC command to do this in one instruction on the ARM like on other processors?

    matt

    disirio
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 12:40

    SUBS is equivalent to a decrement instruction. LDR and STR are only required if your variable resides in memory and it is not allocated into a register.

    So: yes, it has increment/decrement instructions but it is not capable to increment/decrement variables in memory (like most other RISCs, it is a load/store machine).

    regards,

    Giovanni

    ---

    ChibiOS/RT

    http://chibios.sourceforge.net