Memory Reference Using Labels

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
User avatar
Pitchu
Member
Member
Posts: 56
Joined: Tue Feb 12, 2008 3:16 am
Location: Kashmir - Paradise On Earth

Memory Reference Using Labels

Post 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 :)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Memory Reference Using Labels

Post 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:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Pitchu
Member
Member
Posts: 56
Joined: Tue Feb 12, 2008 3:16 am
Location: Kashmir - Paradise On Earth

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