Live data from Hacker News

AsmBB – a lightweight web forum engine written in assembly language

asmbb.org

71–80 of 131 posts

Re: AsmBB – a lightweight web forum engine written in assembly language

#71
post #14

Earlier quoted context omitted.

It's less complicated than you might think. You call into SQLite C library functions using C calling conventions. Here's the relevant code: https://asm32.info/fossil/asmbb/file?name=source/sqlite3.asm...

How about for setting up a server and serving http requests / establishing web sockets? If it’s just a bunch of calling C code then I have to ask which part of this is actually assembly

Well, you see, most OSes today aren't written in ASM. Their native libraries are C, so you have to interface with those libraries if you want to utilize them and their features.

You can certainly write your own TCP/IP stack with raw sockets and directly interface with the NIC, if you like. But at that point you're both reinventing the wheel and bypassing the entirety of the OS, you might as well just write a forum exokernel.

Most developers don't consider utilizing a library in another language as "cheating". Popular and core Rust, D, C++, Python, nodeJS, etc libraries do this all the time.

Re: AsmBB – a lightweight web forum engine written in assembly language

#72

Processing time is insanely fast according to the footer. But the time it takes to transfer the document to Denmark is 500 - 1000ms. Seems like a CDN is better than performant code in this case... Still an impressive feat.

Coming from leading response time initiatives at a Big Tech, ouch. 1s is painful. Obviously transit time is a big part of that but if that's considered "good", well oof.

Well your average big tech site might transfer in a fraction of that, but then spends >5 seconds running JavaScript before anything useful happens.

Re: AsmBB – a lightweight web forum engine written in assembly language

#73
post #25

Earlier quoted context omitted.

C is generally first compiled into assembly anyways. When you program in assembly you're basically just doing the job of the compiler, and can call all the same library functions C code can. You just have to follow the calling conventions of the architecture. It's cumbersome and tedious, but nowhere near impossible. x64 made calling functions more annoying by using registers then spilling over into the stack after ex…

> C is generally first compiled into assembly anyways. I don't think that's right. C is compiled into an intermediate representation first. It's true that you can ask GCC etc. to generate assembly output, but it's not the default.

> I don't think that's right. C is compiled into an intermediate representation first. It's true that you can ask GCC etc. to generate assembly output, but it's not the default.

Just because there's an IR within the compiler doesn't mean there's no "assemble" stage. What do you think the "-pipe" flag to gcc is for? It pipes the compiler output into the assembler, rather than using a temporary .s file.

gcc has four main stages going from source to executable: preprocessor->compiler->assembler->linker.

Edit, for your convenience, gcc -save-temps example:

  > [user@host /tmp/foo]$ ls
  > f.c
  > [user@host /tmp/foo]$ cat f.c
  > #include 
  >
  > int main(int argc, char **argv)
  > {
  >         puts("Hello world!");
  >
  >         return 0;
  > }
  > [user@host /tmp/foo]$ gcc -o f -save-temps f.c
  > [user@host /tmp/foo]$ ls -l
  > total 48
  > -rwxr-xr-x 1 user user 15416 Jan 13 16:50 f
  > -rw-r--r-- 1 user user    91 Jan 13 16:49 f.c 
  > -rw-r--r-- 1 user user 17145 Jan 13 16:50 f.i 
  > -rw-r--r-- 1 user user  1496 Jan 13 16:50 f.o 
  > -rw-r--r-- 1 user user   515 Jan 13 16:50 f.s 
  > [user@host /tmp/foo]$ cat f.s
  >         .file   "f.c"
  >         .text
  >         .section        .rodata
  > .LC0:
  >         .string "Hello world!"
  >         .text
  >         .globl  main
  >         .type   main, @function
  > main:
  > .LFB0:
  >         .cfi_startproc
  >         pushq   %rbp
  >         .cfi_def_cfa_offset 16
  >         .cfi_offset 6, -16
  >         movq    %rsp, %rbp
  >         .cfi_def_cfa_register 6
  >         subq    $16, %rsp
  >         movl    %edi, -4(%rbp)
  >         movq    %rsi, -16(%rbp)
  >         leaq    .LC0(%rip), %rax
  >         movq    %rax, %rdi
  >         call    puts@PLT
  >         movl    $0, %eax
  >         leave
  >         .cfi_def_cfa 7, 8
  >         ret
  >         .cfi_endproc
  > .LFE0:
  >         .size   main, .-main
  >         .ident  "GCC: (GNU) 13.1.1 20230429"
  >         .section        .note.GNU-stack,"",@progbits
  > [user@host /tmp/foo]$ ./f
  > Hello world!
  > [user@host /tmp/foo]$ 
  >

