-
Notifications
You must be signed in to change notification settings - Fork 0
/
fasm_compatibility.asm
126 lines (87 loc) · 2.93 KB
/
fasm_compatibility.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
; Flat Assembler uses the Intel syntax.
; Effective for:
; Flat assembler version 1.64
; emu8086 integrated assembler version 4.00-Beta-20 (or above)
#fasm# ; this code is for FASM.
org 100h
name "fasmcomp"
; === [NOTE 1]
; calculate the sum of 'a' and 'b'
jmp start
a dw 5
b dw 7
start:
; this is correct syntax for emu8086 integrated assembler,
; but it is wrong for fasm:
mov ax, a
mov bx, b
add ax, bx ; AX = offset a + offset b (AX=206) (correct, but not what we expect)
; correct syntax for fasm:
mov ax, [a]
mov bx, [b]
add ax, bx ; AX = 5 + 7 (AX=000C) (correct)
;; to calculate sum of offsets for emu8086 integrated assembler
;; it is required to use the offset directive, for example:
; mov ax, offset a
; mov bx, offset b
; add ax, bx ; sum of offsets instead of values.
;; the offset directive is not supported for fasm (error: extra characters on line)
; Hello, World example in fasm:
mov dx, msg
mov ah, 9
int 21h
; for emu8086 integrated assembler:
; mov dx, offset msg
; or
; lea dx, msg
; (syntax of the integrated 8086 assembler is mostly MASM/TASM compatible)
; wait for any key...
mov ah, 0
int 16h
ret
msg db "Hello, World!", 0x0D, 0x0A, "$"
; emu8086 compatible declaration is:
; msg: db "Hello, World!", 0x0D, 0x0A, "$"
; (note: there is ":" after msg)
; === [NOTE 2]
; fasm does not support the comment directive, for example:
; comment *
; la lalala la...
; *
; === [NOTE 3]
; these precompiler directives are preparsed by the IDE:
; NAME
; #make...
; #AX=...
; etc...
; === [NOTE 4]
; for fasm it's required to use "byte" and "word" prefixes
; in places where it may be required to use "byte ptr", "word ptr"
; or "b.", "w." prefixes for the integrated 8086 assembler.
; For example:
mov byte [m1], AL
m1 dw 1234h
; ; for the integrated 8086 assembler it should be:
; mov b. m1, AL
; ; or:
; mov byte ptr m1, AL ; (MASM compatible)
; === [NOTE 5]
; uninitialised variables are not added to actual binary file
; when these variables are located in the bottom of the file
; and there is no defined data after them (MASM compatible)
; 8086 assembler always initialises variables as 0 (MASM incompatibility)
; For example:
u1 dw ?
; === [NOTE 6]
; fasm assembler is case sensitive;
; for example, the following code would cause
; "symbol redefinition" error for MASM or 8086 integrated assembler,
; but it is completely legal for fasm:
mov [d], 9
mov [D], 12
ret
d Dw 5
D dw 7
; === [NOTE 7]
; there may be other slight syntax incompatibilities,
; if you find any problem feel free to email.