please help me understand some basic booting basics
please help me understand some basic booting basics
hello i am having problems with making a basic bootloader but at this basic stage i need help
OK first the BIOS checks for boot sector in bootable device and then checks for first 512 bytes for any boot signature and then the BIOS loads that valid boot sector 512 code to memory(0000:7c00).And then what???
does CPU start executing from 0000:7c00 or 0000:0000 cause why do we use org 0000:7c00 in our code after BIOS loads into memory.
and why use times 510-($-$$) db 0 we say by this that we fill 512-2 bytes with 0's(including boot signature in the code)
then what would happen to remaining code then wouldn't it be 0'ed out.
please help me i keep on reading about this information at different places but i can't understand!!!!
OK first the BIOS checks for boot sector in bootable device and then checks for first 512 bytes for any boot signature and then the BIOS loads that valid boot sector 512 code to memory(0000:7c00).And then what???
does CPU start executing from 0000:7c00 or 0000:0000 cause why do we use org 0000:7c00 in our code after BIOS loads into memory.
and why use times 510-($-$$) db 0 we say by this that we fill 512-2 bytes with 0's(including boot signature in the code)
then what would happen to remaining code then wouldn't it be 0'ed out.
please help me i keep on reading about this information at different places but i can't understand!!!!
- DavidCooper
- Member
- Posts: 1150
- Joined: Wed Oct 27, 2010 4:53 pm
- Location: Scotland
Re: please help me understand some basic booting basics
The first of those locations - it can't run code at the bottom of memory because the interrupt vectors live there. So, the code in your boot sector is put in memory at 7C00 and then that code is run.wenn32 wrote:OK first the BIOS checks for boot sector in bootable device and then checks for first 512 bytes for any boot signature and then the BIOS loads that valid boot sector 512 code to memory(0000:7c00).And then what???
does CPU start executing from 0000:7c00 or 0000:0000 cause why do we use org 0000:7c00 in our code after BIOS loads into memory.
I don't understand what that's about, so I'll leave it to someone else to answer.and why use times 510-($-$$) db 0 we say by this that we fill 512-2 bytes with 0's(including boot signature in the code)
then what would happen to remaining code then wouldn't it be 0'ed out.
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming
Re: please help me understand some basic booting basics
does BIOS initiate the cpu to run at 7C00??then why do we use org in our code????
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: please help me understand some basic booting basics
The "org 0x7C00" is only for the assembler's information. The BIOS knows nothing about that "org" statement: it always loads at 0x7C00 and executes at 0x7C00. The assembler needs to know that the executable will end up at 0x7C00 to give the proper values to the labels.
The zeroing thing only zeroes out the bytes after the end of the code (up to the last two bytes of the bootsector). It isn't strictly necessary to zero that area out, but it is necessary to have that statement, because it allows you to put the boot signature at the end of the bootsector.
The zeroing thing only zeroes out the bytes after the end of the code (up to the last two bytes of the bootsector). It isn't strictly necessary to zero that area out, but it is necessary to have that statement, because it allows you to put the boot signature at the end of the bootsector.
Re: please help me understand some basic booting basics
so its like
1 byte "some code"
2 byte "some code"
3 byte "some code"
4 byte "some code"
5 byte "some code"
6 byte "some code"
7 byte "some code"
8 byte "some code"
9 byte "last part of code"
10 byte "0 value is added"
11 byte "0 value is added"
12 byte "0 value is added"
13 byte "0 value is added"
-
-
-
-
-
-
-
510 byte "0 value is added"
511 byte "0x55"
512 byte "0xAA"
am i right??
thanks by the way for the "org" it really cleared my mind thanks!!
1 byte "some code"
2 byte "some code"
3 byte "some code"
4 byte "some code"
5 byte "some code"
6 byte "some code"
7 byte "some code"
8 byte "some code"
9 byte "last part of code"
10 byte "0 value is added"
11 byte "0 value is added"
12 byte "0 value is added"
13 byte "0 value is added"
-
-
-
-
-
-
-
510 byte "0 value is added"
511 byte "0x55"
512 byte "0xAA"
am i right??
thanks by the way for the "org" it really cleared my mind thanks!!
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: please help me understand some basic booting basics
Yes, that's how it works. (Although you probably have more than 9 bytes of code )
Re: please help me understand some basic booting basics
yeah but thanks though!
hey can you tell how make this work
when i execute it shows me windows error i know BIOS INT won't work in 32 bit then how can i print character??
hey can you tell how make this work
Code: Select all
[section .text]
global _main
_main:
xor eax,eax
mov ah,02h
int 0x10
mov eax,0
ret
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
Re: please help me understand some basic booting basics
This is not relevant to the forum, if you're interested in programming user mode applications for Windows, you should look elsewhere.wenn32 wrote:when i execute it shows me windows error i know BIOS INT won't work in 32 bit then how can i print character??
Humouring you, Windows has its own system call interface.. I don't know if this has been officially published, but unofficial lists exist.
Generally people would call Windows API functions instead, how this is done exactly depends on the assembler.
Re: please help me understand some basic booting basics
sorry! so i can't directly call BIOS INT.
thanks that's all!
thanks that's all!
Re: please help me understand some basic booting basics
Are you sure ?wenn32 wrote:thanks by the way for the "org" it really cleared my mind thanks!!
There's something interesting called INSTRUCTION POINTER. Learn about it to make things more transparent.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !