▶ 书上第 10 章,主要讲了宏,引用了一个 16 位实地址的程序,从代码开始到运行
● 代码
1 ; main.asm 2 INCLUDE Macros.inc 3 IF IsDefined( RealMode ) 4 INCLUDE Irvine16.inc 5 ELSE 6 INCLUDE Irvine32.inc 7 ENDIF 8 9 .code 10 main PROC 11 Startup 12 IF IsDefined( RealMode ) 13 mWrite <"The program is running in 16-bit Real mode.",0dh,0ah> 14 ELSE 15 mWrite <"The program is running in 32-bit Protective mode.",0dh,0ah> 16 ENDIF 17 exit 18 main ENDP 19 20 END main
● 使用 MASM 来编译,需要文件 Irvine16.inc,Irvine16.lib,Macros.inc 在同一目录下。关键选项 -DRealMode=1。
1 REM make.bat 2 @echo off 3 REM +----configuration 4 SET INCLUDE="D:\Code\assembler\book" 5 SET LIB="D:\Code\assembler\book" 6 REM +-------------------- 7 8 REM 调用 ML.EXE 汇编代码文件 9 "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\ML.exe" /nologo -c -omf -Fl -Zi -DRealMode=1 main.asm 10 if errorlevel 1 goto terminate 11 12 REM 调用 LINK16.EXE 链接目标文件 13 D:\Code\assembler\book\LINK16 main,,NUL,Irvine16; 14 if errorlevel 1 goto terminate 15 16 :terminate 17 pause
● 在 DOSBOX 里运行(win10_x86-64不能直接运行 16位实地址程序)