This code comes from my operating system project, written in Crystal. The target platform was AMD64, so that's why it uses 64-Bit integers all over the place. The whole thing isn't open (yet?), but I stopped working on it so..
Take what you want from it, however a short source description, e.g. using a in-source comment, to this gist or to me would be really neat :)