Top
Best
New

Posted by imtomt 12 hours ago

Show HN: Building a web server in assembly to give my life (a lack of) meaning(github.com)
This is ymawky, a static file web server for MacOS written entirely in ARM64 assembly. It supports GET, PUT, DELETE, HEAD, and OPTIONS requests, and supports Range: bytes=X-Y headers (which allows scrubbing for video streaming). It decodes percent-encoded URLs, strictly enforces docroot, serves custom error pages for any HTTP error response, supports directory listing, and has (some) mitigations against slowloris-like attacks.

I’ve also written a more detailed writeup here: https://imtomt.github.io/ymawky/

336 points | 169 commentspage 5
feiz45607 10 hours ago|
[flagged]
paolatauru 8 hours ago||
[dead]
Ami985 9 hours ago||
[dead]
feiz45607 10 hours ago||
[flagged]
ankur-ag 8 hours ago||
[dead]
OutOfHere 11 hours ago||
An agentic LLM should be pretty good at Arm64 assembly generation, but maintainability of large code could become an issue. Why would it not run on Linux?
imtomt 11 hours ago||
I wrote it for MacOS because I don't have a Linux machine right now :( Once I get one up and running again, I'll probably work on porting this.

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.

OutOfHere 44 minutes ago|||
Is it not possible to maintain a single codebase for both OS with appropriate .ifdef commands?
tgv 9 hours ago|||
You could always start in a virtual environment.
shepherdjerred 11 hours ago||
The first paragraph of the README says this was hand written so I’m not sure why you’re bringing up LLMs
OutOfHere 7 hours ago||
Because it's absurd for most people to write too much Assembly by hand.
verandaguy 2 hours ago||
What if the author wants to learn? Is learning just out of style now?

I'd be doing the same kind of thing if I had more free time.

OutOfHere 52 minutes ago||
So go learn, and stop harassing others who are okay with using an LLM for some tasks.
maomaoati985 9 hours ago|
Your determination to make this happen was remarkable — and you truly accomplished it. Congratulations