ID Number: Q39519
4.00 5.00 5.10
MS-DOS
Summary:
By using assembler symbols, macros, and conditional-assembly,
assembling a file to a COM or EXE file is easy. The following is the
solution:
ifdef COM
ending macro text
end start
endm
else
ending macro text
end
endm
endif
_text segment 'code'
assume cs:_text
start: mov ax, 08000h
mov ds, ax
...
_text ends
ending
Use MASM /DCOM /MX foo.asm for assembling into a COM file. Or use
MASM /MX foo.asm for EXE files.
More Information:
This example assembles code depending on whether the assembler symbol
COM is defined or not. COM files must have an entry point so the END
directive requires a start address; whereas, EXE files do not require
an entry point.
Under MASM Version 4.00, you can accomplish this with a simple
conditional-assembly block at the end as follows:
ifdef com
end start
endif
end
MASM Version 5.10 flags this as an error, which it should according to
Page 79 of the "Microsoft Macro Assembler 5.1 Programmer's Guide."
"Any statements following the END directive are ignored by the
assembler." The error occurs because the endif is not being recognized
and "Number of open conditionals: 1" error is displayed.