DOS功能调用与BIOS中断详解

4星 · 超过85%的资源 需积分: 32 26 下载量 151 浏览量 更新于2024-10-02 收藏 291KB DOC 举报
"这篇文档是关于汇编语言中BIOS(基本输入输出系统)和DOS(磁盘操作系统)的功能调用大全,包含了详细的调用列表和解释,旨在帮助程序员理解和使用这些低级别的系统调用进行程序开发。" 在早期的个人计算机时代,汇编语言是与硬件交互的主要方式之一,而BIOS和DOS提供了接口,允许程序员通过特定的中断调用来实现对硬件的操作。以下是对这两个主题的详细说明: 1. **DOS软中断**: - **INT 20H**:程序正常退出,它会将当前程序段寄存器CS设置为程序启动时的PSP(程序服务块)段地址,以结束程序运行。 - **INT 21H**:系统功能调用,这是DOS提供的核心功能接口,通过设置AH寄存器中的功能号来执行不同的任务,如读写文件、控制设备等。 - **INT 22H**:程序结束处理,通常用于异常退出。 - **INT 23H**:Ctrl-Break处理,当用户按下Ctrl-Break组合键时,此中断被调用,AL寄存器设置为0表示忽略中断。 - **INT 24H**:严重错误处理,如磁盘读写错误,AL寄存器返回错误处理选项,如重试或终止程序。 - **INT 25H/26H/27H**:分别对应绝对磁盘读、写和驻留退出功能,用于磁盘I/O操作。 2. **DOS功能调用**: - 功能号由AH寄存器提供,其他入口参数根据具体功能设置。例如: - **00H**:程序终止,结束程序并返回PSP段地址。 - **01H**:键盘输入字符,读取用户输入到AL寄存器。 - **02H**:显示输出,将DL寄存器中的字符送到显示器。 - **09H**:显示字符串,将DS:DX指向的缓冲区中的字符串输出到屏幕。 - **0AH**:输入字符串,从用户处接收字符串并存储到DS:DX指定的缓冲区。 - 其他功能调用如串行设备I/O、打印输出、检查标准输入状态等,提供了丰富的I/O操作能力。 这些调用对于编写DOS时期的程序至关重要,虽然现在大部分系统已经不再直接使用DOS,但在理解操作系统原理、学习底层编程或者处理遗留系统问题时,这些知识仍然具有价值。熟悉这些调用能帮助开发者更好地理解计算机硬件与软件之间的交互,并在需要时编写兼容老系统的代码。
2018-02-20 上传
代码部分来自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