/*
 * File:        hello.s
 * Description: Adds two (long) integers and prints the result.
 */
        .arch   armv8-a

        .global main

        .text
        .align  2
main:
        stp     fp, lr, [sp,-16]!
        mov     fp, sp
        
        adr     x0, prompt              // Pass the prompt string
        bl      printf                  // Call printf

        adr     x0, infmt               // Pass the input format in x0
        adr     x1, x                   // Pass the address of x in x1
        adr     x2, y                   // Pass the address of y in x2
        bl      scanf                   // Call scanf

        adr     x0, outfmt              // Pass the output format in x0
        adr     x1, x                   // Pass the contents of x in x1
        ldr     x1, [x1]
        adr     x2, y                   // Pass the contents of y in x2
        ldr     x2, [x2]
        add     x3, x1, x2              // Add, putting the result in x3
        
        bl      printf                  // Call printf
        
        mov     x0, #0
        ldp     fp, lr, [sp], 16
        ret
        
        .data                           // Start of data segment
        .align  3                       // Align on an address divisible by 8

x:      .quad   0                       // The first integer
y:      .quad   0                       // The second integer

        .section .rodata

prompt:   .string "Enter two integers: "
infmt:    .string "%ld %ld"
outfmt:   .string "%ld + %ld = %ld\n"
