When I declare a variables in my kernel, such as these (for example):
dd cursor_x
dd cursor_y
The locations of these variables when the kernel is run will not be at "cursor_x" ( or the location that nasm will change that to), because that is their location in the disk image. Their location in memory will be:
( ( cursor_x - k_main ) + kernel_offset )
Where kernel_offset is where the kernel was loaded into memory and k_main is the location of the first kernel byte. I'm not sure If I've explained this well enough already, or I've not been specific enough so I'll provide an example, just to make sure...
Say my kernel is loaded to 0x000B0000, and this is my kernel:
Code: Select all
[BITS 32]
k_main:
cursor_x dd 0x00000000
cursor_y dd 0x00000004
Now to address either of these variables, I have to say:
DWORD [ ( ( cursor_x - k_main ) + 0x000B0000 ) ]
and
DWORD [ ( ( cursor_y - k_main ) + 0x000B0000 ) ]
Nasm had no problem assembling addresses this way, if it's in the same module as the k_main label. However, if I try to address a variable this way from another module, in which k_main is defined as external, I get the following error:
Code: Select all
./../sources/kernel/k_screen/k_screen.asm:30: error: beroset-p-650-invalid effective address
Help appreciated,
Brodeur235