nitrix 126 days ago [-]
I have followed the work of vendu on his OS over the years. He has mastered the art. If anyone is interested, you should get in touch with him and try to extract some of the genius sauce out of his brain; especially that memory allocator.
crazyfin 125 days ago [-]
thanks man! :)

the malloc in the book can be considered obsolete - i'm coming up with something hopefully better, even though my rewrite is seriously under construction at the moment.

for some memory management stuff, feel free to consult


wmu 126 days ago [-]
Impressive work. One note: use of MMX instructions in 2017 is odd, as MMX is dead.
pjc50 126 days ago [-]
It's available everywhere now - superceded, yes, but this book is probably older than it looks. That page links to HAKMEM (1972)!

From a scan of the TOC it looks like a great introduction to C programming from a machine point of view. Although, as DJB has pointed out, there can be a big gap between "what all sane compilers do on this architecture" vs "what the C standard actually guarantees".

Edit: thinking about this, it's a bit Intel-centric. The people more likely to be writing low-level code these days would be targeting ARM or even AVR/PIC.

tom_mellior 126 days ago [-]
> this book is probably older than it looks

Yes, from the copyright notice it looks like it was originally started in 2008. Though HAKMEM was already ancient in 2008, too.

> From a scan of the TOC it looks like a great introduction to C programming from a machine point of view.

Maybe, but from the actual contents it's hard to tell what it's trying to do. The C part starts out with a section on C types, with the first sentence being "This section doesn’t attempt to be a primer on C types; instead, I cover aspects I consider to be of importance for low-level programming."

So it's not a primer on C, fair enough. But then it goes on to explain the const and extern keywords, and how to declare structs. It's hard to tell what audience this is aimed at. People who already know enough C not to need an actual primer on C, but who do still need an explanation of const and a very partial explanation of structs?

Other parts, like the malloc implementation at the end, look better, though.

crazyfin 125 days ago [-]
hey there & thanks for the feedback! :)

as it was called nicely, you should consider this book a set of musings and notes. one of the driving ideas behind the c part was to introduce the readers to things new in c99. :P

that malloc, whereas kinda okay, has already been rewritten and the new version is under construction. it sports thread-local magazine caches and all kinds of hacks i've found interesting to mess around with. :)



crazyfin 125 days ago [-]
hehe vendu has been taken already (possibly by me, might have forgotten about it)... =)

back when i wrote this book, i didn't have sse beyond sse1 on my desktop box, so i used mmx. the point was to demonstrate some basic use of simd.

cheers & thanks,

vendu =)

wddps 126 days ago [-]
Dead or under utilized
samkellett 126 days ago [-]
rep_movsd 126 days ago [-]
MMX is not really dead - how else would you do byte level integer processing? AFAIK the later SIMD instructions are all float based
hrydgard 126 days ago [-]
Not true, SSE2 added support for performing all the MMX operations, but at 128-bit width in the SSE registers. AVX2 expanded that out to 256-bit width later.
stephencanon 125 days ago [-]
Right--there is no reason to use MMX today, and two good reasons not to. SSE2 and follow-on extensions give better performance, and the SSE registers do not alias the x87 stack, which removes the risk of a particularly nasty and difficult to diagnose class of bug (failure to issue EMMS following MMX usage can cause x87 stack corruption billions of cycles later in an apparently unrelated call tree).
crazyfin 125 days ago [-]

as i told you guys above, i didn't have sse2+ around at the time i wrote those chapters.

thanks a million for the note on x87 stack corruption, i didn't know about that bug. ;)

hack on,


theparanoid 126 days ago [-]
SSE2 introduced integer instructions.