About the bootsector...

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
Yoshy

About the bootsector...

Post by Yoshy »

Hi, I'm the new guy :D
Okay, so before I start let me tell you that I have 5 yesrs of experience in C/C++ and 3 months in ASM ( But I'm a fast learner - I know that [ax] is a pointer to ax !; acually I leanrd it while looking at MS Vc++ disasembly :D ). But I fell quite at home with the intel-like syntax of NASM.

Soooo... I worte a small bootsector that prints "Hello world" and detects what kind of CPU you have (8086, 286, 386+). But now I want to do more.

I'll limit my post to a few questions beacuse I really want to understand this before going and writting other parts of my os...

So I would like to know if it's best to do a much as possible in the bootsector or a little as possible. I would also like to know where should I enable pMode ? In the bootsector (I don't want my OS to switch modes in run-time; it will always be in pMode). And how do I enable pMode and, from ASM, how do I call a 'C' function. I understant I must go a global _myCFoo and that the params are in revers order but how is it done in real-life ?

Thanks for all your comments/answers/links.
Oh, btw, if you must know; I'm 17 and I come form Canada, Quebec.
Tom

Re:About the bootsector...

Post by Tom »

want PMode and a C kernel loaded with your bootsector? look at my web site and download pk0.6. look at boot.asm ( it loads my C kernel, sets Pmode and a GDT )

I use elf so I don't need the _'s in my kernel linked with asm.

It's best to do as much as possible in a bootsector...at least for my OS, FritzOS.

But it's all your idea...( I do as much as possible for easy coding )

Check FritzOS and see if it helps...
Yoshy

Re:About the bootsector...

Post by Yoshy »

Thanks !
I rewote all of your functions and splitted in 6 files and it still works !!!. I'll start the keyboard driver now !

Thanks again ! ;D :D ;D :D
Tom

Re:About the bootsector...

Post by Tom »

Are you making the keyboard driver with a IDT? if so...I would like the code... ;D
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:About the bootsector...

Post by Pype.Clicker »

Yoshy wrote: ( But I'm a fast learner - I know that [ax] is a pointer to ax !; acually I leanrd it while looking at MS Vc++ disasembly :D ).
hum ... i'm afraid you're wrong on that point! [ax] is by no way a pointer: it is a memory region addressed by ax. So maybe we could tell ax is a pointer to [ax] but that would still be weird-sounding in a low-level language where there's no type and therefore no pointer type ...
grey wolf

Re:About the bootsector...

Post by grey wolf »

as long as the concept is understood, what use are semantics?
Curufir

Re:About the bootsector...

Post by Curufir »

times 1000 MOV AX, BX

times 1000 MOV AX, [Somewhere in memory]

If they match in execution time then I'll eat my hat (Have to go buy one first of course :)). Knowing about the existence of registers is...err...kinda important if you wander into assembly language.

Curufir
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:About the bootsector...

Post by Pype.Clicker »

funny enough, they *could* almost match in execution time, as the very first mov ax,[mem] will make [mem] to be in cache and reading from the cache will probably require just 1 cycle - as reading from a register do ;)
Curufir

Re:About the bootsector...

Post by Curufir »

Pedantic swine ;D

Curufir
Tim

Re:About the bootsector...

Post by Tim »

Pype.Clicker has a very valid point -- accessing the L1 cache on modern CPUs is as quick as accessing registers.
Curufir

Re:About the bootsector...

Post by Curufir »

Ahh, but those 2 extra cycles (Or is it 3, can't remember) for the first reference are saving me from hat eating...which is lucky, I'm out of tomato sauce ;D.

Curufir
Post Reply