file-type

全面详解BIOS与DOS中断调用手册

ZIP文件

4星 · 超过85%的资源 | 下载需积分: 50 | 358KB | 更新于2025-05-31 | 128 浏览量 | 40 下载量 举报 收藏
download 立即下载
BIOS(基本输入输出系统)和DOS(磁盘操作系统)是早期个人电脑操作系统和硬件交互的主要途径。它们之间的重要桥梁是通过中断调用(interrupt calls),即软件可以通过中断向BIOS和DOS操作系统请求执行各种服务。本手册提供了一个汇编语言编程者的参考资料,详细介绍了如何使用BIOS和DOS中断。 ### BIOS中断 BIOS中断是一组预先定义好的程序,它们提供了硬件级别的操作接口,允许程序员直接与计算机硬件交流,而无需关心硬件的复杂细节。BIOS中断通常用INT指令和一个中断号来调用,每个中断号对应了一个特定的服务。 #### BIOS中断号 - INT 10h:视频服务中断,用于控制屏幕显示。 - INT 13h:磁盘服务中断,用于处理磁盘操作,比如读写扇区。 - INT 14h:串口通信中断,用于串行通信。 - INT 16h:键盘服务中断,用于读取键盘输入。 - INT 17h:打印服务中断,用于打印机控制。 - INT 19h:系统引导中断,用于启动计算机。 每种中断号下还有多种功能,例如INT 10h下有多个子功能用于设置光标位置、读取按键等。 ### DOS中断 DOS中断则是DOS操作系统提供的接口,也是通过INT指令调用,提供了文件操作、目录管理、内存管理等高级功能。与BIOS中断类似,每个DOS中断由一个中断号和多个功能子程序构成。 #### DOS中断号 - INT 20h到INT 2Fh:DOS内核中断,用于执行DOS系统功能。 - INT 21h:功能最丰富的DOS中断,提供了大量系统功能调用,包括文件操作、设备I/O、程序控制等。 INT 21h的一个常见调用形式是AH寄存器用于指定具体的功能,如: - AH = 01h:显示输入字符。 - AH = 02h:显示指定字符。 - AH = 09h:显示字符串。 - AH = 3Ch:创建或覆盖文件。 - AH = 3Dh:打开文件。 - AH = 40h:写文件。 - AH = 4Ch:退出程序。 ### 汇编语言与中断的使用 汇编语言是与硬件沟通的低级语言,对中断的使用是汇编编程中的一个重要部分。通过中断,汇编程序能够请求BIOS或DOS执行特定的操作,比如读取按键、显示文字、控制硬盘读写等。 例如,在汇编中使用INT 10h中断读取按键的代码段可能如下: ```assembly mov ah, 0 ; 功能号:设置光标位置 mov bh, 0 ; 页面号 mov dh, 10 ; 行号 mov dl, 20 ; 列号 int 10h ; 调用视频中断 ``` 上述代码将光标移动到第11行21列的位置。 在汇编中调用INT 21h中断创建文件的代码段可能如下: ```assembly mov ah, 3Ch ; 功能号:创建或覆盖文件 mov cx, 0 ; 文件属性(0表示普通文件) lea dx, filename ; 文件名的内存地址 int 21h ; 调用DOS中断 jc error ; 如果有错误则跳转至错误处理 mov fileHandle, ax ; 存储文件句柄 ``` 上述代码段尝试创建一个文件,如果文件创建成功,它的句柄将被存储在`fileHandle`变量中。 ### 学习汇编BIOS_DOS中断的意义 学习和掌握BIOS和DOS中断对于理解早期PC操作系统的运行机制、硬件通信以及编写高效的汇编语言程序至关重要。尽管现代操作系统已经不再直接使用这些中断,但它们仍然是操作系统底层设计和高级编程语言所依赖的底层基础。对于深入学习计算机科学、计算机架构和软件工程的学生和开发者而言,这部分知识可以提高他们对操作系统和硬件交互的深刻理解。

相关推荐

filetype
代码部分来自Google的重建IBMPC BIOS项目(https://sites.google.com/site/pcdosretro/ibmpcbios),其中的BIOS镜像(*.rom)可用于各种IBM PC模拟器,可按情况使用。源代码可以用masm编译,站内英文说明文件如下: IBM PC BIOS source code reconstruction This is a reconstruction of the IBM PC, PC XT, PC AT and PC XT 286 BIOS source code using scanning and transcription of the BIOS listings found in the IBM Technical Reference manuals. This historically relevant source code is presented here for software preservation. The following BIOS source code has been reconstructed: IBM PC version 1 04/21/81 IBM PC version 2 10/19/81 IBM PC version 3 10/27/82 IBM PC XT version 1 11/08/82 (also used on the Portable PC) IBM PC XT version 2 01/10/86 IBM PC XT version 3 05/09/86 IBM PC AT version 1 01/10/84 IBM PC AT version 2 06/10/85 IBM PC AT version 3 11/15/85 (used on the PC AT models 319 and 339) IBM PC XT 286 04/21/86 Notes: • All 3 versions of the IBM PC BIOS and the first version of the IBM PC XT BIOS were built using Intel ASM86 on an Intel development system. In each case the BIOS source code is a single large file and the BIOS code is 8KB which resides at F000:E000 • The IBM PC AT version 1 BIOS was built using IBM MASM 1.0 on DOS. This is the first IBM BIOS which uses multiple source files. Since IBM MASM 1.0 did not support the 80286 there is a macro file (IAPX286.MAC) which is used to generate the necessary opcodes. This is also the first BIOS to be split into two parts: the main BIOS code resides at F000:0000 and the compatibility section (ORGS.ASM) resides at F000:E000. An additional file FILL.ASM has been added to define the area between the end of the main BIOS code and the compatibility section to allow the BIOS to be linked properly. It is currently unknown how this was originally handled. • The IBM PC AT version 2 and 3 BIOS and the IBM PC XT 286 BIOS were built using IBM MASM 2.0 on DOS. These are similar to the PC AT version 1 BIOS but there are fewer source files as some files were combined and a bit of cleanup was done. IAPX286.INC is used to generate the protected-mode 80286 opcodes which IBM MASM 2.0 did not support. FILL.ASM serves the same purpose as it does for the PC AT version 1 BIOS though in each case the file is specific to the particular BIOS being built. • The IBM PC XT version 2 and 3 BIOS were built using IBM MASM 2.0 on DOS. The later PC XT BIOS code was restructured to be similar to the PC AT BIOS code so there are multiple source files. Like the PC AT BIOS the code is split into two parts though the compatibility section is in the file POST.ASM. Again the additional file FILL.ASM is used to define the area between the end of the main BIOS code and the compatibility section. • The following code is present in all versions of the PC AT BIOS and the PC XT 286 BIOS but does not appear in the published listings. It is inferred from the public symbols in ORGS.ASM and code disassembly. It is unknown what purpose this code serves. .XLIST ;;- ORG 0FF5AH ORG 01F5AH HRD PROC FAR CALL DISK_SETUP RET HRD ENDP FLOPPY PROC FAR CALL DSKETTE_SETUP RET FLOPPY ENDP SEEKS_1 PROC FAR CALL SEEK RET SEEKS_1 ENDP TUTOR: JMP K16 .LIST • In all cases the 32KB ROM BASIC code which resides at F6000 is not available as its source code was never published. • Versions of MASM later than 4.0 cannot be used to build the IBM BIOS source code since older constructs and macros are used. More information about functionality changes in the IBM PC BIOS code is listed here: IBM PC BIOS version history
sm419314
  • 粉丝: 0
上传资源 快速赚钱