I'll try and get this building for OSX.<p>For the uninitiated, might I recommend my: <a href="http://nickdesaulniers.github.io/blog/2014/04/18/lets-write-some-x86-64/" rel="nofollow">http://nickdesaulniers.github.io/blog/2014/04/18/lets-write-...</a><p>Though, this is written in yasm syntax, which is slightly different.<p>Also, keep an eye out for a blog post on Interpreters, Compilers, and JITs I'm working on (cleaning it up and getting it peer reviewed this or next week)!<p><i></i>update 1<i></i>
Actually, would the syscall's be different between Linux and OSX? Let's find out, once this builds! <i>hammers away</i><p><i></i>update 2<i></i>
Got it building and linking. bus error when run, debugging with gdb.<p><i></i>update3<i></i>
Can't generate dwarf2 debug symbols for OSX?
$ yasm -g dwarf2<p><i></i>update 4<i></i>
Careful, this tries to listen on port 80 [0] (0x5000 (LE) == 5*16^1 == 80), I would never run any assembly program off the web with elevated privileges. I recommend 0xB8B0 (LE, port 3000).<p>update 5<p>> Actually, would the syscall's be different between Linux and OSX?<p>Looks like yes: <a href="http://unix.stackexchange.com/a/3350" rel="nofollow">http://unix.stackexchange.com/a/3350</a>
These might be close to shim out (OSX and Linux at least share a calling convention, unlink Windows). I'll upstream what I have.<p>[0] <a href="https://github.com/nemasu/asmttpd/blob/master/main.asm#L24" rel="nofollow">https://github.com/nemasu/asmttpd/blob/master/main.asm#L24</a>
It's been closer to 20 years since I last read a complete program in x86 assembly, so this is quite fun to look at.<p>I'm somehow disappointed (quite unreasonably, of course) that the code uses plain old zero-terminated C strings instead of something more exotic. One of the fun things about assembly is that you get to reinvent basic language features on the fly -- calling conventions, data layout, strings, everything.
I wrote httpdito, a web server for Linux in 386 assembly, a couple of years ago (mostly outdated discussion is at <a href="https://news.ycombinator.com/item?id=6908064;" rel="nofollow">https://news.ycombinator.com/item?id=6908064;</a> a README is at <a href="http://canonical.org/~kragen/sw/dev3/httpdito-readme" rel="nofollow">http://canonical.org/~kragen/sw/dev3/httpdito-readme</a>) and I was happy to get the executable under 2000 bytes. I actually used it the other day to test a SPA, although for some things its built-in set of MIME-types leaves something to be desired.<p>But it doesn't have default documents, different kinds of error responses, TCP_CORK, sendfile() usage, content-range handling, or even request logging. So asmttpd is <i>way</i> more full-featured than httpdito, and it's still under 6K.<p>(...httpdito possibly doesn't have any bugs, either, though ☺)
Days ago I saw a lightweight httpd written in C here, yesterday a C++ header-only httpd library caught my mind, and now an httpd in assembly. I'm curious what would come next...
Shameless plug for a companion IRC bot in ARM assembly: <a href="https://github.com/wyc/armbot" rel="nofollow">https://github.com/wyc/armbot</a>
A little strange to see: "Sendfile can hang if GET is cancelled." in the readme and no corresponding issue. Not even one closed as "wontfix". Sounds like DOS?
No dependencies at all, runs on Docker 'FROM scratch', Nice! - <a href="https://registry.hub.docker.com/u/0xff/asmttpd/" rel="nofollow">https://registry.hub.docker.com/u/0xff/asmttpd/</a>