C++ Bare Bones

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
coffee
Posts: 2
Joined: Thu Jun 04, 2009 12:45 pm

C++ Bare Bones

Post 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
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: C++ Bare Bones

Post 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.
coffee
Posts: 2
Joined: Thu Jun 04, 2009 12:45 pm

Re: C++ Bare Bones

Post 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
Post Reply