How do i jump to my second stage loader from my BootSector in real mode??
Ciao

note: i searched google, and nothing was found

just know where you loaded it (segment:offset) and jmp segment:offset ...Berserk wrote: How do i jump to my second stage loader from my BootSector in real mode??
seems you didn't searched very extensively ... 2 mins were enough to find a nicely commented 2-stages bootloader at http://www.dftech.cwc.net/osdev/Bootloader.htmlnote: i searched google, and nothing was found![]()
While it can be argued that it is not absolutely necessary, it is a very wise idea to set up the stack at some point in the boot loader, the earlier the better; otherwise it will be wherever the BIOS set it up, which could be anywhere in lower memory (I think that there is supposed a standard location for it, but of course no one ever follows the standards...). Most boot loaders reset SS and SP as soon as is feasible, usually together with resetting the code segment (with a far jump) and and the data segment (usually matching it to the CS). For example my first-stage boot loader begins:Berserk wrote: Hey,
thanx, i got it working. Now for a question:
Do i have to make a new stack when i jump to my Second Stage Loader??
Or do i have to do something with the Stack??
Code: Select all
;; constants
loader_base???equ 0x0000
%define loader_offset 0x7C00 ; cannot use EQU to give a value in an ORG statement
stage2_entry???equ 0x1000???; the segment:offset to load the second stage into
stage2_offset???equ 0x0000???
stack_seg???equ 0x9000
stack_top???equ 0xFFFF
;; *** additional EQUs, macroes and comments snipped for space
[bits 16]
[org loader_offset]
entry:
???jmp loader_base:start ; ensures that the CS is really at loader_base
start:
???cli
???mov ax, stack_seg
???mov ss, ax??????; and the stack at an arbitrarily high point past ES.
???mov ax, stack_top
???mov sp, ax ??????; put the stack pointer to the top of SS
???mov ax, cs
???mov ds, ax??????; set DS == CS
???sti??????; reset ints so BIOS calls can be used
Code: Select all
void ClearScreen(void)
{
char* VideoMemory = (char*)0xB8000; //Pointer to Video Memory
unsigned int variable = 0;
while(variable < (80 * 25 * 2))
{
VideoMemory[variable] = 0x20;
variable++;
VideoMemory[variable] = 0x07;
variable++;
}
}
Code: Select all
void PutPixel(unsigned int xAxis, unsigned int yAxis, unsigned char PixelColour)
{
unsigned char* VGA = (unsigned char*)0xA0000;
unsigned short offset = 320 * yAxis + xAxis;
VGA[offset] = PixelColour;
}