menu
|
MASM / TASM compatibility
Syntax of
Emu8086 is fully compatible with all major assemblers including
MASM and TASM; though some directives are unique to
Emu8086. If required to compile using any other assembler you may
need to comment out these directives, and any other directives that start with a
'#' sign: #MAKE_COM#
#MAKE_EXE#
#MAKE_BIN#
#MAKE_BOOT#
Emu8086 does not support the ASSUME directive, actually most
programmers agree that this directive just causes some mess in your code.
Manual attachment of CS:, DS:, ES: or SS: segment
prefixes is preferred, and required by Emu8086 when data is in segment
other then DS. For example: MOV AX, [BX] ; same as MOV AX, DS:[BX]
MOV AX, ES:[BX]
Emu8086 does not require to define segment when you compile a
COM file, though MASM and TASM may require this, for
example:
CSEG SEGMENT ; code segment starts here.
; #MAKE_COM# ; uncomment for Emu8086.
ORG 100h
start: MOV AL, 5 ; some sample code...
MOV BL, 2
XOR AL, BL
XOR BL, AL
XOR AL, BL
RET
CSEG ENDS ; code segment ends here.
END start ; stop compiler, and set entry point. |
Entry
point for COM file should always be at 0100h (first instruction
after ORG 100h directive), though in MASM and TASM you may
need to manually set an entry point using END directive. Emu8086
works just fine, with or without it.
In order to test the above code,
save it into test.asm file (or any other) and run these commands from
command prompt:
For MASM 6.0: MASM test.asm
LINK test.obj, test.com,,, /TINY
For TASM 4.1: TASM test.asm
TLINK test.obj /t
We should get test.com file (11 bytes), right click it and
select Send To and emu8086. You can see that the
disassembled code doesn't contain any directives and it is identical to code
that Emu8086 produces even without all those tricky directives.
A template used by Emu8086 to create EXE files is fully
compatible with MASM and TASM, just comment out #MAKE_EXE#
directive to avoid Unknown character error at line 11.
EXE files produced by MASM are identical to those produced
by emu8086. TASM does not calculate the checksum, and has
slightly different EXE file structure, but it produces quite the same machine
code.
Note: there are several ways to encode the same machine
instructions for the 8086 CPU, so generated machine code may vary when compiled
on different compilers.
Emu8086 assembler supports shorter versions of BYTE PTR and
WORD PTR, these are: B. and W.
For MASM and
TASM you have to replace B. and W. with BYTE PTR and
WORD PTR accordingly.
For example: LEA BX, var1
MOV WORD PTR [BX], 1234h ; works everywhere.
MOV w.[BX], 1234h ; same instruction, but works in Emu8086 only.
HLT
var1 DB 0
var2 DB 0
|