hey, maddie! logo

hello, universe ✨

welcome to my new blog. i hope you are well!

there’s not much here to see yet, but that will soon change. 🤞🏻

in this blog i plan to write about: mental health, tech, game dev, video game music composing, reverse engineering (mostly games), 3d and pixel art, accessibility, and the state of computing technology (mostly OS, software, UI, and UX focused) as a whole of which i care about a lot. i will share many stories, and perhaps other random thoughts or things i have been working on.

i’m writing for me, which means things might get a little chaotic here, so if you end up following, which you can with this RSS/Atom feed, i hope you enjoy this wild ride with me! and as a reminder i claim to be no expert, and i will always be learning, as much as you are.

for now, i’ll leave you with hello universe written in x86-64 assembly for UNIX based operating systems!

; universe.s
global _start

section .text

; every executable has something like a `_start`! this is just like the function `main`.

_start:
; this is basically a syscall to write the string to `STDOUT`
; equivalent to say, `printf`, `cout`, `puts`, `console.log`, etc.
; you can check all of them out here! https://blog.rchapman.org/posts/Linux_System_Call_Table_for_x86_64/
; note that the x86_64 bit syscalls are different from the x86 (32-bit) ones.
; macOS uses FreeBSD derived syscalls, which are also quite different.
; see https://opensource.apple.com/source/xnu/xnu-1504.3.12/bsd/kern/syscalls.master

mov rax, 1 ; write
; for macOS: mov rax, 0x2000004

mov rdi, 1 ; STDOUT
lea rsi, [rel str] ; you may see this written as mov rsi, str in other examples
; lea, with rel, will load this as a relative address reference
; which is necessary by default for macOS (vs a 32-bit absolute address).
mov rdx, len
syscall

; this exit syscall works like `return 0;` i.e., exiting with an error code.
mov rax, 60 ; exit
; for macOS: mov rax, 0x2000001

xor rdi, rdi ; error code 0
syscall

section .rodata
; string data needs to be stored here, and can be referred to by its label
; (essentially a pointer) `str`, defined here.
str: db "hello, universe ✨", 10
len: equ $ - str

to build and run this, you’ll need nasm. you can install this following the instructions under 1.3.2 Installing NASM under Unix here. for Windows you’ll need to do this in WSL. you can also use a package manager like brew or apt-get.

once nasm is installed, you can run the below to build and run!

# linux uses elf64 binaries
nasm -f elf64 -o universe.o universe.s
ld -o universe universe.o
chmod +x universe
./universe

> hello, universe ✨

for macOS, this is slightly different

# macOS uses the macho64 executable format
nasm -f macho64 universe.s

# macOS needs a number of references to get the linker to work.
ld -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -macosx_version_min 10.13.0 -lSystem -o universe universe.o

chmod +x universe
./universe

> hello, universe ✨