Intel X86 32 bit programming Assembly Language.

Problem: Add two numbers 45 and 55 and display the content in Console/Terminal output.

Soloution:

To solve that problem we will load number 45 in eax register and number 55 in ebx register and add the two and store in eax. And print the content of register eax to standard output.

Here is the program addition.asm
https://gist.github.com/1589234

section .text
global main
extern printf
main:
   mov eax, 45
   mov ebx, 55
   add eax,ebx
   push eax
   push message
   call printf
   add esp, 8
   ret
message db “Value = %d”, 10, 0

To run this

$nasm -f elf addition.asm

$gcc -m32 -o addition addition.o

To run this code use

$./addition

Value=100

Thats All. Now your task is to substract a number from bigger number and one more multiply two numbers.

Advertisements