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