I'm surprised that asmhttpd doesn't use sendfile(2) anywhere. Isn't that the fastest way to send a file to a socket?
Web server for Linux written in amd64 assembly
31–40 of 59 posts
Re: Web server for Linux written in amd64 assembly
#32Earlier quoted context omitted.
AFAIK the Turbo Assembler was producing x86 bytecode, how would that work?
> x86 bytecode What?!
Re: Web server for Linux written in amd64 assembly
#33Why would you do this, write it in C and let the compiler do the hard work.
I agree. There's little justification for this other than 'I can'. If you need to hit the metal you can inline assembly in both c and c++.
And why isn't that enough?
Re: Web server for Linux written in amd64 assembly
#34Pretty neat! It's awesome how assembly these days is reasonably high level: https://github.com/nemasu/asmttpd/blob/master/http.asm It dawns on me why we couldn't have shortcuts for several patterns that show up everywhere: - mov, mov, mov then call/syscall could just be written as call(arg, arg, arg) since it's not that difficult to figure out which argument needs to go to which register if there was a defined order…
Re: Web server for Linux written in amd64 assembly
#35Using Document Root: htdocs/ An error has occured, exiting
Re: Web server for Linux written in amd64 assembly
#36Earlier quoted context omitted.
I agree. There's little justification for this other than 'I can'. If you need to hit the metal you can inline assembly in both c and c++.
> There's little justification for this other than 'I can'. And why isn't that enough?
Re: Web server for Linux written in amd64 assembly
#37I wonder how fast is this server. Is handwritten assembly faster than GCC/clang-written assembly?
As one example, check out the content-type detection, which is essentially a long chain of repeated strlen + strcmp; assembly language doesn't magically make bad algorithms fast.
Re: Web server for Linux written in amd64 assembly
#38Re: Web server for Linux written in amd64 assembly
#39Earlier quoted context omitted.
A few more instruction cycles? Which architecture and which decade?
This decade :) For modern out-of-order CPUs - xor reg1,reg2 is problematic because the result depends on the previous contents of the register. Hence it cannot be executed out of order. However as a special case xor reg1,reg1 (along with sub reg1,reg1) will be detected by the cpu (intel anyway) as a 'zero idiom' instruction and because it has a smaller opcode than mov reg,0 its preferred. There are also other complex…
The initial claim was that mov reg,0 was slower to execute.
Re: Web server for Linux written in amd64 assembly
#40Earlier quoted context omitted.
> It's awesome how assembly these days is reasonably high level: There were macro assemblers already available in the 80's!
In my OS/architecture class we used a textbook whose author had piled on so much macro assembling on top of SPARC asm (macros all in m4, naturally) that he in effect was writing the book using a personal high-level language constructed out of gobs of m4. Like the bizarro-world version of personalized language construction in Lisp-land... Was this book (the first review complains about the same thing): http://www.amaz…
I think the use of m4 needlessly complicated the material.