Live data from Hacker News

Assembly Nights

ratfactor.com

21–30 of 37 posts

Re: Assembly Nights

#21
post #18

I've also recently discovered the joy of system level programming. I've gone through a few iterations of writing a (incomplete) kernel from scratch using different languages. I started with a 32-bit kernel in C and got as far as preemptive multitasking. Then I decided to try Nim, I found it very ergonomic and lets you write compact code that expresses the main logic without too much syntax noise. But I got blocked by…

github? I like the idea of using Nim to write a kernel, and is curious on what the code looks like. Especially, how do you avoid malloc?

Re: Assembly Nights

#23
post #21
post #18

I've also recently discovered the joy of system level programming. I've gone through a few iterations of writing a (incomplete) kernel from scratch using different languages. I started with a 32-bit kernel in C and got as far as preemptive multitasking. Then I decided to try Nim, I found it very ergonomic and lets you write compact code that expresses the main logic without too much syntax noise. But I got blocked by…

github? I like the idea of using Nim to write a kernel, and is curious on what the code looks like. Especially, how do you avoid malloc?

I wasn't ready to share it yet, but here it goes[1]. It's at a very early stage, but should give you an idea of how to get things up and running under Nim.

I didn't avoid malloc. I provided a simple bump pointer based heap to get things going. Later I'll have to separate things into a UEFI bootloader and a proper kernel image, each with its own allocator (the bootloader will use UEFI memory allocation services, and the kernel will have its own heap).

[1] https://github.com/khaledh/axiom

Re: Assembly Nights

#24
post #5

I recently started manually writing assembly with focus AVX2 (a flavor of Intel SIMD extensions). The rationale is that these are complex enough that compilers do not always notice the opportunity to use them, so my ultimate goal is to apply this is to find a non-artificial problem where I could beat a compiler :-) I confirm that its one of the most satisfactory ways to add some numbers using a modern computer.

Would you maybe be able to share some of the learning resources you’ve been using? I’ve really been wanting to get into this! :)

I found surprisingly little material about "how to program AVX/AVX2". That said here's what I used so far:

  * Intel AVX Programming Reference [0] - comprehensive but not very useful as "where do I even start"

  * Godbolt[1] to look at code samples produced by compilers. This is good to see how the instructions work together.

  * A random discussion that has *some* concepts behind the YMM registers[2]

  * Stack Overflow, for example [3]

[0] https://www.intel.com/content/dam/develop/external/us/en/doc...

[1] A sample code that generates some AVX2 code: https://godbolt.org/z/Kr1sojov6

[2] https://community.intel.com/t5/Intel-ISA-Extensions/Software...

[3] https://stackoverflow.com/q/40623773/12166

Re: Assembly Nights

#25
"Also, though I did install Lynx, this is not a great machine for modern Web surfing (except for ratfactor.com, of course). So it's a pretty distraction-free device."

As an owner of one these ASUS EeePC netbooks I used links (a different text-only browser) in VGA textmode in NetBSD for many years. For the small screen size, the terminal font is easy on the eyes. Lynx is one of the worst text-only browsers, IMHO. For me, staying in textmode prevents distraction. However I am reading from the www in textmode all the time. A large, complex, Javascript-enabled, advertising-sponsored, graphical browser is not necessary. No idea what "modern Web surfing" means but it does not sound like it is worth the time if all it produces is distraction.

Re: Assembly Nights

#26

"Also, though I did install Lynx, this is not a great machine for modern Web surfing (except for ratfactor.com, of course). So it's a pretty distraction-free device." As an owner of one these ASUS EeePC netbooks I used links (a different text-only browser) in VGA textmode in NetBSD for many years. For the small screen size, the terminal font is easy on the eyes. Lynx is one of the worst text-only browsers, IMHO. For…

> Lynx is one of the worst text-only browsers, IMHO.

What are you using then? I didn't like the "bloatedness" of the modern web. So I often use browser "reader mode". But I would happily try something different.

Re: Assembly Nights

#27
That's somewhat similar to what I'm doing with Miniforth [0]. Programming in a minimal environment is fun. I don't have a separate machine, so I'm booting my main laptop from a thumbdrive. The difference in boot time is staggering – after BIOS loads the boot sector, everything else is instant. This is instrumental to my strategy for tricking myself into working on the project – normally, I'm very prone to going off into a research rabbit hole after taking a look at the wrong browser tab. So, instead, I make sure to power off my machine in the evenings. That way, booting into miniforth becomes the option with less friction (:

Unfortunately, this does not work for writing the blog about the project. Hopefully this will change soon, once I write an editor and filesystem...

[0]: https://niedzejkob.p4.team/bootstrap/

Re: Assembly Nights

#29
post #5

I recently started manually writing assembly with focus AVX2 (a flavor of Intel SIMD extensions). The rationale is that these are complex enough that compilers do not always notice the opportunity to use them, so my ultimate goal is to apply this is to find a non-artificial problem where I could beat a compiler :-) I confirm that its one of the most satisfactory ways to add some numbers using a modern computer.

My favourite way to add numbers, in assembly, was this project: https://github.com/skx/math-compiler I had far too much fun writing it, even though it is completely pointless!

That sounds like formula translator, aka Fortran!

Re: Assembly Nights

#30
It's so nice to find something you wrote 10+ years ago still being enjoyed in the wild (under the sheets no less).

Kudos to Dave for a great read, he's inspired me to dust off my own EeePC!..

Post reply on HN