MASM / TASM compatibility


syntax of emu8086 is fully compatible with all major assemblers including MASM and TASM;   though some directives are unique to this assembler.   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_bin#
#make_boot#
#cs=...#
         etc...



emu8086 ignores the ASSUME directive.   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 ah, [bx]        ; read byte from DS:BX
mov ah, es:[bx]     ; read byte from ES:BX



emu8086 does not require to define segment when you compile segmentless COM file, however MASM and TASM may require this, for example:


name test

CSEG    SEGMENT     ; code segment starts here.

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, however in MASM and TASM you may need to manually set an entry point using END directive even if there is no way to set it to some other location. emu8086 works just fine, with or without it; however error message is generated if entry point is set but it is not 100h (the starting offset for com executable). the entry point of com files is always the first byte.

If you compile this code with Microsoft Assembler or with Borland Turbo Assembler, you 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.

emu8086 has almost 100% compatibility with other similar 16 bit assemblers. The code that is assembled by emu8086 can easily be assembled with other assemblers such as TASM or MASM, However not every code that assembles by TASM or MASM can be assembled by emu8086.

A template used by emu8086 to create EXE files is fully compatible with MASM and TASM.

The majority of EXE files produced by MASM are identical to those produced by emu8086.   However, it may not be exactly the same as TASM's executables because TASM does not calculate the checksum, and has slightly different EXE file structure, but in general 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 integrated assembler supports shorter versions of byte ptr and word ptr, these are: b. and w.

For MASM and TASM you have to replace w. 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 / shorter emu8086 syntax.
hlt

var1  db  0
var2  db  0



LABEL directive may not be supported by all assemblers, for example:
	  TEST1 LABEL BYTE
	  ; ...
	  LEA DX,TEST1
The above code should be replaced with this alternative construction:
          TEST1:
          ; ...
	  MOV DX, TEST1
The offset of TEST1 is loaded into DX register. this solutions works for the majority of leading assemblers.