# IBM PC BIOS 源代码重建笔记 作者:弗农·布鲁克斯 PC DOS Retro(https://sites.google.com/site/pcdosretro/) --- 本文通过扫描并转录IBM技术参考手册内的BIOS代码清单,完成了IBM PC、PC XT、PC AT以及PC XT 286 BIOS源代码的重建。这份具备历史研究价值的源代码在此公布,用于软件资料留存。 已完成重建的BIOS源代码如下: IBM PC 版本1 1981年04月21日 IBM PC 版本2 1981年10月19日 IBM PC 版本3 1982年10月27日 IBM PC XT 版本1 1982年11月08日(也适用于便携式PC) IBM PC XT 版本2 1986年01月10日 IBM PC XT 版本3 1986年05月09日 IBM PC AT 版本1 1984年01月10日 IBM PC AT 版本2 1985年06月10日 IBM PC AT 版本3 1985年11月15日(适用于PC AT 319型与339型主机) IBM PC XT 286 1986年04月21日 备注: - IBM PC BIOS 的全部3个版本以及IBM PC XT BIOS 第一版,均在英特尔开发机上使用英特尔 ASM86 汇编器编译生成。以上所有BIOS均为单一完整源码文件,BIOS程序大小8KB,存放地址为 F000:E000。 - IBM PC AT 版本1 BIOS 在DOS系统下使用 IBM MASM 1.0 汇编器编译。这是首款采用多源码文件结构的IBM BIOS。由于 IBM MASM 1.0 不支持80286处理器,项目配套宏文件(IAPX286.MAC)用于生成所需操作码。该版本BIOS也是首个拆分为两部分的BIOS:主BIOS代码存放于 F000:0000,兼容段(ORGS.ASM)存放于 F000:E000。项目额外新增 FILL.ASM 文件,用于定义主BIOS代码末尾到兼容段之间的内存区域,保障BIOS能够正常链接;该区域最初的实现方式目前暂无资料佐证。 - IBM PC AT 版本2、版本3 BIOS 以及 IBM PC XT 286 BIOS,均在DOS系统下使用 IBM MASM 2.0 汇编器编译。结构与PC AT 版本1 BIOS相近,但源码文件数量更少——部分源码文件进行了合并,同时代码做了一定整理优化。配套 IAPX286.INC 文件,用于生成 IBM MASM 2.0 不支持的80286保护模式操作码。FILL.ASM 文件作用和PC AT 版本1 BIOS一致,不过每个BIOS版本都配套独立的 FILL.ASM。 - IBM PC XT 版本2、版本3 BIOS 在DOS系统下使用 IBM MASM 2.0 汇编器编译。后期版本PC XT BIOS 重构了代码结构,与PC AT BIOS 架构对齐,采用多源码文件。和PC AT BIOS一致,代码拆分为两部分,但其兼容段位于 POST.ASM 文件内。同样依靠附加文件 FILL.ASM 划定主BIOS代码末尾至兼容段之间的内存区域。 - 以下代码存在于所有版本PC AT BIOS 和 PC XT 286 BIOS 中,但并未出现在官方发布的代码清单内。这段代码是通过 ORGS.ASM 内的公共符号与反汇编结果推导得出,目前该代码的作用尚不明确。 .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 - 存放于 F6000 地址的32KB ROM BASIC 代码,暂无源码可用,因其源代码从未对外发布。 - 高于4.0版本的MASM汇编器无法编译这份IBM BIOS源代码,源码使用了旧版语法结构与宏定义。 原文翻译自: IBM PC BIOS source code reconstruction notes by Vernon Brooks PC DOS Retro (https://sites.google.com/site/pcdosretro/) --- 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.