TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Asmttpd: Web server for Linux written in amd64 assembly (2017)

166 pointsby jxubalmost 7 years ago

13 comments

tptacekalmost 7 years ago
Isn&#x27;t this basically a web server for Linux written in C, except with absolutely no standard library optimizations?<p>Yes, it&#x27;s assembly, but it&#x27;s basically a thin script over a set of string library functions which are themselves just naive versions of what&#x27;s already in libc. Most of this is just strcpy&#x2F;strcat&#x2F;strchr&#x2F;strstr; the only reason it&#x27;s not one giant stack overflow is that it doesn&#x27;t actually implement most of HTTP (for instance: nothing reads Content-length, and everything works off a static buffer that is sized to be as large as the maximum request it will read). What&#x27;s the point of writing assembly if you&#x27;re going to repeatedly scan to the end of strings as you try to build them?<p>I&#x27;m not taking away anything from the project as an exercise. It&#x27;s neat! But like: it&#x27;s not something you&#x27;d ever want to use, or a productive path to go down to make a good webserver.
评论 #17528650 未加载
评论 #17528321 未加载
mabynogyalmost 7 years ago
Nobody mentioned rwasa so I do it (an HTTPs webserver written in asm):<p><a href="https:&#x2F;&#x2F;2ton.com.au&#x2F;rwasa&#x2F;" rel="nofollow">https:&#x2F;&#x2F;2ton.com.au&#x2F;rwasa&#x2F;</a><p>I proposed to debian (on an IRC channel for that) to make a package for rwasa but I&#x27;ve been told that &quot;nobody does asm in 2017&quot;. I wonder if it&#x27;s still true in 2018.
评论 #17528070 未加载
评论 #17527572 未加载
bumholioalmost 7 years ago
Sounds like an excelent front end, for best performance. For the back end stability is paramount, that&#x27;s why I would always recommend to pair this with a shell script server: <a href="https:&#x2F;&#x2F;github.com&#x2F;avleen&#x2F;bashttpd" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;avleen&#x2F;bashttpd</a><p>Bash is undeniably the language with the highest possible stability, you can literally feel the stability and security when a file is served and the hard drives go crazy.
评论 #17527856 未加载
saagarjhaalmost 7 years ago
<p><pre><code> %macro stackpush 0 push rdi push rsi push rdx push r10 push r8 push r9 push rbx push rcx %endmacro %macro stackpop 0 pop rcx pop rbx pop r9 pop r8 pop r10 pop rdx pop rsi pop rdi %endmacro </code></pre> I guess that&#x27;s one way of saving registers. Not particularly efficient, I guess, but it works…
评论 #17528566 未加载
评论 #17526354 未加载
sctbalmost 7 years ago
A couple of past threads:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9571827" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9571827</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7170010" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7170010</a>
inambercladalmost 7 years ago
This is some of the best written assembly I&#x27;ve seen. I can actually follow what&#x27;s going on.
k1nsalmost 7 years ago
This is really cool. I admire your bravery.<p>I noticed that certain options are hardcoded (such as the port number). As someone with very little experience in assembly, how difficult would it be to make this dynamic via environment variables?
评论 #17526527 未加载
评论 #17526472 未加载
评论 #17526221 未加载
评论 #17526106 未加载
laurent123456almost 7 years ago
That&#x27;s impressive, but I couldn&#x27;t find the reason for it. Was it done just for the challenge, or can their be a use for this kind of server?
评论 #17534563 未加载
评论 #17526246 未加载
ebikelawalmost 7 years ago
Looking at the code I’d be surprised if this is anywhere near as fast as a simple equivalent written in C++ (which wouldn’t be as pessimistic with the register saving, in an opt build) or even compared to bozohttpd.
anyfooalmost 7 years ago
Neat, but unless I am missing something, a nightmare in terms of security. Assembly has a worse type system than even C: essentially no type system at all!<p>(Or rather the weakest, simplest, most dynamic type system you can imagine.)
评论 #17527518 未加载
评论 #17528576 未加载
daniel-cussenalmost 7 years ago
25.8 KB zip file! Now that&#x27;s tight code.
评论 #17526524 未加载
fbn79almost 7 years ago
AVE CESARE!
ConcernedCoderalmost 7 years ago
Nice? I mean, how would you be certain it was NOT a &quot;Web VIRUS for Linux written in amd64 assembly (2017)&quot; unless you could read grok asm?<p>NOTE: I&#x27;m not saying it IS or ISN&#x27;T, and although I CAN grok asm, I&#x27;m not going to take the time to do it right now...<p>Just struck me as possible, given the idea of a high-level language is to mainly provide abstraction over implementation details ( point being, you can&#x27;t really get any MORE implementation detail specific than asm... )<p>(edit: words...)
评论 #17528435 未加载