Hi,
I'm new to this forum and I hope I'm posting according to the rules.
I tried finding an answer for this but couldn't see one.
In the real mode assembly bear bones:
http://wiki.osdev.org/Real_mode_assembly_bare_bones
there is a use of the call instruction, meaning it is using the stack.
However, in the original bare bones tutorial:
http://wiki.osdev.org/Bare_bones
It says that the esp points at anything and using it may cause harm. So why is it ok to use it in the first tutorial without setting it up first? Does it have something to do with GRUB being present in Bare bones?
Thanks!
Real mode bare bones and the stack
Re: Real mode bare bones and the stack
These two tutorials are fully unrelated and take place in two different environments (the real mode tutorial is basically a bootloader, while the regular bare bones tutorial is a multiboot kernel loaded by GRUB). Things are different in those two environments. You need to think critically.
It may well be a bug in the Real Mode Bare Bones tutorial that it doesn't set up its own stack pointer and trusts the BIOS to set up a stack.
It may well be a bug in the Real Mode Bare Bones tutorial that it doesn't set up its own stack pointer and trusts the BIOS to set up a stack.
-
- Member
- Posts: 5501
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Real mode bare bones and the stack
Indeed, that is a bug in the tutorial. The BIOS stack is not guaranteed to be large enough for anything but the default IRQ handlers. In particular, extended int 0x13 functions are likely to cause problems if the stack is too small.
Re: Real mode bare bones and the stack
Thanks!
Just to be sure I get it - both tutorials run in real mode. The difference is that on of them runs after the BIOS, which leaves the system in a certain state, while the other runs after GRUB, which leaves the system in an other state. Both of them have no guarantee regarding the stack state. Is this correct? Say I want to find out about how the BIOS leaves the system, how will I go about it?
Just to be sure I get it - both tutorials run in real mode. The difference is that on of them runs after the BIOS, which leaves the system in a certain state, while the other runs after GRUB, which leaves the system in an other state. Both of them have no guarantee regarding the stack state. Is this correct? Say I want to find out about how the BIOS leaves the system, how will I go about it?
-
- Member
- Posts: 5501
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Real mode bare bones and the stack
GRUB leaves the CPU in protected mode, not real mode.
The BIOS is much less predictable than GRUB, but most will leave the system in real mode with a small stack set up, the drive number for int 0x13 in DL, and CS:IP pointing to either 0000:7C00 or 07C0:0000.
The BIOS is much less predictable than GRUB, but most will leave the system in real mode with a small stack set up, the drive number for int 0x13 in DL, and CS:IP pointing to either 0000:7C00 or 07C0:0000.
Re: Real mode bare bones and the stack
Octocontrabass: The multiboot specification leaves the stack unspecified.
-
- Member
- Posts: 5501
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Real mode bare bones and the stack
Sortie: Yes, I forgot to mention that part. Proofreading is difficult from my phone.
GRUB leaves the system according to the multiboot specification. Multiboot doesn't specify how the stack should be set up, so GRUB doesn't set one up for you.
GRUB leaves the system according to the multiboot specification. Multiboot doesn't specify how the stack should be set up, so GRUB doesn't set one up for you.
Re: Real mode bare bones and the stack
Oh, got it. Thank you all!