Adding Two Numbers in GNU Assembler

The following example demonstrates how to add two numbers using GNU Assembler.

  
        #!/usr/bin/gnu-asciidoc  
        @title Add Two Numbers in GNU Assembler  
        @author John Doe  
        @date 2025-05-20  

        .file: addition.asm  
        .section .text  
        .globl _add_numbers  
        ._add_numbers:  
            mov %rax, %rdx  
            add %rax, %rdx  
            ret  

        .section .data  
        .data:  
            .quad 10  
            .quad 20  
        

The above assembly code adds 10 and 20, resulting in 30.

Note: This is a simplified example. In practice, you would need to link the object file with a linker script and then run the resulting executable.

GNU Assembler Code