GNU Assembler - Adding Two Numbers

This is a simple example of adding two numbers using GNU Assembly Language (NASM).

Objective: To demonstrate how to add two numbers using assembly language.

  
; Simple Assembly Program to Add Two Numbers  
section .data  
    num1 DWORD 10  
    num2 DWORD 20  
    result DWORD ?  

section .text  
    mov eax, num1  
    mov ebx, num2  
    add eax, ebx  
    mov result, eax  
    mov eax, 0  
    ret  
            

The program loads two values into registers, adds them, and stores the result in memory.

Note: You need to link this with an assembler such as NASM before running it.