日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

啟動(dòng)扇區(qū)代碼分析 FreeBSD 5.2.1 boot0( 五 )


一個(gè)分區(qū)信息(加16字節(jié))入口 。循環(huán)直到255字節(jié)邊界 。

#
# Passed a 256 byte boundary..
# table is finished.
# Add one to the drive number and check it is valid,
#
popw %ax # Drive number
subb $0x80-0x1,%al # Does next
cmpb NHRDRV,%al # drive exist? (from BIOS?)
jb main.6 # Yes
“popw %ax”把上面壓入堆棧的bx(當(dāng)前的啟動(dòng)扇區(qū))值彈出到ax中 。例如,如果計(jì)算機(jī)是從軟盤(pán)
啟動(dòng)的則dl=0,若是從IDE的C、D盤(pán)啟動(dòng)的則dl分別為 0x80和0x81 。然而,F(xiàn)reeBSD的Boot Manerger不能夠
安裝到軟盤(pán)上,所以,dl只能為0x80、0x81,0x82...等 。
在計(jì)算機(jī)的BIOS地址0:0x475處存放的是計(jì)算機(jī)的硬盤(pán)的數(shù)目,“subb $0x80-0x1,%al”一句等于“sub
$0x79,%al”,例如,即當(dāng)前驅(qū)動(dòng)器如果是C盤(pán),則al的值是ox80-0x79=1,然后再與計(jì)算機(jī)的硬盤(pán)的數(shù)目比
較,如果當(dāng)前所在硬盤(pán)不是最后一個(gè)硬盤(pán),則直接跳轉(zhuǎn)到main.6 。如果當(dāng)前所在硬盤(pán)是最后一個(gè)硬盤(pán),則繼
續(xù)執(zhí)行 。

# If not then if there is only one drive,
# Don"t display drive as an option.
#
decw %ax # Already drive 0?
jz main.7 # Yes
如果只有一個(gè)硬盤(pán),則直接跳轉(zhuǎn)到main.7,這樣,本計(jì)算機(jī)只有一個(gè)硬盤(pán),所以不用顯示其他
磁盤(pán)相關(guān)的提示 。

# If it was illegal or we cycled through them,
# then go back to drive 0.
#
xorb %al,%al # Drive 0

下面的內(nèi)容表示多于一個(gè)磁盤(pán)的情況 。此時(shí)“al”清0,與磁盤(pán)列舉相關(guān) 。
#
# Whatever drive we selected, make it an ascii digit and save it back
# to the "next drive" location in the loaded block in case we
# want to save it for next time.
# This also is part of the printed drive string so add 0x80 to indicate
# end of string.
#
main.6:
addb $"0"|0x80,%al # Save next
movb %al,_NXTDRV(%bp) # drive number
movw $drive,%di # Display
callw putx # item
首先,在_NXTDR(%bp)處置入“0字符高位置1”的字符,以代表第二個(gè)驅(qū)動(dòng)器,
然后在屏幕上顯示“Fx Drive”,表示更換另外的磁盤(pán)啟動(dòng) 。注意,在調(diào)用
putx之前,di中保存的是下面字串“Drive ”的首地址 。dl中存放的是當(dāng)前
遍歷的到的可啟動(dòng)的或者合法的分區(qū)類(lèi)型遞增序數(shù),al與dl是不同的,al是ASCII碼,
dl是“Fx”中的x值 。

#
# Now that we"ve printed the drive (if we needed to), display a prompt.
# Get ready for the input byt noting the time.
#
main.7:
movw $prompt,%si # Display
callw putstr # prompt
movb _OPT(%bp),%dl # Display
decw %si # default
callw putkey # key
xorb %ah,%ah # BIOS: Get
int $0x1a # system time
movw %dx,%di # Ticks when
addw _TICKS(%bp),%di # timeout
上面的代碼首先在屏幕上打印出字符串“Default: ”,缺省啟動(dòng)的磁 盤(pán)號(hào)放在
“_OPT(%bp)”中,這里有個(gè)小小的技巧,在執(zhí)行“decw %si”和“callw putkey”
兩句后屏幕會(huì)顯示“Fx”,x是_OPT(%bp)的ASCII 。

然后取得當(dāng)前的tickes放到%di中,等待用戶按鍵超時(shí)的時(shí)間從_TICKS(%bp)中取出,
加到當(dāng)前的tickes即是最后超時(shí)時(shí)間到的tickes 。

#
# Busy loop, looking for keystrokes but
# keeping one eye on the time.
#
main.8:
movb $0x1,%ah # BIOS: Check
int $0x16 # for keypress
jnz main.11 # Have one
xorb %ah,%ah # BIOS: Get
int $0x1a # system time
cmpw %di,%dx # Timeout?
jb main.8 # No
等待用戶按下“Fx”鍵,同時(shí)檢查當(dāng)前等待是否超時(shí),如果有用戶按鍵則跳轉(zhuǎn)到main.11,
如果超時(shí)時(shí)間不到則繼續(xù)等待 。

#
# If timed out or defaulting, come here.
#
main.9:
movb _OPT(%bp),%al # Load default
jmp main.12 # Join common code
超時(shí)時(shí)間到,此時(shí)表示用戶使用缺省分區(qū)啟動(dòng),把缺省的啟動(dòng)分區(qū)號(hào)置入al中,然后跳轉(zhuǎn)
到main.12 。

#

推薦閱讀