And you should not be surprised if it doesn't work when you un-nest it from all that virtualization...
Virtual machines are pretty good, but they're not perfect...
But how do I allocate memory? I mean there are various tutorials on the net on how the process should be done, and the dangers of making one(which is kind of why I'm using a Virtual Machine), but not one line of code. What function/command in C allocates memory? Or do I need to use assembly's mov command?
If you are working on an OS kernel you need to write a complete memory manager, that is, the underlying stuff behind malloc()...
Usually memory is allocated by placing frames around blocks of memory... they form a sort of linked list (loose analogy, but close enough for illustration purposes) of allocated blocks, each pointing to the next. You start at the bottom (or top) of memory and allocate 100 bytes, so you put a frame there, the frame contains a pointer to the next block and the size of the current block and you return a pointer to the first byte of the block to the program... to allocate another block you simply add a nother frame...
Then to deallocate a block you fix the pointers and remove the frame...Code:
size of this block
pointer to next block
* allocated block
Size of this block
pointer to next block
You know where each block begins and ends, so as you add and remove blocks you can "manage" the memory by filling gaps.
Of course it's a little bit more complicated than this --well, more than a little actually-- but that's the jist of it... If you understand linked lists you understand memory management.
Where exactly are you at with regard to this OS development? Is your boatloader done or are you using something like GRUB? When you say, "I made my own printf function", what do you mean by that? I hope you understand that when creating your own OS you leave behind the comfort of the standard libraries when it comes to input/output, memory management, disk access, ect. All these libraries implement there functions by OS specific API calls that conform to the standard; however they are specific to the OS they were made for.
The reason I am saying this is because of your question asking for what "C function to allocate memory". There is no standard C function available to you because you are creating your own OS. You have left the comfort zone of the standard libraries and you are on your own in the woods so to say.
Keep this in mind when you decide to come back here and ask for what C function to make files or access the harddrive. There are none for you. You are going to need to make them yourself.
That being said take a look at these tutorials. This should get you going with your project. I would suggest you start at the top and read your way through.
The OSDev page you yourself linked mentions two different approaches: Bitmaps or headers. The same site also has explanations of what those two words mean.
here I understand how the code works, but I can't identify the line of code which actually assigns the memory. Any help?
It's all assigning memory... he's doing what I showed you in message 35 of the thread... writing frames into memory.
i386/boot/cdboot/malloc.c Source is that I have no idea what &end is. It hasn't been declared in this piece of code, so I assume its in boot.h. How do I define end?
end is probably the end of the allocated block of memory; but as you say, it is not defined here (nor is it changed here!) so if you want to know what it is you'll have to find it elsewhere.
Are we really going to build an OS one post at a time here? This is starting to verge on ridiculous.........
That doesn't make the attempt pointless. The OP will gain experience whether s/he succeeds or not. For example, "Learning to quit while you are ahead" appropriately is something you learn thru experience, but beyond that there's lots worthwhile in studying how an OS kernel works, and doing it hands on might be a good idea. I'm jealous ;)