You are on page 1of 1

adding two integers and stores the results in a register using ×86 assembly language with the

assembler NASM

my_program_add.asm

section. Data
num1 dd 5 num2 dd 3 section. text global _start _start: ; Load values into integers mov eax, [num1]
mov ebx, [num2] ; Add the values add eax, ebx ; Exit the program mov eax, 1 int 0×80
Enter

Sections: .data: This section defines data variables. In this case, it defines two double-word (4 byte)
integers named num1 and num2 initialized with values 5 and 3, respectively. .text: This section
contains the program instructions. Code: global _start: This directive declares the symbol _start
as globally visible, indicating it's the program's entry point. _start: This label marks the beginning
of the executable code. mov eax, [num1]: This instruction loads the value of num1 (which is 5) from
memory into the EAX register. mov ebx, [num2]: This instruction loads the value of num2 (which is
3) from memory into the EBX register. add eax, ebx: This instruction adds the content of EBX (3)
to the content of EAX (5), and the result ( is stored back in EAX. mov eax, 1: This instruction
replaces the value in EAX with 1. While this step doesn't directly contribute to the addition, it's likely
used for program termination purposes in the following instruction. int 0x80: This instruction
triggers an interrupt (system call) with code 0x80, which typically signifies program termination.

You might also like