?? 1_3 boot sector - 《自己動手寫操作系統》 -2.htm
字號:
<DIV class=col1>
<DIV class=lineBlue></DIV><!-- title -->
<DIV class=arcTitle>
<H1><A href="http://book.csdn.net/bookfiles/88">自己動手寫操作系統 </A></H1>
<DIV style="FONT-SIZE: 15px; TEXT-ALIGN: center"><A
href="http://book.csdn.net/bookfiles/88/100882494.shtml">1.3 Boot Sector
</A></DIV>
<DIV style="FONT-SIZE: 15px; TEXT-ALIGN: center"><A class=url
href="http://book.csdn.net/">http://book.csdn.net/</A> 2006-8-11 18:35:00 </DIV>
<DIV class=clear></DIV>
<DIV
style="BORDER-RIGHT: #0b5f98 1px solid; BORDER-TOP: #0b5f98 1px solid; MARGIN: 0px auto; BORDER-LEFT: #0b5f98 1px solid; WIDTH: 700px; BORDER-BOTTOM: #0b5f98 1px solid">
<DIV
style="PADDING-RIGHT: 1px; PADDING-LEFT: 1px; FLOAT: left; PADDING-BOTTOM: 1px; WIDTH: 16px; COLOR: white; PADDING-TOP: 1px; BACKGROUND-COLOR: #0b5f98">圖書導讀
</DIV>
<DIV
style="PADDING-LEFT: 2px; FLOAT: right; WIDTH: 670px; LINE-HEIGHT: 16pt; TEXT-ALIGN: left"><!--導讀-->
<H1 id=divCurrentNode
style="PADDING-LEFT: 2px; FONT-SIZE: 12px; WIDTH: 100%; COLOR: #b83507; TEXT-ALIGN: left">當前章節:<A
href="http://book.csdn.net/bookfiles/88/100882494.shtml"><FONT color=red>1.3
Boot Sector</FONT></A></H1>
<DIV id=divRelateNode style="PADDING-LEFT: 2px">
<DIV style="FLOAT: left; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882492.shtml">1.1 準備工作</A></DIV>
<DIV style="FLOAT: right; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882493.shtml">1.2
10分鐘完成的操作系統</A></DIV>
<DIV style="FLOAT: left; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882495.shtml">1.4 代碼解釋</A></DIV>
<DIV style="FLOAT: right; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882496.shtml">1.5 水面下的冰山</A></DIV>
<DIV style="FLOAT: left; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882497.shtml">1.6 回顧</A></DIV>
<DIV style="FLOAT: right; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882498.shtml">2.1 虛擬計算機(Virtual
PC)</A></DIV></DIV></DIV></DIV>
<DIV class=clear></DIV></DIV><!-- main -->
<DIV id=main>
<DIV id=text>
<DIV id=csdn_zhaig_ad_yahoo_2></DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><FONT
size=2><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">你可能還沒有從剛剛的興奮中走出來,可是我不得不告訴你,實際上,你剛剛所完成的并不是一個完整的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">OS</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,而僅僅是一個最最簡單的引導扇區(</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Boot Sector</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">)。然而不管我們完成的是什么,至少,它是直接在裸機上運行的,不依賴于任何其他軟件,所以,這和我們平時所編寫的應用軟件有本質的區別。它不是操作系統,但已經具備了操作系統的一個特性。</SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><FONT
size=2><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我們知道,當計算機電源被打開時,它會先進行加電自檢(</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">POST</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">),然后尋找啟動盤,如果是選擇從軟盤啟動,計算機就會檢查軟盤的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">0</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">面</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">0</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">磁道</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">1</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">扇區,如果發現它以</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">0xAA55</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">(假如我們把此扇區看做一個字符數組</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">sector[]</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的話,那么此結束標志相當于</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">sector[510]=0x55</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,且</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">sector[511]=0xAA</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">)結束,則</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">BIOS</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">認為它是一個引導扇區,也就是我們說的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Boot Sector</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。當然,一個正確的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Boot Sector</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">除了以</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">0xAA55</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">結束之外,還應該包含一段少于</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">512B</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的執行碼。</SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><FONT
size=2><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">好了,一旦</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">BIOS</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">發現了</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Boot Sector</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,就會將這</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">512B</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的內容裝載到內存的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">0000:<ST1:CHMETCNV w:st="on" tcsc="0"
numbertype="1" negative="False" hasspace="False" sourcevalue="7"
unitname="C">7c</ST1:CHMETCNV>00</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">處,然后跳轉到</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">0000:<ST1:CHMETCNV w:st="on" tcsc="0"
numbertype="1" negative="False" hasspace="False" sourcevalue="7"
unitname="C">7c</ST1:CHMETCNV>00</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">處將控制權徹底交給這段引導代碼。到此為止,計算機不再由</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">BIOS</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中固有的程序來控制,而變成由操作系統的一部分來控制。</SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 20pt"><FONT
size=2><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">現在,你可能明白了為什么在那段代碼的第一行會出現</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">org <ST1:CHMETCNV w:st="on" tcsc="0"
numbertype="1" negative="False" hasspace="False" sourcevalue="7"
unitname="C">07c</ST1:CHMETCNV>00</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">這樣的代碼。沒錯,這行代碼就是告訴編譯器,將來我們的這段程序要被加載到內存偏移地址</SPAN><FONT
face="Times New Roman"><ST1:CHMETCNV w:st="on" tcsc="0" numbertype="1"
negative="False" hasspace="False" sourcevalue="7" unitname="C"><SPAN
lang=EN-US>7c</SPAN></ST1:CHMETCNV><SPAN lang=EN-US>00</SPAN></FONT><SPAN
style="FONT-FAMILY: 宋體; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">處。好了,下面將對代碼的其他部分進行詳細解釋。</SPAN></FONT><SPAN
lang=EN-US style="COLOR: blue"><O:P></O:P></SPAN></P></DIV><!-- page -->
<DIV class=page style="TEXT-ALIGN: center"><A
href="http://book.csdn.net/bookfiles/88/100882493.shtml">上一頁</A> <A
href="http://book.csdn.net/bookfiles/88/index.html">首頁</A> <A
href="http://book.csdn.net/bookfiles/88/100882495.shtml">下一頁</A> </DIV>
<DIV
style="BORDER-RIGHT: #0b5f98 1px solid; BORDER-TOP: #0b5f98 1px solid; MARGIN: 0px auto; BORDER-LEFT: #0b5f98 1px solid; WIDTH: 700px; BORDER-BOTTOM: #0b5f98 1px solid">
<DIV
style="PADDING-RIGHT: 1px; PADDING-LEFT: 1px; FLOAT: left; PADDING-BOTTOM: 1px; WIDTH: 16px; COLOR: white; PADDING-TOP: 1px; BACKGROUND-COLOR: #0b5f98">圖書導讀
</DIV>
<DIV
style="PADDING-LEFT: 2px; FLOAT: right; WIDTH: 670px; LINE-HEIGHT: 16pt; TEXT-ALIGN: left"><!--導讀-->
<H1 id=divCurrentNode2
style="PADDING-LEFT: 2px; FONT-SIZE: 12px; WIDTH: 100%; COLOR: #b83507; TEXT-ALIGN: left">當前章節:<A
href="http://book.csdn.net/bookfiles/88/100882494.shtml"><FONT color=red>1.3
Boot Sector</FONT></A></H1>
<DIV id=divRealteNod2 style="PADDING-LEFT: 2px">
<DIV style="FLOAT: left; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882492.shtml">1.1 準備工作</A></DIV>
<DIV style="FLOAT: right; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882493.shtml">1.2
10分鐘完成的操作系統</A></DIV>
<DIV style="FLOAT: left; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882495.shtml">1.4 代碼解釋</A></DIV>
<DIV style="FLOAT: right; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882496.shtml">1.5 水面下的冰山</A></DIV>
<DIV style="FLOAT: left; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882497.shtml">1.6 回顧</A></DIV>
<DIV style="FLOAT: right; WIDTH: 49%">·<A
href="http://book.csdn.net/bookfiles/88/100882498.shtml">2.1 虛擬計算機(Virtual
PC)</A></DIV></DIV></DIV></DIV>
<DIV class=clear> </DIV></DIV>
<DIV class=todayCommend style="WIDTH: 100%">
<DIV class=title>
<H5>同類圖書推薦</H5></DIV>
<DIV class="blank6 clear"></DIV>
<DIV class=content id=divSameSort>
<LI style="FLOAT: left; WIDTH: 20%"><A title=Linux應用程序開發(Java版)
href="http://book.csdn.net/bookfiles/222/"><IMG height=112
src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/TS00123568__.jpg" width=80
border=0></A>
<P><A title=Linux應用程序開發(Java版)
href="http://book.csdn.net/bookfiles/222/">Linux應用程序開發(Ja...</A></P></LI>
<LI style="FLOAT: left; WIDTH: 20%"><A title="Linux C編程"
href="http://book.csdn.net/bookfiles/54/"><IMG height=112
src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/smallTS_730211369001top.jpg"
width=80 border=0></A>
<P><A title="Linux C編程" href="http://book.csdn.net/bookfiles/54/">Linux
C編程</A></P></LI>
<LI style="FLOAT: left; WIDTH: 20%"><A title=UNIX編程藝術
href="http://book.csdn.net/bookfiles/34/"><IMG height=112
src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/TS0091589__.jpg" width=80
border=0></A>
<P><A title=UNIX編程藝術
href="http://book.csdn.net/bookfiles/34/">UNIX編程藝術</A></P></LI>
<LI style="FLOAT: left; WIDTH: 20%"><A title="Solaris 10紅寶書"
href="http://book.csdn.net/bookfiles/19/"><IMG height=112
src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/TS00105905__.jpg" width=80
border=0></A>
<P><A title="Solaris 10紅寶書" href="http://book.csdn.net/bookfiles/19/">Solaris
10紅寶書</A></P></LI>
<LI style="FLOAT: left; WIDTH: 20%"><A title=Linux內核分析及編程
href="http://book.csdn.net/bookfiles/12/"><IMG height=112
src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/TS0079168__.jpg" width=80
border=0></A>
<P><A title=Linux內核分析及編程
href="http://book.csdn.net/bookfiles/12/">Linux內核分析及編程</A></P></LI></DIV></DIV><!-- 評論 -->
<DIV class=clear></DIV>
<DIV class=todayCommend style="WIDTH: 100%">
<DIV class=title>
<H5>網友熱評</H5></DIV>
<DIV class="blank6 clear"></DIV>
<DIV class=content style="OVERFLOW: scroll; WIDTH: 99%; TEXT-ALIGN: left">
<SCRIPT
src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/NewsCsdnNetJsReferences.aspx"
type=text/javascript></SCRIPT>
</DIV></DIV><!-- 今日推薦 -->
<DIV class=clear></DIV>
<DIV id=tagad style="TEXT-ALIGN: left">
<DIV id=csdn_zhaig_ad_yahoo style="WIDTH: 99%"></DIV>
<SCRIPT type=text/javascript>
ad_width=468;
ad_height=60;
adcss=2;
unionuser=22;
ad_type='j';
count=3;
</SCRIPT>
<SCRIPT src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/showads.js"
type=text/javascript></SCRIPT>
<SCRIPT src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/tag.js"
type=text/javascript></SCRIPT>
</DIV></DIV><!-- 頁腳 -->
<DIV id=foot><IMG height=0 alt=""
src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/readbook.aspx" width=0> </DIV>
<STYLE>#CFBig {
CLEAR: both; FONT-SIZE: 12px; MARGIN: auto; WIDTH: 770px; FONT-FAMILY: Tahoma, sans-serif; TEXT-ALIGN: center
}
#CFBig #CFContent {
MARGIN: auto; WIDTH: 500px; TEXT-ALIGN: center
}
#CFBig #CFContent P {
MARGIN: 2px
}
#CFBig HR {
COLOR: #4682b4; HEIGHT: 1px
}
#CFBig #CFBiaoShi {
FLOAT: right; WIDTH: 40px
}
#CFBig A:link {
COLOR: #000; TEXT-DECORATION: none
}
#CFBig A:visited {
COLOR: #000; TEXT-DECORATION: none
}
#CFBig A:hover {
COLOR: #369; TEXT-DECORATION: none
}
#CFBig A:active {
COLOR: #000; TEXT-DECORATION: none
}
</STYLE>
<!-- 頁腳 -->
<DIV style="TEXT-ALIGN: center">
<DIV id=CFBig>
<HR>
<DIV id=CFContent>
<DIV id=CFBiaoShi><A
href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202001032100010"><IMG
height=48 alt="" src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/BiaoShi.gif"
width=40 border=0></A> </DIV>
<P><A href="http://www.csdn.net/intro/intro.asp?id=2">網站簡介</A>-<A
href="http://www.csdn.net/intro/intro.asp?id=5">廣告服務</A>-<A
href="http://www.csdn.net/map/map.shtm">網站地圖</A>-<A
href="http://www.csdn.net/help/help.asp">幫助</A>-<A
href="http://www.csdn.net/intro/intro.asp?id=9">聯系方式</A>-<A
href="http://job.csdn.net/Jobs/f9c75c9f2ad14404a604669b757b9ed0/viewcompany.aspx">誠聘英才</A>-<A
href="http://www.csdn.net/english/">English</A>-<A
href="javascript:navigate('mai'%20+%20'lto:'%20+%20'webm'%20+%20'aster@c'%20+%20'sdn.n'+'et?subject=向CSDN報告問題')">問題報告</A></P>
<P>北京百聯美達美數碼科技有限公司 版權所有 京 ICP 證 020026 號</P>
<P>Copyright © 2000-2006, CSDN.NET, All Rights Reserved</P></DIV>
<HR>
</DIV></DIV>
<SCRIPT type=text/javascript>document.write("<img src=http://counter.csdn.net/pv.aspx?id=115 border=0 width=0 height=0>");</SCRIPT>
<SCRIPT language=JavaScript
src="1_3 Boot Sector - 《自己動手寫操作系統》 -2.files/counter.js"></SCRIPT>
<!-- /頁腳 --></DIV></BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -