Page 1 of 1
C or asm
Posted: Tue Nov 10, 2009 6:42 pm
by VolTeK
i am almost finished with my current os, and have been thinking about how my future in this is going to look and how good it will be depending upon what tool i use. i have looked into 32 bit assembly, but still cant even enter protected mode (workin on it) i always get the "processor error" in virtual PC 2007, i have used every tutorial i could get my hands on, and nothing has ever worked for me, so in the mean time im leaning new things. but i want to know what programming langage is most effiecient for my 32 bit development. C or asm (i have learned alot of 16 bit asm, and learning 32bit)
any help would be appreciated,
thanks
Re: C or asm
Posted: Tue Nov 10, 2009 7:33 pm
by neon
I would have to say C. HLLs allows you to not worry about alot of the details involved in assembly language, and provides faster productivity rate compared to assembly language.
(oh, and congrats on your 256th post!)
Re: C or asm
Posted: Tue Nov 10, 2009 7:54 pm
by NickJohnson
I would also recommend using C for most of a project, not only because it hides many tedious details (which is a big plus), but also because of portability - if 95% of the code is C, theoretically all you would need to port is 5% of the code to make it work on another architecture. Of course, for kernel code, a lot of it is not portable, but the higher level parts as well as everything outside of the kernel should require little modification. (IIRC) the reason C was initially so successful is because it was portable across architectures.
If you like assembly a lot, it might be a good balance to have everything non-portable (not just requiring privileged instructions or stack hacking) written in an assembly "hardware abstraction layer", which is linked to by C code that does the high level stuff that ties everything together. The point is, use assembly where it works better: I have seen assembly shorter and clearer than C for bare metal operations.
Edit: You mean congrats on 0x100 posts (or perhaps 0400?)
Re: C or asm
Posted: Tue Nov 10, 2009 7:56 pm
by VolTeK
then i will start learning C, it wil not be easy as learnig asm was, but ill do my best. thank u for the answer, i wasnt loking for a "u can use C and asm" i was looking for a what should i put my time more torward, C or asm, and thank u for the answer. C it is then. now if anyone could help me with my real more to protectes mode switching problem problem
@neon: thanks lol now for 512, maybe next year im barely on as it is lol
@nick: lol thanks
Re: C or asm
Posted: Tue Nov 10, 2009 8:01 pm
by NickJohnson
Usually, protected mode OSes use a bootloader to get into protected mode, mostly because it's a tricky operation, but also because you don't have to load anything off the disk, or even deal with the (potentially buggy) BIOS at all. I would recommend just using GRUB, but if you want to bootstrap your own kernel, there is a
wiki page on the protected mode switch...
Re: C or asm
Posted: Tue Nov 10, 2009 8:10 pm
by VolTeK
thank u, i might be enabling the a20 at the wrong time, or loading the gdtr at the wrong time, il read carefull, and thank you for the help
Re: C or asm
Posted: Tue Nov 10, 2009 8:38 pm
by neon
Ghost:
This might help when understanding protected mode and getting into it. If you need specific help, feel free to ask.
Re: C or asm
Posted: Tue Nov 10, 2009 8:40 pm
by VolTeK
thank you, and i might, and i am sure i will have some questions. thank you all
Re: C or asm
Posted: Wed Nov 11, 2009 12:57 pm
by VolTeK
finally, in protected mode, now to learn more about protected mode memory (already know some about it) and more about 32bit assembly, id like to thank the forum, (mainly neon and nick)yes i did load the a20 and the gdt in the wrong places and had cli and sti where they shouldnt be. i think im going to leave my realmode project out and start on the realy fun stuff