225 karma · joined May 1, 2026 (6mo ago) · 33 submissions
comment 5mo ago · link · parent
Good luck with your RISC-V asm stuff! Hit me up if you publish any of it :)
comment 5mo ago · link · parent
comment 5mo ago · link · parent
comment 5mo ago · link · parent
comment 5mo ago · link · parent
7.
Show HN: A pure ARM64 Assembly web server, now on Linux with CGI for no reason(github.com ↗)
51 points · by imtomt · 5mo ago · 26 comments
comment 6mo ago · link · parent
comment 6mo ago · link · parent
Thanks for the tips on CGI! Definitely going to look into it more. The server-side execution of CGI scripts definitely interests me more than the CGI scripts themselves, so I’ll probably just look for some existing (simple) CGI scripts and work on building the env vars and executing them.
comment 6mo ago · link · parent
comment 6mo ago · link · parent
comment 6mo ago · link · parent
comment 6mo ago · link · parent
comment 6mo ago · link · parent
In a comparison between a similar fork-per-connection server written in C and this, I would imagine the throughput would be about the same, because the bottleneck in this model is fork() itself rather than the actual code. It probably matters more for binary size and startup time than requests/sec. Would be fun to actually benchmark, though.
comment 6mo ago · link · parent
comment 6mo ago · link · parent
comment 6mo ago · link · parent
As for why it wouldn't run on Linux, there are some pretty big differences in the actual assembly. One pretty superficial difference is calling conventions -- MacOS uses the x16 register for syscall numbers, Linux uses x8. Calling the kernel in Mac uses "svc #0x80", in Linux it's "svc #0". That's ~120 lines that need to be replaced, but easy enough to just use sed. Syscall numbers are all different, as are the struct layouts for sigaction(), MacOS has an "sa_tramp" field that Linux doesn't have. Enforcing max processes is done here using the MacOS-specific proc_info() syscall, which can be used to get the number of children any given process has. Linux doesn't have an equivalent, so process tracking would need to be done differently. Finally, Linux has the getdents64() syscall, rather than getdirentries64(), which uses a different struct and is called differently.
I'm sure an LLM could make all those changes, but it's a pretty large codebase, so it would probably make some mistakes or miss things.
comment 6mo ago · link · parent
Higher level languages are more convenient for 99% of things, but the directness of Assembly gives me a rush unlike any other. I didn't live through the C64/Amiga, but I was obsessed with old C64/ZX emulators growing up.
comment 6mo ago · link · parent
Modularizing it into multiple files was easier than I expected it to be, you basically have other functions/labels in other files, and mark them as .global at the top. The Makefile compiles each file into their own .o, which you then link all together. You can "b" or "bl" to any label from any other file, as long as it's global and linked together. Same with data in .bss or .data, mark them as .global and they can be accessed from elsewhere.
comment 6mo ago · link · parent
comment 6mo ago · link · parent