Page 111 - ARM 64 Bit Assembly Language
P. 111

Data processing and other instructions 97


                   37         bl     scanf
                   38         adr    x1, dataIn
                   39         ldr    x20, [x1]       // y
                   40
                   41         // longMul(x, y)
                   42         mov    x0, x19
                   43         mov    x1, x20
                   44         bl     longMul
                   45
                   46         // printf("%18lx * %18lx = %18lx%18lx\n", x, y, hi, lo)
                   47         mov    x4, x0          // lo
                   48         mov    x3, x1          // hi
                   49         mov    x2, x20         // y
                   50         mov    x1, x19         // x
                   51         adr    x0, fmtResult
                   52         bl     printf
                   53
                   54         // return 0
                   55         mov    w0, #0
                   56         ldp    x19, x20, [sp, #16]    // Callee-saved
                   57         ldp    x29, x30, [sp], #32
                   58         ret
                   59         .size  main, (. - main)
                   60
                   61         .data
                   62  dataIn:
                   63         .skip 8
                   64
                   65         .section .rodata
                   66  prompt:
                   67         .string "Enter a number in hex: "
                   68  fmtScan:
                   69         .string "%lx"
                   70  fmtResult:
                   71         .string "%016lx * %016lx = %016lx%016lx\n"



                     4.2.8 Division operations

                     There are only two division instructions in AArch64:
                     sdiv    Signed divide and
                     udiv    Unsigned divide.

                     4.2.8.1 Syntax

                          <op>      Rd, Rm, Rn
   106   107   108   109   110   111   112   113   114   115   116