Move all asm but MBR to inline asm, rewrite memory detection and add regparm attribute to all functions