multiple org statements dont work in nasm
multiple org statements dont work in nasm
I'm to the point where ive enabled paging and i want to execute my kernel at high virtual memory however when i have another org statement in the nasm source file, the entier source file dosn't assemble correctly or soemthing. Is there any easy way around this? or do i just either have to link it together at different address, or include a seperate binary file in my source file?
Re:multiple org statements dont work in nasm
It would be easier to link all the file to a low address or all the file to a high address. You can't easily have a split like this (as you've found), and it just confuses things.
You could either:
-- Make the bit of code which enables paging position-independent. That is, write it so that it doesn't care where it's really located in memory. Then you could link it to a high address and it would still run, even though it was really at a low address. Since the rest of the kernel will be linked to a high address, and it really *is* at a high address (because paging is enabled), everything's OK.
-- Enable paging in the kernel loader. Then link all the kernel to a high address without any position-independent code. Then paging is always enabled while the kernel is running.
-- Set the base address of your code and data segments to a magic value so that linear address C000_0000 (or wherever) maps to physical address 0010_0000 (or wherever) even though paging isn't enabled yet. Then, when you enable paging, you could load flat selectors with zero base and carry on as normal.
I think I described one or more of these approaches in my memory management tutorials.
You could either:
-- Make the bit of code which enables paging position-independent. That is, write it so that it doesn't care where it's really located in memory. Then you could link it to a high address and it would still run, even though it was really at a low address. Since the rest of the kernel will be linked to a high address, and it really *is* at a high address (because paging is enabled), everything's OK.
-- Enable paging in the kernel loader. Then link all the kernel to a high address without any position-independent code. Then paging is always enabled while the kernel is running.
-- Set the base address of your code and data segments to a magic value so that linear address C000_0000 (or wherever) maps to physical address 0010_0000 (or wherever) even though paging isn't enabled yet. Then, when you enable paging, you could load flat selectors with zero base and carry on as normal.
I think I described one or more of these approaches in my memory management tutorials.