B. COMPILATION PROBLEMS + COMPATIBILITY
0. How compatible is FASM with MASM, NASM, ... ?
Sorted from worst to best:
- GAS AT&T - you will have to rewrite >95% of the code (swap operands and much more)
- MASM - depending from MASM version and coding style used, you will have to rewrite 50% ... 95% (MASM compatibility (partial) macros exist for Win32, also some unofficial "PROC16")
- GAS INTEL syntax, TASM ideal - rewrite 20% to 50%
- NASM - simple (DOS COM) code will compile as-is or with very minor fixes, sophisticated code will need fixing up, most notably macros
FASM doesn't support OMF output format, this can be an additional problem.
1. I have a few ASM books and none of the examples works !!!
Most likely your books use MASM syntax. FASM introduces its own syntax, inspired by TASM IDEAL mode and NASM. It is unable to compile code written for MASM, like for example TURBO-PASCAL is unable to compile QBASIC code.
http://board.flatassembler.net/topic.php?t=13867 "Does MASM help learning FASM?" 2012-Jan
t=7572 "mov dl, byte es:[di] - invalid .."
t=3197 "Design Principles, or Why fasm Is Different" 2005-Mar by
Tomasz Grysztar
2. I get "error: undefined symbol 'C0000040h'" but it's a number !
Your BUG. Like some other assemblers, FASM recognizes things like "C0000040h" or "CFFFh" as a label, and not as a hex number. The "h" suffix is a residual support of MASM syntax in FASM. There are multiple ways to fix this:
"C0000040h" - bad in all assemblers
"0C0000040h" - OK in all or most assemblers
"0xC0000040" - OK in FASM and NASM (C-style)
"$C0000040" - OK in FASM, bad in NASM
"$0C0000040" - OK in FASM and NASM
"$C000'0040" - OK in FASM and unique to FASM
http://board.flatassembler.net/topic.php?t=13746 "Why? "error: undefined symbol 'C0000040h'""
http://board.flatassembler.net/topic.php?p=133777#133777 Post about "h" suffix
http://board.flatassembler.net/topic.php?t=1484 "Problem: Int 21 Ah =1 >> Int 15 Ah = 1!!!" Forgot "h" suffix
3. FASM whines with "reserved word used as symbol"
Instructions like MOV AX, [CX] or JMP WORD [AX] cause this error - FASM bug ?
Your BUG. Only BX, BP, SI and DI are available for indexing in 16-bit code. FASM's report is bad, but it originates from internal design. This is a "problem" of 8086 design and 16-bit code. Using more registers like EAX etc. for addressing is a privilege of 32-bit code on 80386 and later CPU's.
http://board.flatassembler.net/topic.php?p=137175#137175 post about "mov [cx], ax" in t=13626 2011-Nov
http://board.flatassembler.net/topic.php?t=9983
http://board.flatassembler.net/topic.php?t=8140
http://board.flatassembler.net/topic.php?t=7231
http://board.flatassembler.net/topic.php?t=6823
http://board.flatassembler.net/topic.php?t=5448
4. What's wrong with "CS:[SI]" ?
SI is valid for addressing (see above), but correct FASM syntax is
[CS:SI], in both 16-bit and 32-bit code (and [CS:ESI] then). This is a difference from MASM syntax.
http://board.flatassembler.net/topic.php?t=9998 "comparison Tasm vs Masm vs Fasm vs Rasm" (2009-Mar)
http://board.flatassembler.net/topic.php?t=9759 "How to convert "mov fs:[0],esp" to FASM syntax?" (2009-Feb)
http://board.flatassembler.net/topic.php?t=7572 "Bug ? mov dl, byte es:[di] - invalid .." (2007-Aug)