Be free…. be yourself with Linux.

Programming Language – NASM (Assembly language in Linux)

At about 22 years ago, Assembly Language is my second language after BASICA. I used Borland Turbo Assembler and Microsoft Debug on that time. I think Debug one of the very powerful tools for hacking. I like hacking. With Assembly, you can order the machine to do anything you want and go directly to every ports in the machine.

I just figure out, is there any Assembly Language in Linux?

Because, usually Assembly Language use DOS Services. Meanwhile, there is no DOS in Linux.

I finally found a good application, named NASM (Net wide Assembler). It’s a Assembly Language compiler in Linux. I’m still new with NASM, so I just take the sample codes from http://leto.net/writing/nasm.php.

NASM doesn’t have a text editor, so you have to type your code using other text editor then save the file with .asm file extension.

There are few main differences to be considered when you use assembly language in Linux:

In DOS mostly you use interrupt int 21h, int 10h and int 16h. In Linux, everything is handled by kernel with int 80h.

Linux is a 32-bit protected mode operating system, so you have to use extended 32-bit registers, such as EAX, EBX, ECX and so on. In 16-bit register, you still use AX, BX,CX etc …. registers.

In 32-bit programming, you don’t have to think about segments at all because it runs in the flat memory model.

I think no body write DOS assembly anymore. Hey… it’s 16 bit.

How I can get Nasm?

NASM is listed in Ubuntu Repository, so just download it using apt.

taufanlubis@toshiba:~$ sudo apt-get install nasm

[sudo] password for taufanlubis:

Reading package lists… Done

Building dependency tree

Reading state information… Done

The following packages were automatically installed and are no longer required:

When I learn a new computer language, the first thing I want to know is, how to display a ‘Hello World!!!’. I don’t want to know about the structure, variables, codes etc. Just do a simple thing, type, compile and see it run. That’s it. Then you can go further. It’s the same when you teach a baby to speak. We don’t teach any grammar. We give samples.

So, here it is.

Step 1. Type the code

You can use, vim, vi, gedit etc. The extension must be .asm.

taufanlubis@toshiba:~$ sudo vim hello.asm

[sudo] password for taufanlubis:

section .data

hello: db ‘Hello world!’,10

helloLen: equ $-hello

section .text

global _start

_start:

mov eax,4

mov ebx,1

mov ecx,hello

mov edx,helloLen

int 80h

mov eax,1

mov ebx,0

int 80h

Press ‘Esc‘ button and type ‘:wq‘ to save the file.

Actually, I’m new myself in Assembly Programming in Linux. I took the codes above from the NASM website. I just wanna show you that we can do Assembly Programming in Linux. If you want to know deeper you can go

Like this:

Related

24 Responses

sounds interesting…..
I have knowledge in C and I am doing now .net programming, is it easy for me to learn assembly?? I am just a college fresh student and computer enthusiast, as you have said you can easily go with every port of the machine, and want to learn about that…
can you list some nice resources for assembly?

Assembly is a very difficult language programming that’s why it’s categorized as Low level language. If you are a technician who designed a hardware then it’s a recommended language. But if you are a programmer or a student, you can learn it as a reference.
In Linux, if you need to do port programming, you can use GAMBAS or gcc.
I suggest to use gambas, it’s easier.

Programming Assembly in Linux is different with in MS-DOS. In Linux you deal with a kernel meanwhile in DOS you deal with DOS services.
There few books and websites describe about Assembly programming in Linux. You can use Google by typing “NASM”.

i am a student..
i need to submit a game written in assembly language for my final project.. and the game is a PAIR/MATCHING GAME.. i don’t have any idea how to start.. anybody has an idea how to code this game??? HELP.. please