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

FreeBSD啟動扇區(qū)代碼分析( 五 )


# 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鍵,同時檢查當前等待是否超時,如果有用戶按鍵則跳轉(zhuǎn)到main.11,如果超時時間不到則繼續(xù)等待 。#
# If timed out or defaulting, come here.
#
main.9:
movb _OPT(%bp),%al # Load default
jmp main.12 # Join common code超時時間到,此時表示用戶使用缺省分區(qū)啟動,把缺省的啟動分區(qū)號置入al中,然后跳轉(zhuǎn)到main.12 。#
# User's last try was bad, beep in displeasure.
# Since nothing was printed, just continue on as if the user
# hadn't done anything. This gives the effect of the user getting a beep
# for all bad keystrokes but no action until either the timeout
# occurs or the user hits a good key.
#
main.10:
movb $0x7,%al # Signal
callw putchr # error用戶輸入錯誤,只是響鈴提示,其他什么也不發(fā)生 。#
# Get the keystroke.
#
main.11:
xorb %ah,%ah # BIOS: Get
int $0x16 # keypress
movb %ah,%al # Scan code用戶按下了一個鍵,把鍵值掃描碼放到al中 。#
# If it's CR act as if timed out.
#
cmpb $KEY_ENTER,%al # Enter pressed?
je main.9 # Yes如果用戶按下“Enter鍵,和超時等同處理,這樣,就啟動缺省的boot分區(qū) 。#
# Otherwise check if legal
# If not ask again.
#
subb $KEY_F1,%al # Less F1 scan code
cmpb $0x4,%al # F1..F5?
jna main.12 # Yes
subb $(KEY_1 - KEY_F1),%al # Less #1 scan code
cmpb $0x4,%al # #1..#5?
ja main.10 # No如果是除“Enter鍵外其他的鍵,則檢查是不是F1...F5鍵,如果不是,表示輸入不合法,跳回到main.10處理 。#
# We have a selection.
# but if it's a bad selection go back to complain.
# The bits in MNUOPT were set when the options were printed.
# Anything not printed is not an option.
#
main.12:
cbtw # Option
btw %ax,_MNUOPT(%bp)# enabled?
jnc main.10 # No如果是F1...F5鍵,則檢查是否在我們提示的范圍內(nèi),其中,_MNUOPT(%bp)的相應bit位為1,表示是一個合法的選項,如果不是,跳回到 main.10處理 。#
# Save the info in the original tables
# for rewriting to the disk.
#
movb %al,_OPT(%bp) # Save option把我們按下的F1...F5鍵保存到_OPT(%bp)位置 。movw $FAKE,%si # Partition for write
movb (%si),%dl # Drive number把原來的啟動分區(qū)代碼取回到dl中 。movw %si,%bx # Partition for read
cmpb $0x4,%al # F5 pressed?
pushf # Save
je main.13 # Yes如果我們按下的是F5鍵則直接跳轉(zhuǎn)到main.13處理 。shlb $0x4,%al # Point to
addw $partbl,%ax # selected
xchgw %bx,%ax# partition
movb $0x80,(%bx) # Flag active上面,我們從按鍵Fx選擇中得到圖(三)中的我們選擇的四個分區(qū)信息中的某一分區(qū)信息,上面計算出的bx為我們選擇的分區(qū)信息的首地址,我們把此選擇到的分區(qū)信息的第一個個字節(jié)置為0x80表示它是當前的活動分區(qū) 。#
# If not asked to do a write-back (flags 0x40) don't do one.
#
main.13:
pushw %bx # Save
testb $0x40,_FLAGS(%bp) # No updates?
jnz main.14 # Yes
movw $start,%bx # Data to write
movb $0x3,%ah # Write sector
callw intx13 # to disk檢查回寫標志_FLAGS(%bp)的bit位0x40為,如果設(shè)置的是可回寫,則把當前選擇到的boot分區(qū)作為下次缺省的啟動分區(qū) 。main.14:
popw %si # Restore
popf # Restore
#
# If going to next drive, replace drive with selected one.
# Remember to un-ascii it. Hey 0x80 is already set, cool!

推薦閱讀