Page 1 of 1

C++ Bare Bones

Posted: Thu Jun 04, 2009 12:48 pm
by coffee
Hi,

I've got a question about the following turtorial
http://wiki.osdev.org/C_PlusPlus_bare_bones

I don't understand about following part with with piece of code it's connected
C/C++

typedef unsigned long vintp; //- integer type to store a pointer.

extern start_ctors, end_ctors, start_dtors, end_dtors;

void loader(void) {
//- call all the static constructors in the list.
for(vintp * call = &start_ctors; call < &end_ctors; call++) {
((void (*)(void))*call)();
}

//- call kernel proper
main();

//- call all the static destructors in the list.
for(vintp * call = &start_dtors; call < &end_dtors; call++) {
((void (*)(void))*call)();
}
}
it's in loader.s document, does this mean that this piece is from NASM or from the GAS code

Re: C++ Bare Bones

Posted: Thu Jun 04, 2009 2:18 pm
by NickJohnson
I believe the idea is to use that C/C++ code instead of the GAS or NASM code. However, it doesn't have nearly as much power as the assembly: it can't get the multiboot pointer, set up the GDT, or set up a higher half kernel. I would probably use the assembly instead. I also could be wrong - it may be intended to work with a smaller assembly section contained in loader.s.

Re: C++ Bare Bones

Posted: Fri Jun 05, 2009 9:41 am
by coffee
hello,

Now you mention, the code seems to look allmost exactly the same, so I think you're right. I'll give it a try