DEV Community

Cover image for How to Say "Hello World" in x86 Assembly

How to Say "Hello World" in x86 Assembly

Sk on February 27, 2025

Because why not? Software is fun. I know this sounds insane; assembly for fun—but trust me, you feel alive. I’m lucky to be at a point where ...
Collapse
 
pxlmastrxd profile image
Caleb (pxlmastr)
#include <iostream>

int main() {
    std::cout << "To be honest, I'd rather stick to something normal :D";
    return 0;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sfundomhlungu profile image
Sk

#include <stdio.h>

int main() {
    printf("I agree! but this is normal 😂 :D\n");
    return 0;
}

Enter fullscreen mode Exit fullscreen mode
Collapse
 
k0msenapati profile image
K Om Senapati
print("Weirdos")
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
pxlmastrxd profile image
Caleb (pxlmastr)
class Test
{
    public static void main(String[] args)
    {
        System.out.println("No, we are the same when we bond against java people");
    }
}
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
perisicnikola37 profile image
Nikola Perišić
print("Good post! 9.67 score on dev-to-rater.xyz")
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
sfundomhlungu profile image
Sk
import IO, only: [puts: 1]

puts("Uhmmm lol 😂😭") 
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
ezpieco profile image
Ezpie • Edited

let me join in

section .data
    msg db 'amateurs', 0

section .text
    global _start

_start:
    mov eax, 4
    mov ebx, 1
    mov ecx, msg
    mov edx, 8
    int 0x80

    mov eax, 1
    mov ebx, 0
    int 0x80
Enter fullscreen mode Exit fullscreen mode
Collapse
 
jankapunkt profile image
Jan Küster 🔥
01001000 01100101 01101100 01101100 
01101111 00101100 00100000 01110111 
01101111 01110010 01101100 01100100 
00100001
Enter fullscreen mode Exit fullscreen mode
Collapse
 
ezek-iel profile image
𝙴𝚣𝚎𝚔𝚒𝚎𝚕 • Edited

I'll just

gcc -s main.cpp
Enter fullscreen mode Exit fullscreen mode


`
that thanks.

Collapse
 
pxlmastrxd profile image
Caleb (pxlmastr)
#include <iostream>
int main() {
    std::cout << "YOO WE MADE THIS POST GO VIRAL";
    return 0;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
teminian profile image
Robert Teminian

Let me join. lol

Program HelloPascal;
begin
    writeln('Please don''t forget here''s Pascal.');
end.
Enter fullscreen mode Exit fullscreen mode
Collapse
 
schemetastic profile image
Schemetastic (Rodrigo)
console.log("I think I'll stay with the good 'ol JS haha, but cool post 😉")
Enter fullscreen mode Exit fullscreen mode
Collapse
 
eljayadobe profile image
Eljay-Adobe

This is fun!

Yet another assembly...

a_cr    = $0d       
bsout = $ffd2       

    .code

    ldx #0      
printnext:
    lda text,x  
    beq done    
    jsr bsout   
    inx     
    bne printnext   
done:
    rts     
    .rodata

text:
    .byte   "Hello World", a_cr, 0
Enter fullscreen mode Exit fullscreen mode
Collapse
 
chaymankala profile image
Chaitanya Mankala

Everyone who is commenting that they rather use high-level programming language for "Hello World", you should understand that even author is not recommending to use assembly in real life. We developed High Level languages to make our lives easier, everyone agrees on that. Its so sad that they cant appreciate assembly and not at all curious to understand how things work.

Future will be just like,
When someone writes a C program to print hello world, commentors like these will comment like "I would rather use chatGPT prompt, this is so stupid!"

Collapse
 
0xw3ston profile image
Youssef El Idrissi

this is quite a cool blog post,
so I began to learn Computer Architecture & Organization and I found the assembly section to be the most interesting (because it's practical, and you could see the theory about registers etc in action).
But honestly I didn't find a right motive to learn it and be proficient in it, I'm learning it only for the curiosity at the moment but yk I still didn't find the right purpose.
So I ask you, could it possibly be useful in something like say... Malware development ? because code could be obfuscated etc on a very low level.
What do you think?

Collapse
 
sfundomhlungu profile image
Sk

Honestly sticking with c/c++ is your best bet, and you can transition to embedded systems easy.

These are closest to the metal.

The only thing I could remember assembly being used a lot for is AAA games and critical systems, to squeeze as much performance as possible.

But c++ has taken the role.

But if you insist on using assembly, there's an actual niche:

1) Create dlls and so files for old systems and open source them or sell them, php servers consume dll's, for example grpc is a dll.

2) Learn pure wasm(WAT) and webgpu, that's how they achieve Deep learning in the browser with tensorflow.js, or a more general niche create physics/game engine for the web(I'll personally use that), you could bring near AAA games on the web.

Other than that c++ is fine.

on obfuscated, handwritten assembly is way more readable than the compiler generated one gcc/g++, so c++ would be better there too

Collapse
 
anmolbaranwal profile image
Anmol Baranwal

People having entire conversations through code in comments lol. 🤣

Between, awesome post. 🔥

Collapse
 
sfundomhlungu profile image
Sk

😂😂😭

Collapse
 
skhmt profile image
Mike 🐈‍⬛ • Edited
Collapse
 
sfundomhlungu profile image
Sk

😭😭😂 solved!!

Collapse
 
armando_ota profile image
Armando Ota

Noice ... Brings back memories of writing asm code for z-80 ;)

Collapse
 
benny00100 profile image
Benny Schuetz

Great to see assembly again. I used to code in assembly on the Amiga in the good old days.

Collapse
 
sfundomhlungu profile image
Sk

ahhh the old days 🏖️ I remember, I am lying I started this year 😂, I think I am a jr assembler? Loving it thou, so good to touch the metal

Collapse
 
benny00100 profile image
Benny Schuetz

Enjoy the ride. IMHO it will teach you a lot.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
nwobia_david_346af40996c4 profile image
Nwobia David

isn't msg_len = . - msg not supposed to be this: msg_len = msg - .

Take the address after "Hello, World!\n" and subtract the start address

Collapse
 
cc_f9f91ece754f4e626078c2 profile image
cc44599

1

Collapse
 
ravi-coding profile image
Ravindra Kumar

Good !

Some comments have been hidden by the post's author - find out more