Page 1 of 1

About the bootsector...

Posted: Wed Nov 13, 2002 6:04 pm
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.

Re:About the bootsector...

Posted: Wed Nov 13, 2002 6:13 pm
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...

Re:About the bootsector...

Posted: Wed Nov 13, 2002 11:20 pm
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

Re:About the bootsector...

Posted: Thu Nov 14, 2002 9:59 am
by Tom
Are you making the keyboard driver with a IDT? if so...I would like the code... ;D

Re:About the bootsector...

Posted: Fri Nov 15, 2002 12:56 am
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 ...

Re:About the bootsector...

Posted: Fri Nov 15, 2002 2:52 am
by grey wolf
as long as the concept is understood, what use are semantics?

Re:About the bootsector...

Posted: Fri Nov 15, 2002 8:55 am
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

Re:About the bootsector...

Posted: Fri Nov 15, 2002 9:30 am
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 ;)

Re:About the bootsector...

Posted: Fri Nov 15, 2002 10:53 am
by Curufir
Pedantic swine ;D

Curufir

Re:About the bootsector...

Posted: Mon Nov 18, 2002 6:26 am
by Tim
Pype.Clicker has a very valid point -- accessing the L1 cache on modern CPUs is as quick as accessing registers.

Re:About the bootsector...

Posted: Mon Nov 18, 2002 7:05 am
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