DEV Community

Cover image for "Hello, world" in Assembly
Bek Brace
Bek Brace

Posted on

"Hello, world" in Assembly

You should learn Assembly language - and I'm going to tell you why πŸ˜‰ ..!

Not to be a great Assembly programmer, but at least to understand how it functions.

In my opinion, I think learning how to code in Assembly is to appreciate all what C language offers you; and if you want to learn C in order to appreciate all the great things that Python gives you, that's also a great move.

So Assembly, C and Python are three main languages you need to know if you want to understand how code is working and how things look like underneath the hood, I even would say Assembly and C, then you're free to choose whatever language you want for backend programming; but the reaosn why I mentioned Python is that Python is written in C, the most famous Python interpreter is Cpython.
C itself is written in C, but you can think that the first C was coded in Assembly.
So Python is written in C, C is written in Assembly and Assembly is the human readable form for machine language which is a bunch of 0s and 1s

You will need to run on an IBM compatible PC...

(hmm.. wait a minute, I think this term is deprecated , but you can call me a Nerd πŸ€“ )

...with an x86_64 processor that is a 64 bit of virtual memory address, and also we will need to have a copy of a Linux kernel.

To check out the type of your processor, just type in your terminal

~$ arch
OR
~$ uname -m

We will need also to install the NASM assembler program which is the Netwide Assembler for the Intel X86 architecture,
An assembler works as a compiler but for assembly,
go ahead and install that :

sudo apt-get install nasm


There are many assemblers like
Microsoft Assembler (MASM)
The GNU assembler (GAS)

An assembly program can be divided into three sections βˆ’
The text section.
The data section,
The bss section

1) The text section is used for keeping the actual code.
This section must begin with the declaration global _start, which tells the kernel where the program execution begins, and global keyword followed by _start is essential for the linker, later when we will run our program.

2) The data section is used for declaring data or constants.
This data does not change at runtime.
You can declare various constant values, file names, or buffer size, etc., in this section.
You can think of this as the keyword const in JavaScript for constants declaration

3) The bss section is used for declaring variables
You can think of this as the word let in JavaScript for variables declaration

You can watch the video to see how you can write a "Hello, World" simple program to print Hello, World on the screen .. in Assembly, it's not that simple πŸ€“

Thanks for readin - and watching maybe πŸ€” - leave your comment and contact me on info@bekbrace.com , or follow me on Facebook, Twitter and Instagram : @bekbrace

Signin' out,
Bek

Top comments (0)