TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A web server in x86 assembly language

75 点作者 hide1713将近 14 年前

7 条评论

Luyt将近 14 年前
Hmmm, 90% seems to be glueing Win32 APIs together for a GUI. That's not very exciting in assembly; neither is it significantly more efficient than doing it from C. It's also very unreadable, and I fear for maintainability.<p>And does this webserver serve many simultaneous connections? I doubt it. You'd learn more about proper webserver programming techniques by studying the source code to nginx [1] or mongrel2 [2].<p>As an example, it's more useful in showing how to build GUIs in assembly, and that's not very productive. You <i>do</i> get small executables, tho.<p>[1] <a href="http://nginx.org/en/" rel="nofollow">http://nginx.org/en/</a><p>[2] <a href="http://mongrel2.org/home" rel="nofollow">http://mongrel2.org/home</a>
评论 #2615700 未加载
Wo0kToR将近 14 年前
These Win32 assembly programs are quite cool. I used to dabble with writing small things in it. But I realised a while ago that, as Luyt has already touched on, 95% - 99.x% of the CPU time is spent in the Win32 library code, which is written in C, and which you have to call if you want to do anything significant, eg. put up a GUI. That defeats the performance benefit of writing such programs in asm: like Luyt said the slow down from writing the same thing in efficient C or C++ code would be minute. You still get the benefit of tiny executables, though.<p>One might consider the fact that nowadays it's only worth writing "busy code" in assembly, and most or all of a GUI app isn't busy code, but that would be being sensible. A web server might have a few pieces of busy code in it IF it's designed to connect to hundreds or thousands of users at once. It would be good to write those in assembly. :)
评论 #2616072 未加载
kragen将近 14 年前
It's mostly calls to some kind of assembler macro built into MASM, which means it's not really x86 assembly language:<p><pre><code> INVOKE SetFilePointer,hFile,FOffset,0,FILE_BEGIN INVOKE ReadFile,hFile,pMem,FSize,offset NotUsed,0 INVOKE send,wParam,pMem,FSize,0 INVOKE GlobalUnlock,hMem INVOKE GlobalFree,hMem INVOKE closesocket,wParam INVOKE CloseHandle,hFile ;Done with file and socket too. </code></pre> The guy wrote it in 2001, when he was in high school, and he's done a lot more cool and interesting stuff since then, and it looks like he's graduated to Linux: <a href="http://lingcog.iit.edu/~scubed/projects.xml" rel="nofollow">http://lingcog.iit.edu/~scubed/projects.xml</a><p>Too bad he stopped adding new projects to the page in 2007. His "portfolio" page has a few more things since then.
评论 #2618393 未加载
msie将近 14 年前
It would have been really neat if the page was served by the very same assembly code.
limmeau将近 14 年前
It's also an example of a Win32 program in assembler, together with a WndProc for a window. Does Win32 require a window if you want to write a web server?
评论 #2615754 未加载
评论 #2615706 未加载
leon_将近 14 年前
I'd say code readability is at the level of a Node.js application.
评论 #2616266 未加载
评论 #2615921 未加载
Argorak将近 14 年前
Hm, no rack adapter yet?<p><i>duck</i>