OS learning note (loaded from the start sector)

zhaozj2021-02-16  47

This is a translated article, where is

Http://www.nondot.org/sabre/os/files/booting/bootsector.html

The start sector is always in the first TRACK of the first header in the disk. When the system starts (or restart), the BIOS first runs the parallel to system self-test (POST), initialize all of it. Data, then it will look for a valid startup area. First it will look for a floppy drive, then find a C drive (standing for one night: Generally, BIOS will not always be like this, but according to BIOS startup settings In order to find it). If you don't find the start area, BIOS will trigger an interruption of 18H, which will start ROM Basic on the ordinary PC (standing on one night: I don't know what this Basic is.

http://www.computerhope.com/jargon/r/rombasic.htm is explained here With early computer the ROM BASIC was a ROM interpreter that allowed users to run and create BASIC programs. Today's computers no longer include a BASIC ROM, However, Users Using IBM Compatible Computes Related To The Rom Basic. For Bios, the effective start sector is 0xAA55 in offset 0x510 (standing for one night Note: This is the flag, quite The 'MZ' of Bitmap 'BM', PE file,

Http://www.bitapf.org/licher/licher_os/doc_cn/node20.html This is said that the 0x55AA binary form is 101010110101010 If this has a bit error, it can be easily detected).

When the BIOS finds the start sector, it reads the area (total 512bytes) on the disk to the memory area of ​​0: 7C00, then the BIOS will drop to 0: 7C00 to execute, so that the code inside the sector Just achieved the right. At this time, all BIOS data area (40h: 0) and BIOS interrupts (10h-1ah) have completed initialization, and all memory areas are completely used, but there is no need to put them all Give 0.

Below is an example code of a start sector:

The following is the program code: Generic boot sector shell. Written by Chris Lattner 1995; Code Data Must Be Less Than 510 BYTES Long! _Text Segment Public Use16 Assume Cs: _Text, DS: _Text Org 0 throughrypoint: db 0eah; JMP Far SEG : OFS; CURRENTLY WE ARE AT 0: 7C00 DW Offset afterData, 7C0H; This Makes US Be AT 7C0: 0; PUT Any Data Here! AfterData: Push Cs Pop DS; Update DS To BE 7C0 INSTEAD OF 0; PUT CODE Here! JMP $; hang out ... org 510; make the file 512 bytes long dw 0aa55h; add the boot signature_text ends end

转载请注明原文地址:https://www.9cbs.com/read-19248.html

New Post(0)