Linux serverlinux web serverNETWORK ADMINISTRATIONS

Web in Native Assembly (Linux x86_64)

Playlist: https://www.youtube.com/playlist?list=PLpM-Dvs8t0VbLCQEKNhIIIHdTPlGVvETz

Chapters:
– 0:00:00 – Announcement
– 0:00:56 – flat assembler
– 0:02:36 – Hello, World in fasm
– 0:12:10 – fasm is Self-Hosted
– 0:14:07 – fasm Macros
– 0:20:23 – bm
– 0:21:49 – fasm community
– 0:24:25 – Plans for the Session
– 0:26:32 – Starting the Web Server
– 0:29:10 – Creating the Socket
– 0:38:08 – Stealing Constants from C
– 0:39:22 – Inspecting with strace
– 0:42:10 – Inspecting with gdb
– 0:49:19 – Storing the Socket in Memory
– 0:55:19 – Handling Socket Error
– 1:00:40 – Log Tracing
– 1:05:23 – The Difficulty of Binding the Socket
– 1:07:26 – Allocating sockaddr Structure
– 1:19:46 – Populating sockaddr Structure
– 1:25:52 – Binding the Socket Address
– 1:32:06 – Closing the Socket
– 1:35:45 – Listening to the Socket
– 1:39:55 – Accepting the Connection
– 1:53:32 – Responding with Plan Text
– 1:55:05 – Responding with HTTP Response
– 1:59:59 – Request Processing Loop
– 2:03:22 – Outro

References:
– flat assembler – https://flatassembler.net/
– Chromium OS – Linux Syscalls – https://chromium.googlesource.com/chromiumos/docs/+/HEAD/constants/syscalls.md
– tgrysztar – fasm – https://github.com/tgrysztar/fasm
– Tsoding – bm – https://github.com/tsoding/bm
– MenuetOS – http://www.menuetos.net/
– nakst – gf – https://github.com/nakst/gf
– musl – libc – https://musl.libc.org/

Socials:
– Twitch: https://twitch.tv/tsoding
– Twitter: https://twitter.com/tsoding

Support:
– BTC: bc1qj820dmeazpeq5pjn89mlh9lhws7ghs9v34x9v9

source

by Tsoding Daily

linux web server

40 thoughts on “Web in Native Assembly (Linux x86_64)

  • Once I asked a colleague what's after the dword. He replied with the fword, so I smacked his face.

  • If you ever feel neglected, just remember the EXIT_SUCCESS and EXIT_FAILURE he defined at 59:40 and then ignored for the rest of the stream.

  • 1:23:43 It is really easy to implement htons in assembly using XCHG instruction.
    And for htonl, there is the BSWAP instruction.
    And for information, in C, you can use __builtin_bswap16/__builtin_bswap32 under gcc and _byteswap_ushort/_byteswap_ulong under msvc.

  • Yesterday, I didn't even know this guy. Now, he is one of the best ppl I know.

  • Hi mate, i really need your help im trying to get notcurses running with fasm, How do i get these variables to work:

    define NCALPHA_HIGHCONTRAST 0x30000000ull

    define NCCHANNEL_INITIALIZER(r, g, b)
    (((uint32_t)(r) << 16u) + ((uint32_t)(g) << 8u) + (b) + NC_BGDEFAULT_MASK)

    Stuff like this is impossible to define in FASM.

    If u get time to read this ok, basically im trying to convert all the notcurses.h typedefs and structs to work with FASMN.

    Cheers mate good videos

  • pretty sure I learned more in 2 hours than 2 years of university

  • well, technically .tv is the top-level-domain of tuvalu. Buut, television is also great 😀
    (more people should have domains like that, gotta support the small busi… eh i mean countries around us 🙂 )

  • Dude, I really appreciate what you are doing, it is rare to have such of deep content (at least to me who is a junior myself) but yet entertaining.
    I really love to see and learn how things work under the hood, not just using them, and most of your video just fit that.

  • ASM is "hard" because people treat CS like the "how to draw an owl" joke: we have machine code, then we have assembly, then we have React. What is in-between? Who cares! I just LOVED the concept of "fasm" – I might try it sometime on my old asm repos.

  • First of all: A really great video! I learned a few basics about fasm.
    But one more thing: What desktop environment is here in use? I never had seen something like this before. But i like it 🙂

  • Бро, ты русский? Можно по-русски вопросы в комменты кидать тебе?

  • cant wait for the cobol web development video 🙏

  • the syscall table can be found at / linux /arch /x86 /entry /syscalls /syscall_64.tbl if you have kernel sources.

  • Does bind really determine the type based on the size? Looks more like a validation thing to me, the actual type is probably deduced using a union-type approach where they check the address family, since that's always the first field of the struct. At least that's what i'd expect. Good video :3

  • 1:56:29
    This whole bit has been my experience whenever I'm searching for answers/ examples and makes me question the legitimacy of "I just google the answers, bro" memes.

  • This channel in a nutshell: "boom, look how I can emulate modern functionality using old tools in a way that's much less robust."

    Like don't get me wrong, C is probably my favorite programming language, and using grep to search source code is a useful skill, but it also less reliable and slower than using an LSP to do go to symbol if that's available. In this case? Yeah, it's the easiest way to do it and it's a good skill, but like, it's not some super magical thing. Your approach being functional in 10 years makes it useful as a fallback, but refusing to learn or use modern tools on the basis that they might stop working (and no, this does not indicate that the tools are worse, just that they are more specific to a task and require more work to maintain) is not something to be proud of.

  • Only like an hour in, but it kinda feels like using an assembler with such powerful macros ends up sorta defeating the point, because if you're generating the bulk of your code through macros like this… well, it's basically serving as a compiler that does no optimization. You lose out on the ability to skip unnecessary operations and very tightly pack things and whatever.

    At that point it's just like… why not write C?

  • my man wrote his owns language, applications using that language, is doing a video about web development with assembly and says "I'm not a low level person"

  • Nice contribution, I was learning something, thanks so much. PS: Your Porn Folder has 6,5GiB har har har

  • Just following along for fun, my gf2 does not show the instructions after i try `run` even though the program runs fine (at 47:00)… anyone know why?
    Btw thanks for this great video. +1 sub

  • Why do i need stdlib if syscall(1, 1, "Hello world", 14) ?

  • wow, the development screencast by anyone who is not indian on youtube in 2023! instant subscription

  • Watching this taught me a lot, on top of you explaining how things work, reading some docs and following along in c is super fun. Thank you mr Tsoding

  • Great video … took my attention from the beginin..

  • 13:15 I downloaded the fasm executable directly from their website and it is, in fact, statically linked

Comments are closed.