Page 1 of 1

Preset Variable Problems

Posted: Fri Oct 21, 2005 10:54 pm
by pyros
Hello,
I am currently in the process of writing my first operating system. However, after completing the bootloader, it appears the kernel cannot access the variables I have set in assembler. I believe its possible a problem with the kernel's location in memory.

The bootloader loads the kernel off the next 1024 bytes, and places it into memory at the address location 0x7E00. It then jumps to the beginning of the kernel, which is a seperate program, and then the kernel clears the screen, and attempts to write several strings to the screen. The commands I have written for this work perfectly within the bios, and then when used in the kernel print nothing to the screen.

I am not sure of the cause of this, and have already tried to fix it. The print single character function works when I provide it with a hexidecimal value. Also, im not sure if anyone looking at this problem will need to see my code, if so I can post it.

Thanks for taking the time to read my post, and any advice would be greatly appreciated

Re:Preset Variable Problems

Posted: Fri Oct 21, 2005 11:08 pm
by AR
If the "assembler code" refers to an assembly file that is part of the kernel then you need to declare the variable/function as GLOBAL:

Code: Select all

; NASM Syntax
GLOBAL MyVar
MyVar: dd 6

# GAS Syntax
.global MyVar
MyVar: .long 6
If you are refering to the bootloader variables and the bootloader is not directly linked into the kernel then you will have to use runtime binding (either through proper linking or just knowing where in memory the variable is and reading it directly)

BIOS Functions don't work in protected mode, if you are still in real mode then the problem is most likely with something else if they work in the bootloader.