setup.s代码注释

1 !
2 ! setup.s (C) 1991 Linus Torvalds
3 !
4 ! setup.s is responsible for getting the system data from the BIOS,
5 ! and putting them into the appropriate places in system memory.
6 ! both setup.s and system has been loaded by the bootblock.
7 !
8 ! This code asks the bios for memory/disk/other parameters, and
9 ! puts them in a "safe" place: 0x90000-0x901FF, ie where the
10 ! boot-block used to be. It is then up to the protected mode
11 ! system to read them from there before the area is overwritten
12 ! for buffer-blocks.
!
! setup.s 负责从BIOS 中获取系统数据,并将这些数据放到系统内存的适当地方。
! 此时setup.s 和system 已经由bootsect 引导块加载到内存中。
!
! 这段代码询问bios 有关内存/磁盘/其它参数,并将这些参数放到一个
! “安全的”地方:0x90000-0x901FF,也即原来bootsect 代码块曾经在
! 的地方,然后在被缓冲块覆盖掉之前由保护模式的system 读取。
13 !
14
15 ! NOTE! These had better be the same as in bootsect.s!

! 以下这些参数最好和bootsect.s 中的相同!
16
17 INITSEG = 0x9000 ! we move boot here - out of the way ! 原来bootsect 所处的段。
18 SYSSEG = 0x1000 ! system loaded at 0x10000 (65536). ! system 在0x10000(64k)处。
19 SETUPSEG = 0x9020 ! this is the current segment ! 本程序所在的段地址。
20
21 .globl begtext, begdata, begbss, endtext, enddata, endbss
22 .text
23 begtext:
24 .data
25 begdata:
26 .bss
27 begbss:
28 .text
29
30 entry start
31 start:
32
33 ! ok, the read went well so we get current cursor position and save it for
34 ! posterity.
! ok,整个读磁盘过程都正常,现在将光标位置保存以备今后使用。
35
36 mov ax,#INITSEG ! this is done in bootsect already, but...
! 将ds 置成#INITSEG(0x9000)。这已经在bootsect 程序中
! 设置过,但是现在是setup 程序,Linus 觉得需要再重新
! 设置一下。
37 mov ds,ax
38 mov ah,#0x03 ! read cursor pos
! BIOS 中断0x10 的读光标功能号 ah = 0x03
! 输入:bh = 页号
! 返回:ch = 扫描开始线,cl = 扫描结束线,
! dh = 行号(0x00 是顶端),dl = 列号(0x00 是左边)。
39 xor bh,bh
40 int 0x10 ! save it in known place, con_init fetches
41 mov [0],dx ! it from 0x90000.
! 上两句是说将光标位置信息存放在0x90000 处,控制台
! 初始化时会来取。
42
43 ! Get memory size (extended mem, kB) ! 下面3 句取扩展内存的大小值(KB)。
! 是调用中断0x15,功能号ah = 0x88
! 返回:ax = 从0x100000(1M)处开始的扩展内存大小(KB)。
! 若出错则CF 置位,ax = 出错码。
44
45 mov ah,#0x88
46 int 0x15
47 mov [2],ax ! 将扩展内存数值存在0x90002 处(1 个字)。
48
49 ! Get video-card data: ! 下面这段用于取显示卡当前显示模式。
! 调用BIOS 中断0x10,功能号 ah = 0x0f
! 返回:ah = 字符列数,al = 显示模式,bh = 当前显示页。
! 0x90004(1 字)存放当前页,0x90006 显示模式,0x90007 字符列数。
50
51 mov ah,#0x0f

52 int 0x10
53 mov [4],bx ! bh = display page
54 mov [6],ax ! al = video mode, ah = window width
55
56 ! check for EGA/VGA and some config parameters ! 检查显示方式(EGA/VGA)并取参数。
! 调用BIOS 中断0x10,附加功能选择 -取方式信息
! 功能号:ah = 0x12,bl = 0x10
! 返回:bh = 显示状态
! (0x00 - 彩色模式,I/O 端口=0x3dX)
! (0x01 - 单色模式,I/O 端口=0x3bX)
! bl = 安装的显示内存
! (0x00 - 64k, 0x01 - 128k, 0x02 - 192k, 0x03 = 256k)
! cx = 显示卡特性参数(参见程序后的说明)。
57
58 mov ah,#0x12
59 mov bl,#0x10
60 int 0x10
61 mov [8],ax ! 0x90008 = ??
62 mov [10],bx ! 0x9000A = 安装的显示内存,0x9000B = 显示状态(彩色/单色)
63 mov [12],cx ! 0x9000C = 显示卡特性参数。
64
65 ! Get hd0 data ! 取第一个硬盘的信息(复制硬盘参数表)。
! 第1 个硬盘参数表的首地址竟然是中断向量0x41 的向量值!而第2 个硬盘
! 参数表紧接第1 个表的后面,中断向量0x46 的向量值也指向这第2 个硬盘
! 的参数表首址。表的长度是16 个字节(0x10)。
! 下面两段程序分别复制BIOS 有关两个硬盘的参数表,0x90080 处存放第1 个
! 硬盘的表,0x90090 处存放第2 个硬盘的表。
66
67 mov ax,#0x0000
68 mov ds,ax
69 lds si,[4*0x41] ! 取中断向量0x41 的值,也即hd0 参数表的地址

你可能感兴趣的:(video,IE,System,扩展,Parameters,磁盘)