NHacker Next
login
▲Learn x86-64 assembly by writing a GUI from scratch (2023)gaultier.github.io
127 points by ibobev 4 days ago | 15 comments
Loading comments...
tomhow 4 hours ago [-]
Previously:

Learn x86-64 assembly by writing a GUI from scratch - https://news.ycombinator.com/item?id=36153237 - June 2023 (146 comments)

userbinator 6 hours ago [-]
This is more like "by communicating with the X server", which is not exactly the level of "from scratch" I was expecting, but then again, it's more involved than the equivalent in Win32 that's not much more than filling in some structures and invoking a few functions.
vidarh 2 hours ago [-]
It's not even that much more involved, just tedious. The serialization/deserialization of X requests and responses is fairly straight-forward (it could be more straightforward - it's not a very nice protocol, but it's also not difficult), as the article also shows, and it can be made more compact than that with a couple of helpers.

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).

signa11 6 hours ago [-]
seesh ! what would `from scratch` mean for you ? invent the whole universe ?
userbinator 6 hours ago [-]
I was expecting something closer to direct framebuffer writes, as is often done in the various write-an-OS articles that get posted here semi-regularly.
signa11 6 hours ago [-]
i on the other hand, just loved the article.

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.

chickenzzzzu 2 hours ago [-]
KMSDRM is soooo much more fun than X. Truly the way programs were meant to be.
jcranmer 6 hours ago [-]
This reminds me of the time I was a young, naïve idiot, and decided I would learn GTK by writing some basic app in GTK. In x86 (not x86-64) assembly. Like all of my other project ideas from that era, never went anywhere, and I horribly underappreciated just how complicated things were.

Kudos for actually getting somewhere in their attempt to do this, a further state than I ever managed.

iberator 4 hours ago [-]
I currently re-learn ASM by writing my own virtual machine with my own cpu architecture and instruction set. Its FUN :)

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.

mettamage 2 hours ago [-]
How so? I know some of both but not enough to know why C++ is that much more complex.
farhanhubble 6 hours ago [-]
I learned X86 ASM by sinking my teeth into the Intel 8085 manual, then lighting up LEDs on a hardware emulator and later on a 8085 simulator that me and my brother built.

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.

pjc50 2 hours ago [-]
Corresponding Windows article: https://bitcodersblog.wordpress.com/2017/05/10/win32-in-nasm...

(but yes, I also would have expected a bit more "from scratch". Is there an annotated disassembly of, say, AmigaOS around?)

DeathArrow 4 hours ago [-]
Using X11 isn't exactly from scratch.
actionfromafar 2 hours ago [-]
Perhaps unintuitively, the recipe for writing a GUI from scratch is almost exactly the same as making an apple pie from scratch, save some minor details at the very end.
thedumbname 2 hours ago [-]
XQuartz does not support high resolution displays, that is not what macOS users looking for.