Re: AsmBB – a lightweight web forum engine written in assembly language

#74
post #25

Earlier quoted context omitted.

C is generally first compiled into assembly anyways. When you program in assembly you're basically just doing the job of the compiler, and can call all the same library functions C code can. You just have to follow the calling conventions of the architecture. It's cumbersome and tedious, but nowhere near impossible. x64 made calling functions more annoying by using registers then spilling over into the stack after ex…

> x32 was more pleasant by far, since it only used the stack Maybe I misunderstand you, but this is completely dependent on compiler, operating system etc, there are multiple calling conventions for x86-32, eg. cdecl, fastcall ... https://en.wikipedia.org/wiki/X86_calling_conventions

Apologies, my experience is SysV-centric for amd64, as described here[0] under the Parameter Passing section, which is a clustrfuck compared to the simplicity of the 386 SysV ABI as described here[1]:

  > Argument words are pushed onto the stack in reverse order (that is, the
  > rightmost argument in C call syntax has the highest address), preserving the
  > stack’s word alignment. All incoming arguments appear on the stack, resid-
  > ing in the stack frame of the caller.
Both links were found @ https://wiki.osdev.org/System_V_ABI

[0] https://www.uclibc.org/docs/psABI-x86_64.pdf

[1] https://www.sco.com/developers/devspecs/abi386-4.pdf

Re: AsmBB – a lightweight web forum engine written in assembly language

#75
post #37

This is super cool, though I very much doubt the following statement: > AsmBB is very secure web application, because of the internal design and the reduced dependencies. There's a lot of value in using well tested dependencies, and even Chuck Norris will have bugs writing complex software in assembly. Especially when doing string manipulation which this project should be doing a lot of.

I disagree; dependencies are more of a liability than anything else.

Do you really want to implement http, ssl and tls; all by your self, what about security hash algorithms? Re inventing the wheel means you also get to go through all the bugs and s purity issue that these open source libraries went through. This is a type of opinion I would expect some one with no understanding about security saying.

Re: AsmBB – a lightweight web forum engine written in assembly language

#76
post #64

Next: Unikernel

Yes please! Still waiting for unikernels to actually become a thing. Looks so promising, but Unikraft has yet to launch their cloud offering and NanoVM is 7$ per unikernel, which, compared to an always on shared Hetzner vCPU for ~4$ (knowing those two are not exactly the same) is kind of pricey... Would expect them to be cheaper or at least cost the same

Re: AsmBB – a lightweight web forum engine written in assembly language

#77
post #17

In the header, there’s a button to disable live notifications. On a side note, showing a list of forum users to someone who isn’t logged in is probably a bad idea. Is it something configurable?

Haven’t found the button to disable live notifications while on mobile.

Re: AsmBB – a lightweight web forum engine written in assembly language

#78
post #51

Earlier quoted context omitted.

I can see this maybe being true in a high level language (depending on the dependency), though it's definitely not the case with assembly. OpenSSL, for example, was hit with quite a few serious bugs over the years, and I'd still choose using it than my own SSL implementation. Especially in assembly.

> OpenSSL, for example, was hit with quite a few serious bugs over the years, and I'd still choose using it than my own SSL implementation. Especially in assembly. That's the difference between a programmer and a real engineer: an engineer doesn't need any help from dependencies to make his code totally insecure.

Engineers do design, implementation is the job of the technician or machinist or somebody like that. If the engineer’s code ends up shipped to customers, something very strange has happened.

Re: AsmBB – a lightweight web forum engine written in assembly language

#79

[flagged]

True, but it's a tricky time to point that out. Right now we'd have to boycott a large proportion of open source projects by Israeli and Arab/Iranian/etc authors if we wanted to avoid using any open source software written by people who support obscene and inhumane military actions.

I don’t think there is any point in boycotting open-source software written by those people?

If it was actually their source of income, then it might do something, but it’s already freely available.

Post reply on HN