Page 101 - ARM 64 Bit Assembly Language
P. 101

Data processing and other instructions 87

                     4.2.1.1 Syntax

                          <op>{s}       Rd, Rn, <Operand2>
                          <op2>{s}      Rd, Rn, Rm
                          neg{s}        Rd, <Operand2>
                          ngc{s}        Rd, Rm



                     •   <op> is one of add, sub.
                     •   <op2> is one of adc, sbc. The carry bit from PSTATE is added to the two operands.
                     •   neg and ngc are aliases of sub and sbc where Rn is ZR. Therefore, neither syntax uses
                         Rn.
                     •   The optional s specifies whether or not the instruction should affect the bits in PSTATE.


                     4.2.1.2 Operations

                       Name     Effect                               Description
                       add      Rd ← Rn + Operand2                   Add.
                       adc      Rd ← Rn + Rm + carry                 Add with carry.
                       sub      Rd ← Rn − Operand2                   Subtract.
                       sbc      Rd ← Rn − Rm + carry − 1             Subtract with carry.
                       neg      Rd ←−Operand2                        Negate.
                       ngc      Rd ←−Rn + carry − 1                  Negate with carry.



                     4.2.1.3 Examples

                    1         add    x0, x1, x2      // x0 = x1 + x2 and don’t set PSTATE
                    2
                    3         subs   x3, x3, #1      // x3 = x3 - 1 and set nzcv flags in PSTATE
                    4
                    5         neg    x4, x5, lsl #4  // x4 = -(x5 << 4)


                     Example 9. The following listings show a complete program for adding the contents of two
                     statically allocated variables and printing the result. The printf() function expects to find
                     the address of a string in x0, as it prints the string, it finds the %d formating command, which
                     indicates that the value of an integer variable should be printed. It expects the variable to be
                     stored in w1. Note that the variable sum does not need to be stored in memory. It is stored in
                     w1,where printf() expects to find it.
   96   97   98   99   100   101   102   103   104   105   106