Learn X86-64 Assembly by Writing a GUI From Scratch (2023)
Key topics
The article 'Learn x86-64 assembly by writing a GUI from scratch' sparks discussion on the meaning of 'from scratch' and the practicality of using assembly for GUI development, with some commenters sharing their own experiences learning assembly and others pointing out the use of X11.
Snapshot generated from the HN discussion
Discussion Activity
Active discussionFirst comment
4d
Peak period
20
84-96h
Avg / period
6.8
Based on 27 loaded comments
Key moments
- 01Story posted
Sep 12, 2025 at 8:51 AM EDT
4 months ago
Step 01 - 02First comment
Sep 16, 2025 at 12:47 AM EDT
4d after posting
Step 02 - 03Peak activity
20 comments in 84-96h
Hottest window of the conversation
Step 03 - 04Latest activity
Sep 20, 2025 at 10:38 AM EDT
3 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
was a bit confused about the segfault stuff mentioned towards the beginning of the article. but got quite quickly disabused of that notion with gdb etc.
Most "from scratch" would be some sort of microcontroller - write directly to hardware, program registers directly. It's the best feeling when you know every single instructions on the CPU is under your control, there is no 20 million lines of kernel code that do something.
But the MCU needs special hardware (MCU itself, display, programmer) so it is not a good starting project. This brings us to good old MS-DOS. Sure, you need to call BIOS to set up graphics (mode 13h, "320x200x256 colors" is the best for beginners), but after that, you are talking directly to hardware.
The biggest pain in doing "raw" X is the async nature of the protocol - to write a robust X client you really want an event-loop driven approach that embraces that like XCB does, instead of trying to paper over it (like Xlib did).
Kudos for actually getting somewhere in their attempt to do this, a further state than I ever managed.
I never expected to write programs in pure machine code before, but here I am. Writing my own assembler now :)
Way easier than C++ LOL
I highly recommend it.
In my youth, kids learned assembly to crack games.
(but yes, I also would have expected a bit more "from scratch". Is there an annotated disassembly of, say, AmigaOS around?)
Learn x86-64 assembly by writing a GUI from scratch - https://news.ycombinator.com/item?id=36153237 - June 2023 (146 comments)
What certainly helped was that I had did some digital design and instruction set architecture, etc.
Later on, I did some real-world assembly programming for the PIC microcontrollers and some inlined assembly in C, which I did not find daunting at all because of my previous experience.
I guess the best prerequisite for this material is having done some low-level C, the kind where you know about text/data sections and being comfortable with calling conventions, the run time and the linking process.
- small, known size moves are stitched from a fixed number of mov instructions, sometimes overlapped. For example 21 bytes is qword (8 bytes) + xmmword (16 bytes), overlapped.
- char-copying loops like "a++ = b++ c times" with c not known at compile time are either realized as simple increase, compare, conditional jump, or, at higher optimization, a monster that has like 10 branches to use anything from xmmword to byte depending on the amount of data
- big, known size moves (> 256 bytes) just generate a call to memcpy