How to install NASM and compile Assembly program in kali linux.


Here i am going to show you how you can install NASM compiler to compile your assembly program in kali linux or any other linux.

Step 1: Open terminal in your linux.
Step 2: To download and install linux write the command on your terminal
           


                              "apt-get install nasm"

Step 3: Open your text editor and write Hello World program and save it with  .asm file extension.

  section .text
global _start
  _start:
mov edx,len
mov ecx,msg
mov ebx,1
mov eax,4
int 0x80

mov eax,1
int 0x80

  section .data
  msg db 'hello World!' , 0xa
  len equ $ -msg
       
Step 4: To compile the program write "nasm -f elf64 hello.asm" .
            ->Here "hello.asm" is the file name so don't get confused.
            ->If your system is 32 bit then you should use "nasm -f elf32 hello.asm"
            ->If your system is 64 bit then you should use "nasm -f elf64 hello.asm"


Step 5: After you will compile your code you will get a object file as "hello.o".

Step 6: To execute the "hello.o" file write the command "ld hello.o -o hello".


After executing the "hello.o" file you will get one more executable file as "hello".

Step 7: To Run the file just type ./hello and press Enter you will get your output.



So here you successfully installed and compiled your Assembly program.

Comments

  1. Hi can you provide me this nasm code for my assignment please.

    Ask two scores from the user, specifically, the raw score as the first score and the total score as the second score. Store the digits in the EAX and EBX register, respectively, given the formula raw score divided by the total score times 50 and plus 50. Store the result in a memory location 'res' and finally display the result.

    ReplyDelete

Post a Comment

Popular posts from this blog

JAVA PROGRAM TO REVERSE THE ARRAY ELEMENT.

Java program to draw pattern of Indian Map