flat assembler
Message board for the users of flat assembler.
Index
> Main > Frequently Asked Questions (FAQ) Main |
Author |
|
Matrix 01 Nov 2004, 15:42
Frequently Asked Questions (FAQ) Main
Posting Information for newbies: You've got a problem with assembly programming? There are probably many people who can help you solve it. You only have to do the following: First of all, you should take a look at the Flat Assembler Documentation , then you might wanna take a look at the examples section, IF you already did so, THEN try using the search function of this message board, IF you can't find the solution, do the following: Try to categorize your problem, ask yourself the following questions: Is your problem assembly related? IF NOT , THEN post to Heap ELSE Does it belong to a specific operating system? IF YES, THEN post it to the appropriate subforum: DOS, Windows, Linux, Unix, MenuetOS ELSE Do you think your problem is due to some bug in FASM compiler core? (we hope not) IF YES, THEN post it to Compiler internals ELSE Is the problem in the FASM IDE? IF YES, THEN post it to IDE Development - For developers and users of the Integrated Development Environments for flat assembler ELSE You would like to give some feedback on the forums? IF YES, THEN post to Feedback ELSE Post it to Main (you are here). For advanced programmers there are also: Macroinstructions - Post here your useful macroinstructions, discuss various tricks and syntax adjustments. Programming Language Design - Discuss development of assemblers/compilers. OS Construction - Post here if you are writing your own OS kernel, boot loader, etc. You probably could categorize your problem, now you may open a new topic named with the best description of your problem/suggestion, imagine if you saw that topic just created, what would you think if it had that name? Beginning of FAQ: This thread/sticky is intended to be a good list of FAQs (or simply usefull things), it's understandable that from time to time the search function might be a little tricky to use and it might take a while to find what one is looking for (especially when one isn't too familiar with the art of searching). Where can I get the latest information on the CPUs? Intel 64 and IA-32 Architectures Software Developer's Manuals (@intel.com) These manuals describe the architecture and programming environment of the Intel 64 and IA-32 processors. newbies, pls read the FASM documentation, Design Principles, or Why fasm Is Different Intros to ASM - after reading fasm documentations, for beginners Last edited by Matrix on 25 Aug 2006, 04:37; edited 2 times in total |
|||
01 Nov 2004, 15:42 |
|
DOS386 12 Sep 2011, 07:38
A. FATAL PROBLEMS
FASM / FASMW / FASMG / some example / my code after compiling has a virus !!! Very wrong, you have a false positive , FASM isn't a virus and the files from "official" page aren't infected either. The high occurrence of false positives on FASM (up to 1/3 of "antivirus" products can get upset) is a known fact and has been reported many times but hardly anything can be done on the side of FASM. Just put FASM on the "ignore list" , change or drop your "antivirus" , or bug the vendor or developer of it. t=21681 2020-Nov t=19186 2016-May "FAsmG triggering anti-virus" t=15749 2013-Sep "Malware false identifications" (do-nothing-EXE brewed with MASM is wormed too) t=15185 2013-Mar "virus problem" t=13868 2012-Jan "malware alert for FASM.EXE (WIN32 command line tool) COMODO" t=11233 2010-Mar "IS THERE A: Virus / Trojan in the FASM for Windows" t=10968 2009-Dec Post in "RB directive - Reserved Data (was "Reverse Data?")" p=106527 t=143 2009-Dec Post in "AsmEdit control" t=9861 2009-Feb "Fasm 1.67.34 windows package virus alert?" t=9857 2009-Feb "fasm 1.67.34" t=9496 ??? t=9118 ??? t=8977 ??? t=8818 ??? http://board.flatassembler.net/topic.php?t=8154 http://board.flatassembler.net/topic.php?t=7807 http://board.flatassembler.net/topic.php?t=7314 http://board.flatassembler.net/topic.php?t=7310 t=7302 2007-Jul "OllyDbg & FASMW recognized as viruses by AVG Free." http://board.flatassembler.net/topic.php?t=4696 "FASMLIB 0.8.0 - general purpose library" also has virii Last edited by DOS386 on 30 Oct 2023, 22:50; edited 15 times in total |
|||
12 Sep 2011, 07:38 |
|
DOS386 12 Sep 2011, 07:38
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. t=13867 2012-Jan "Does MASM help learning FASM?" t=7572 "mov dl, byte es:[di] - invalid .." t=3197 2005-Mar "Design Principles, or Why fasm Is Different" 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?t=21150 "mov ax, [sp], error: reserved word used as symbol" (2019-Aug) 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 "call or Jmp [ax]" (2009-Mar) 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) Last edited by DOS386 on 30 Oct 2023, 22:14; edited 6 times in total |
|||
12 Sep 2011, 07:38 |
|
DOS386 12 Sep 2011, 07:39
C. CPU DOCS
Intel's 8086 instruction reference ? http://board.flatassembler.net/download.php?id=4975 (8086, only PDF, direct download) Intel's 8086 to Pentium instruction reference ? http://home.myfairpoint.net/fbkotler/index.html "A Beginner's Nasm Page" http://home.myfairpoint.net/fbkotler/nasmdoc0.html "The Netwide Assembler: NASM" "This manual documents NASM, the Netwide Assembler: an assembler targetting the Intel x86 series of processors, with portable source." http://home.myfairpoint.net/fbkotler/nasmdocb.html "The Netwide Assembler: NASM" "Appendix B: Instruction List" http://home.myfairpoint.net/fbkotler/nasmdocr.html "This manual documents NASM, the Netwide Assembler: an assembler targetting the Intel x86 series of processors, with portable source." (links to "docc") http://home.myfairpoint.net/fbkotler/nasmdocc.html "Nasm Instruction Set Reference" "Appendix A: x86 Instruction Reference" long detailed list Intel's 80386 & 80387 instruction reference ? http://board.flatassembler.net/topic.php?t=3164 (In OS construction) http://board.flatassembler.net/download.php?id=3092 (80387, TXT, year 1986) http://board.flatassembler.net/download.php?id=3093 (80386, TXT, year 1986) Intel 386 Programmer's Reference Manual (year 1986).pdf (DEAD, 1 MiB, content identical to TXT file above) http://ompldr.org/vN2E3aQ/I80386.PDF (DEAD, 80386, PDF, 1.6 MiB, updated version from 1996) Intel's latest Pentium/SSE 4/5 instruction reference ? http://www.intel.com/products/processor/manuals/index.htm http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-manual-325462.pdf (all-in-one, 15 MiB) t=20533 (2018) -- "Collection of Intel manuals" (also AMD and ARM can be found under "x86") t=12900 (2011,2012) -- "Intel manuals" (all-in-one, bug reports) http://board.flatassembler.net/topic.php?t=7161 (SSE4) http://board.flatassembler.net/topic.php?t=7013 (links to above Intel page) Where to find newer (Pentium 2/3), but not newest manuals ? http://board.flatassembler.net/topic.php?t=6917 (SMSW discussion, link at end of thread) ftp://ftp.sac.sk/pub/sac/text/ (Huuuuge list, instruction lists pentium*.* , also other stuff (fileformats, RBIL, ...) http://alexfru.narod.ru/emiscdocs.html (Huuuuge list) http://www.ragestorm.net/downloads (Some more: 286, 386, MMX, ...) AMD's latest manuals ? http://developer.amd.com/documentation/guides/pages/default.aspx (big list) Last edited by DOS386 on 08 Oct 2024, 16:53; edited 13 times in total |
|||
12 Sep 2011, 07:39 |
|
DOS386 12 Sep 2011, 07:39
D. FASM INTERNAL
Why (not to) use FASM or some other assembler ? http://board.flatassembler.net/topic.php?t=16215 "FASM vs. NASM vs. MASM" 2014-Jan http://board.flatassembler.net/topic.php?t=10960 "So, why FASM?" 2009-Dec http://board.flatassembler.net/topic.php?t=10943 "Anyone of you tried out YASM ?" 2009-Dec http://board.flatassembler.net/topic.php?t=9686 ""Virtual" ... beautiful directive !" http://board.flatassembler.net/topic.php?t=9196 "Which Assembler is better?" How did the FASM project start ? FASM started on ASM32, Tomasz's previous assembler (32-bit DOS, non-public). ASM32 had started on TASM - using the IDEAL mode. http://board.flatassembler.net/topic.php?t=13794 (in DOS) 2011-Dec-29 "HDOS" - About HDOS and early FASM history, with some old files released http://board.flatassembler.net/topic.php?t=4919 (in DOS) 2006-Mar-08 "Some game with insight into origins of flat assembler" Help with FASM porting / understanding the source http://board.flatassembler.net/topic.php?t=3883 Where is the disassembler ? There is no "official" one for FASM. You can use NDISASM (inside every NASM package) or DISTORM (semi-official disassembler of YASM) or OBJCONV (smart). OBJCONV is done in C++, the other 2 are written in C Or BEYE / BIEW (can save disassembly if you try hard enough). http://board.flatassembler.net/topic.php?t=23174 "How to disassemble to a Flat Assembler source?" 2023-Dec http://board.flatassembler.net/topic.php?t=15510 "Disassembler?" 2013-Jun http://board.flatassembler.net/topic.php?t=14817 "Extended Length Disassembler Engine" 2012-Dec http://board.flatassembler.net/topic.php?t=11132 "quick decoder v1.02 by CandyMan" 2010-Mar (only DOS32 and Win32 binaries, closed source) http://board.flatassembler.net/topic.php?t=10874 "Challenge: code a disasembler <1 day & <512 Byte's" 2010-Feb (Toy < 512 Byte's disassembler and also a 256 Byte's self-disassembler) http://board.flatassembler.net/topic.php?t=10345 "The importance of a disassembler by hopcode (output source)" 2009-Jun (open source project, early) http://board.flatassembler.net/topic.php?t=10329 "FASM Disassembler" 2009-Jun http://board.flatassembler.net/topic.php?t=5248 "[IDEA] fdasm - FASM decompiler" 2006-May NDISASM (from NASM) http://nasm.us Lack: CMP EAX, BYTE 0x02 DISTORM (semi-official disassembler of YASM) http://www.ragestorm.net/distorm/ (was BSD, now only GPL) Lack: MOV GS:[EAX],0x0 BEYE / BIEW can save its disassembly output http://board.flatassembler.net/topic.php?t=4715 Agner Fog's OBJCONV: http://board.flatassembler.net/topic.php?t=10291 2009-Jun http://www.agner.org/optimize/#objconv Directive "comment" or C-style /* blah */ comments ? There is a substantial need for such a thing in the community and this has been requested many (at least 19 !!!) times since this forum was launched in 2003. However Tomasz doesn't want such a feature so it will most likely never be supported in the official versions of FASM. http://board.flatassembler.net/topic.php?t=15630 "multi-line comments in FASM" 2013-Jul http://board.flatassembler.net/topic.php?t=13186 "multi-comment function in FASM." 2011-Jul http://board.flatassembler.net/topic.php?t=11343 "Block comments (infinity+n)th attempt" 2010-Mar (by DOS386 with POLL) http://board.flatassembler.net/topic.php?t=11341 "Wink 6.91 (underlined, bold and italic)" 2010-Mar (famous IDE hacks by ouadji) http://board.flatassembler.net/topic.php?t=11161 "suggestion /*Comments*/ (final rev.8 - over for me)" 2010-Feb (famous "PREPROCE.INC" hacks by ouadji) http://board.flatassembler.net/topic.php?t=9911 "Commenting out garbage: /* blah */ and skip blah endskip" 2009-Mar (by DOS386) http://board.flatassembler.net/topic.php?t=9305 "Comment a block of lines in FASM?" in Main http://board.flatassembler.net/topic.php?t=8826 "COMMENT directive?" in Main http://board.flatassembler.net/topic.php?t=8419 "Looking forward fasm 1.67.27 released" in Main (posts in) http://board.flatassembler.net/topic.php?t=7481 " Comments in FASM." 2007-08-09 http://board.flatassembler.net/topic.php?t=7115 " Multiline /* ... */ comments in FASM." 2007-05-27 by MHajduk in Compiler Internals http://board.flatassembler.net/topic.php?t=5871 http://board.flatassembler.net/topic.php?t=5538 http://board.flatassembler.net/topic.php?t=4340 http://board.flatassembler.net/topic.php?t=3483 http://board.flatassembler.net/topic.php?t=2707 "Add block-comments into Fasm?" 2004-12-07 with POLL http://board.flatassembler.net/topic.php?t=2237 "comment feature?" 2004-09-12 http://board.flatassembler.net/topic.php?t=839 http://board.flatassembler.net/topic.php?t=582 "Improving comments" 2003-Nov (almost 10 years ago) Tomasz's preferred answer: http://board.flatassembler.net/topic.php?p=112215#112215 2010-Mar Does FASM have a "-d" switch ? The "-d" switch (known from many other HLL and ASM compilers) defines a symbol using the commandline, it has same effect as the "define" directive. And this is probably the most controversial design decision in FASM. Originally it was NOT there, then it got added in 1.67.24 (after Tomasz got pressured), but in 1.67.35 it got removed (after Tomasz got pressured and accused of breaking principles), so the history file of 1.68 is comparing with 1.66 only (1.67.xx was a "development line") and "-d" is not ever mentioned. But in 1.71.31 got got re-added, with the chief arguments that FASM should promote, but not enforce self-sufficient sources, and that the "include" directive (had been always in) does "break" the holy SSSO principle more than "-d". So YES, FASM does have "-d" switch now, but still self-sufficient sources are preferable. http://board.flatassembler.net/topic.php?t=17584 "FASM define macro from commmand line - "-d" switch" 2015-Jan http://board.flatassembler.net/topic.php?t=10763 2009-Oct http://board.flatassembler.net/topic.php?t=9948 "FA - command line extension for fasm" 2009-Mar http://board.flatassembler.net/topic.php?t=9770 "flat assembler 1.67.3x" 2009-Feb to 2009-Mar (removing "-d") http://board.flatassembler.net/topic.php?t=9634 2008-Dec http://board.flatassembler.net/topic.php?t=7902 "flat assembler 1.67.24" 2007-Dec Trouble with FASM's expression evaluator: 63 or 64 or 65 bits ? For years FASM's expression evaluator had a resolution of 64 bits, although it probably should be 65 bits. TASM had 33 bits for up to 32 bits code. With version 1.69.41 from 2012-03-01 it got upgraded to 65 bits. http://board.flatassembler.net/topic.php?t=14048 "flat assembler 1.69.41" http://board.flatassembler.net/topic.php?t=13815 "db 0. A bug or not a bug?" http://board.flatassembler.net/topic.php?t=13578 "Bug ? (value out of range)" http://board.flatassembler.net/topic.php?t=11876 ""db (-1) shr 1" results into "value out of ra"" scroll down: Tomasz explains TASM and FASM expression evaluator backgrounds (now obsolete) Last edited by DOS386 on 03 Jan 2024, 17:46; edited 19 times in total |
|||
12 Sep 2011, 07:39 |
|
DOS386 12 Sep 2011, 07:40
E. MATH
How to find out whether a number (integer or float) is square ? http://board.flatassembler.net/topic.php?t=13324 "quickest way to check if a number is a square" 2011-Aug How to get random numbers ? Use some PRNG algorithm and a source of real randomness. There is also the RDRAND instruction, but was added very recently (2010) so it is not that useful if you want to support older processors too. http://board.flatassembler.net/topic.php?t=14880 "RDRAND problem" http://board.flatassembler.net/topic.php?t=13741 "Fast and small Multiplicative Random number generator" http://board.flatassembler.net/topic.php?t=13283 "Intel has added a new instruction (RDRAND) Kewl !" 2011-Aug http://board.flatassembler.net/topic.php?t=5617 "Random Number Generator in FASM" 2006-Aug to 2013-Jun http://board.flatassembler.net/topic.php?t=1517 "Random numbers" 2004-May to 2007-Oct (How to generate a random number between 0 and 9? And big discussion of random number generators ...) How to calculate absolute difference of 2 integers ? http://board.flatassembler.net/topic.php?t=9110 How to find out the maximum of 2 integers ? http://board.flatassembler.net/topic.php?t=4219 Big math: chaining DIV, alternatives to the DIV instruction ? * t=11197 "how DIV works?" 2010-Feb (good, 32-bit DIV chaining for 64-bit) * t=9880 "Division..." 2009-Feb (magic number hack) * t=9129 "Large Number" 2008-Aug (large mul and div, prime factorization) * t=8690 "MUL & DIV" 2008-May (has C division code) * asmcommunity.net/...topic=21308 (scroll down) * masm32.com/...topic=458 "Factor WITHOUT division / multiplication" 2005-Jan * x86asm.net/...big-numbers... How to drop a number to the screen or convert into string ? You have to repeatedly divide by 10 and take the remainder as digits from RIGHT to LEFT. There is no DOS or BIOS service for this, but there is MSVCRT.DLL on Windows (overkill for such a trivial task). http://board.flatassembler.net/topic.php?t=15386 "Simple Conversion Routines (EAX to ASCII, Win32)" 2013-May to 2013-Jun http://board.flatassembler.net/topic.php?t=14494 "Print ing a number" 2012-Aug to 2013-Apr http://board.flatassembler.net/topic.php?t=8979 "how to do binary to decimal?" http://board.flatassembler.net/topic.php?t=8670 "LOADPEX example world's 1st LOADPEX vs DOS/32A | speed" http://board.flatassembler.net/download.php?id=3760 ("SPEED.ZIP" 144 KiB) http://board.flatassembler.net/topic.php?t=6330 "Numeric value stored in a Register reading as garbage" http://board.flatassembler.net/topic.php?t=5412 "String to number and vice versa ??" t=3924 2005-Aug to 2007-Mar "Binary number to decimal ASCII string conversion" has highly optimized UINT32->DEC code by El Tangas t=42 2003-Jun "i wrote a Sample code for Outputting integers" (has code) How to perform math with saturation ? t=17246 2014-Sep "saturation arithmetic without mmx+" stackoverflow.com...saturating-addition-in-c How to convert float numbers ? t=15740 2013-Sep "float (single) to string?" t=15626 2013-Jul "math calculations - converting ascii in floating point" t=234 2003-Sep "Procedure to output floating point numbers?" (has attach) How to use the FPU ? http://board.flatassembler.net/topic.php?t=15767 "Dividing negative numbers" (brewing PI with integers doesn't work like that, try FPU) http://www.website.masmforum.com/tutorials/fptute/index.html "SIMPLY FPU by Raymond Filiatreault Copyright 2003" "revolver barrel with 8 compartments" Last edited by DOS386 on 19 Sep 2014, 11:55; edited 24 times in total |
|||
12 Sep 2011, 07:40 |
|
DOS386 12 Sep 2011, 07:40
F. ADVANCED INSTRUCTION SETS
Is the AMD's "3DNow!" instruction set useful ? Probaby NO, and it got even officially deprecated in 2010: http://board.flatassembler.net/topic.php?t=11828 "AMD removes 3DNow!" 2010-Aug http://blogs.amd.com/developer/2010/08/18/3dnow-deprecated/ CMOV PageFault's despite the condition is false ... WtF ? This is a known flaw of Intel: http://board.flatassembler.net/topic.php?t=15346 "Did you know?" 2013-Apr (scroll down) http://board.flatassembler.net/topic.php?t=11626 "disappointed with xor eax,eax \ cmovnz eax,[eax]" 2010-Jun Disadvantages of CMOV: - Not available on CPU's older than Pentium 3 - PageFault's despite the condition is false - Slow (??? see http://ondioline.org/mail/cmov-a-bad-idea-on-out-of-order-cpus criticism by Linus ...) Replace PINSR (SSE) with MMX instructions at most ? http://board.flatassembler.net/topic.php?t=11752 "Challenge for MMX/SSE experts: PINSR" 2010-Jul CMOV vs otimization: (128,192,256) -> (160,192,224) ? YES we can: http://board.flatassembler.net/topic.php?t=8568 "Conditional moving without branching" 2008-Apr AVX support http://board.flatassembler.net/topic.php?t=15676 "avx detected but OS not supported" Last edited by DOS386 on 22 Aug 2013, 05:13; edited 8 times in total |
|||
12 Sep 2011, 07:40 |
|
DOS386 08 Oct 2024, 17:24
If you think some question in this FAQ is missing, please post a reply here with a link to the thread, and a short/brief motivation - the reply will then be deleted if approved and the entry added to the FAQ, if the entry is rejected a reply will be made to the post explaining why it's rejected, the request and the answer will then be kept for about an week and then both will be deleted to keep this thread as clean as possible. When reporting a dead link, please try to find a better one yourself and supply it.
Last update: 2024-Oct-08 by DOS386 |
|||
08 Oct 2024, 17:24 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.