Page 1 of 1

Memory Reference Using Labels

Posted: Wed Apr 02, 2008 11:26 pm
by Pitchu
Hi
Well this post of mine is similar in context to a previous one but I think I wasnot able to explain my question there, so here it is:

How can I access a memory location from within my kernel which is not a part of kernel i.e. I mean after the BootSector is loaded into memory at 7c00h which inturn loads kernel at 7e00h (Still in RMode) and kernel needs to access BPB of BootSector?

If have following solutions:

1. Remember where the BPB of BootSector begins in memory and its size and then using those addresses as direct addresses in code....Not a good idea.

2. %include bootsector.asm file :oops: I am afraid there will be no distinctinction between Bootsector and Kernel and most importantly i believe i will get only 1 output file while I need 2 - bootsector and kernel.

3. %incbin bootsector.bin file :oops: Same problem as that of 2, worse I cannot address BPB using labels.

I hope all you there got what I mean....
I wish there is a way where you pseudo-include an asm file to access the variables defined there but donot embed those variables and code or increase the size of the file that includes....
A sort of c-style header file defining all symbolic constants..

Hope this is enough to make my idea clear :)

Re: Memory Reference Using Labels

Posted: Thu Apr 03, 2008 2:31 am
by Combuster
Pitchu wrote:1. Remember where the BPB of BootSector begins in memory and its size and then using those addresses as direct addresses in code....Not a good idea.
Why not - the bootsector is loaded at 0x7c00 so it is already at your disposal at a known address.
2. %include bootsector.asm file :oops: I am afraid there will be no distinctinction between Bootsector and Kernel and most importantly i believe i will get only 1 output file while I need 2 - bootsector and kernel.
You can very well put the kernel and bootloader in one image and put them directly at the start of the disk. you will know where the kernel starts and where the bootsector ends - at the second sector.
3. %incbin bootsector.bin file :oops: Same problem as that of 2, worse I cannot address BPB using labels.
Same non-problem you mean. You can use one label and add equates for each item in the struct, which is another non-problem.
I hope all you there got what I mean....
I expected a bit more from a seasoned programmer doing os development :roll:

Posted: Thu Apr 03, 2008 3:46 am
by Pitchu
Well if there is not a way the seasonal programmer thought to make design flexible, he will stick to solution 1 until such solution is discovered.
Thnx