Get the latest tech news

Learn x86-64 assembly by writing a GUI from scratch (2023)


Published on 2023-05-31 Discussions: Hacker News, r/programming, Lobsters. Most people think assembly is only to be used to write toy programs for learning purposes, or to write a highly optimized version of a specific function inside a codebase written in a high-level language.

The flag-g is telling nasm to produce debugging information which is immensely useful when writing raw assembly, since firing the debugger is often our only recourse in face of a bug. We put the string in the.rodata section (same as the data section but read-only) We load its address in rsi(it's the source) We load the address of the string in the structure on the stack in rdi(it's the destination) We set rcx to the number of bytes to be copied We use cld to clear the DF flag to ensure the copy is done forwards (since it can also be done backwards) We call rep movsb and voila The server sends a big message with a lot of general information, which we will need for later, so we store certain fields in global variables located in the data section.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Scratch

Scratch

Photo of assembly

assembly

Photo of GUI

GUI

Related news:

News photo

Self-Assembly Gets Automated in Reverse of 'Game of Life'

News photo

RustGPT: A pure-Rust transformer LLM built from scratch

News photo

Writing an operating system kernel from scratch – RISC-V/OpenSBI/Zig