Make your own free website on
From: (Raymond Moon)
Subject: x86 Assembly Language FAQ - General Part 3/3
Summary: This section is part three of three parts that contain x86 asm info common to all assemblers.

Subject: 26. WWW Assembly HomePages


All of the web sites listed here are maintained by individuals.  I will
strive to maintain this list current but do not be surprised if the
addresses no longer are current.


Randy Hyde's Assembly Language Page
        Excellent tutorial, Art of Assembly Language
        ASM Style Guide

Christian Ludoff's 80x86 Sandpile Page Basic Page
        The second page is where you should kept you link.  Much good
            information is available at this site.

EG3 Electronic Communication's Electronic Engineer's Toolbox
        Assembly Language Hot Lists and Major Resources.

Robert Collins' x86 Monthly Digest
        Intel processor bugs
        Intel data sheets and programming manuals
        In-Depth articles
        Productivity ehancements and programming tips
        Rober Collins' Dr. Dobb's Journal Undocumented Corner.
        Much more

Jannes Faber's Assembly home page
        List of ASM Books with short reviews
        A few hints and tricks
        Complete source code to some of his programs
        A listing of EMS Professional Shareware products

Ray Rose's HTML For Assembler home page
        An extensive list of ASM books without descriptions
        Links to alt.lang.asm, comp.lang.asm.x86, and alt.msdos.programmer
        Link to the Yahoo/Computers and Internet/Languages/Assembly page
            (see below)

NASM: The Netwide Assembler Project
        A group of programmers are writing a new assembler.  This home page
            describes the project and where to download the latest version.

Michael Babcock's Programming Home Page (many broken links on pages)
        This home page has links to:
            Optimizing 803/4/586 ASM Programming
            ASM Tutorial

The Official Web Shareware Site
        This site appears to have a few asm files not on SimTel.

Dr. ASM's Assembly Home Page
        Some answered questions and links to other assembly related sites.

James Vahn's 80xxx Snippets - 80x86 Assembly Language Enthusiasts
        Download snippets & Booklist

Kip Irvine's Assembly Language Sources

Gavin Estey's Home
        His ASM tutorial, other ASM Links, FAQs and Optimizations

Grzegorz Mazur's x86 CPU Stuff
        x86 CPU identification algorithms
        Cyrix/IBM5x86/6x86 (and 486) control program
        Links to other information on x86 family CPUs

Heath Holcomb's x86 Assembly Page
            Some pointers on what is assembly language, what is assembly good
            for, and what do you need to get started.
            Pointers to ASM Tutorial, this FAQ, other ASM web pages
Eric Isaacson's A86 Assembler and D86 Debugger Page
        Overviews of a86 and a386 assemblers, d86 and d386 debuggers,
            download and purchase of a86 and d86.

Tore Nilsson's Assembly Tutorial Page
        VLA's Assembly and DMA programming tutorials, Asphyxia's VGA
            tutorials, and some graphics and sound programming

Gerd Kortemeyer's 387/486DX/Pentium/Floating Point Processor Stuff
        A collection of assembler routines written for Turbo Pascal and
        C++.  Most of the comments are in German after an English

Cameron's 386+ Programming Page                     NOT CURRENTLY WORKING
        32 bit DOS extender/Utilities/pmode extender
        File formats and specifications/Game programming
        Knowledge Base with ASM tutorials, Denthor's VGA Trainer and Univ.
            of Guadalajara ASM tutorial 

Peter's PMODE Home Page
        Pmode tutorials and programming related files

Niko Komin's Assembler for PCS page
        Shareware, pmode, x86 mnemonics, ASM related links.

Alexandre Zvenigorosky III's Programs for PC 386+
        Zvenigorosky's assembler and debugger, currently documentation
            only in French.

Rich Elber's ValArrow (286 Assembler) Page
        Links to Arrowsoft Assembler, ZD86 debugger, discussion of
            Arrowsoft's Assemblers deviations from MASM.

Kurt I. Groenbech's Alab Homepage
        Home page for the Assembler Laboratory that is an IDE for

Christian Kurzke's Advanced x86 Assembly Programming
        Excerpts from lessons given at Adalbert Stifter Gymnasium in 1989

Bob Richardson's PC Assembly Language Page
        Eighteen topics taken from his SELFIN PC Assembly Language Group.

Jesper Pedersen's Processor Information Page
        List of instructions and opcodes used by Intel, AMD, Cyrix and

Quantasm's x86 and Pentium Programming Tips and Info

Steve Kemp's Assembly Language Programming Index  (Not currently working)
        Assembly Language Newbie information.  A86 Source Code

Ferdi Smit's Assemble It! Page            
        His own source code, 3D programming, his own ASM tutorial,
            optimization and other information.

Paul Hsieh's x86 Assembly Language Page
        Feature articles, Optimization and General Programming/References

Jaap Harm's 80x86 Assembly Page                 (Not currently working)
        Tutorial, source code and links

Charles Winner s ASM Resources                  (Not currently working)

G. Adam Stanislav's Whiz Kid Technomagic                            NEW
        Win95 Assembly Language source code examples

John Eckerdal's Assembly Page     NEW
        Nice collection of Assembly Gems.

Contributor:  Raymond Moon,
Last changed: 19 Sep 98

Return to the Table Of Contents

Subject: 27. Common Reason Why Memory Allocation Fails


A common error received when first learning to use Int 21h Function 48h,
allocate memory, is error code 8, insufficient memory available.  Usually,
the programmer then writes a small program that only allocates memory, and
the program still fails.  This situation is quite puzzling because there
should be hundreds of kilobytes of memory available but this function
reports that there is insufficient memory for a few hundred bytes.  The
reason is that DOS generally allocates all available memory above the
loaded program to that program.  Therefore, there is no more memory to
allocate, so the request fails.


Since a .COM file does not contain any header information, the DOS loader
has no way of determining how much memory is required for a program beyond
the physical size of the program.  Even this number is deceptive because
it does not include a stack.  Therefore, DOS always allocates all
available memory above the program to the program.

To use the allocate memory function, the programmer must release that
extra memory using Int 21h Function 4ah, Set Memory Block Size.  Given
that generally there is more that 64 Kbytes of memory, the DOS sets Stack
Top to just under that value, it is generally safe to release all memory
above 64 Kbytes.


The amount of memory the DOS allocates to the loaded program depends upon
a value in the .EXE header.  This value is called Maximum Allocation and
is a word starting at offset 12.  This value specifies the number of
16-byte paragraphs beyond the image size wanted by the program to execute. 
This value must be equal or greater than the Minimum Allocation, which is
the number of 16-byte paragraphs beyond the image size required by the
program to execute.  This space generally contains uninitialized variables
and the stack.

The value of Maximum Allocation is set by the /CPARM Option for the
Microsoft Linker.  By default, the linker sets this value to 0ffffh which
will causes DOS to allocate the largest block of available memory.  This
memory can be used as a heap, print buffer, etc.


In the PSP, at offset 02h, DOS loads a word which is the segment address
of the next Memory Control Block or Arena.  Subtracting the PSP from that
value at offset 02h will be the number of memory paragraphs allocated to
the program.  The number of bytes can be calculated by shifting that
to the left by 4 bits, multiplying by 16, the size of a memory paragraph.


If you want to load and execute another program, you must release memory
to make room for the program.  Also, since the largest chunk of memory is
allocated already to the program, all requests to allocate memory
generally fail.

Again, to use the allocate memory function, the programmer must release
the extra memory above the program use as for a .COM file above.  The
problem here is where is the end of the program.  The answer is not as
simple as with the .COM file.  There are two basic solutions.

1.  If you use the .dosseg option, the Microsoft Linker will define a
label, _end, at the end of the DGROUP.  Since the .dosseg option also
places any FAR data segments between the code and DGROUP segments, you can
release all memory above that label.

2.  If you do not want or are unable to use the first option, use an
include file which declares all segments used by your program.  Define a
label in the last segment and use it as the _end label in the first

Contributor:  Raymond Moon,
Last changed: 26 Dec 95

Return to the Table Of Contents

Subject: 28. Volume Serial Numbers


The volume serial number was introduced with DOS 4.0 as part of an
extended boot record and is created through you either FORMAT a disk or
use DISKCOPY to create another disk.  The serial number is a function of
the time/date of the formatting or the diskcopying.  Note that DISCOPY
generates a new volume serial number so a DISKCOPY is not an exact image
of the source diskette.


For example, say a disk was formatted on 26 Dec 95 at 9:55 PM and 41.94
seconds.  DOS takes the date and time just before it writes it to the

Low order word is calculated:               Volume Serial Number is:
    Month & Day         12/26   0c1ah
    Sec & Hundrenths    41:94   295eh               3578:1d02

High order word is calculated:
    Hours & Minutes     21:55   1537h
    Year                1995    07cbh

Note that DOS interrupt 21h Functions 2ah, Get DOS Date, and 2ch, Get DOS
Time, are particularly suited to getting the date and time for
calculating the Volume Serial Number. 


To read the Volume Serial Number, use the IOCTL call, int 21h function 
440dh Minor Code 66h, Get Media ID.  To write the Volume Serial Number, 
use the IOCTL call, int 21h function 440dh Minor Code 46h, Set Media ID.

WARNING!  These IOCTL calls use a structure that also contain the volume 
label and file system type.  So that you do not create errors with these 
values, I recommend that you always Minor Code 66h to initialize the 
structure before setting the Volume Serial Number to a new value and 
writing it back to the disk. 

Contributor:  Raymond Moon,
Last changed: 17 Feb 96

Return to the Table Of Contents

Subject: 29. .obj File Format

29.1 INTEL

There are two sources for this information.  The first is available from
Intel.  The Tools Interface Standards Committee has prepared the following 

The readme file in each .zip file states that the document is the
Relocatable Object Module Format Specification, V1.1.  

Unfortunately, both files unzip into documents formatted for Postscript
printers.  Adobe's Acrobat can not display them, but Ghostscript can.  If
you need GhostScript, you can get it from the following site.  Read the 


The second is from Microsoft.  This file is located at:

This file expands into ascii text files that are the Microsoft Product
Support Services Application Note: Relocatable Object Module Format. 
These files date from 1992.  Also included is the .lib file format and the
CodeView extensions. 

Contributor:  Raymond Moon,
Last changed: 9 Jan 96

Return to the Table Of Contents

Subject: 30. Rebooting from Software


Within DOS, there are two types of rebooting.  There is the warm reboot
that is evoked by pressing the "Ctrl-Alt-Del" key combination.  During
this reboot, all Power On System Tests, POSTs, are performed with the
exception of the memory tests.  In addition to the POSTs, interrupt
vectors are reinitialized and system timers reinitialized.  In other
words, the BIOS code initializes the computer system to such a state that
the computer system is ready for loading the operating system.  The
loading of the operating system is done by issuing an interrupt 19h.

The second type of rebooting is a cold reboot that occurs when the system
is turned on.  The only difference between a cold reboot and a warm reboot
is the performing of the memory tests.


Whether a cold or warm reboot is performed depends upon the value if the
the reset flag in the ROM BIOS data area.  If this flag is set to 1234h, a
warm reset is performed.  An any other value results in a cold reboot. 
Usually a zero is loaded for the cold reboot.  Code snippets to do this

ROMBIOS_DATA    segment at 0400h
    org 72h
ResetFlag   dw  ?

ROMBIOS     segment at 0f000h
    org 0fff0h
Reset   label   far

In your code:

    mov ax, seg ROMBIOS_DATA
    mov ds, ax
    mov ResetFlag, 1234h        ; or 0 if cold reset is desired
    jmp Reset


Neither the warm nor the cold boot flushes buffers, system, smartdrv, and
EMM386, or notifies TSRs.  This can lead to lost of data.  The best source
code that takes most of this into account is:

Full souce code is available.


Using this interrupt alone will only reload the operating system onto a
computer system that may not be properly initialized for it.  The
interrupt vectors are not reset but the TSRs that have hooks into the
interrupt table may be overwritten.  Obviously, this can lead to the
system hanging if one of these hooked and overwritten interrupts is
called.  Other problems can be timers not reset or add-on cards not
reinitialized properly.  So, do NOT use int 19h to reboot the computer.


In the original IBM ROM BIOS, the instruction at f000:fff0 was a long jump
to f000:e05b.  Some programs skipped the jump at f000:fff0 and went
directly to the second address which is the start of the reset procedure
in ROM BIOS.  I checked my 386 with non IBM BIOS, and the start of the
reset procedure is at the same address.  I believe that using the second
address is dangerous because there is not any guarantee that it will stay
the same.  Also, if you are rebooting the computer what is the reason in
saving a few cycles!  Stay with the address f000:fff0 as the jump there
always will take the execution path to the correct code.

Contributor:  Raymond Moon,
Last changed: 20 Dec 96

Return to the Table Of Contents

Subject: 31. Other FAQs


This excellent FAQ is posted every 20 days to comp.os.msdos.programmer,
comp.answers and news.answers newsgroup.

It is available from


The following websites contains many links to communication and hardware 
related FAQs, e.g., serial port, game port, keyboard, modem, and LANs. 
Most of these FAQs are not approved FAQs so are not found at
but that is not to say that these are not quality FAQs.  There is much good

Contributor:  Raymond Moon,
Last changed: 17 Feb 96

Return to the Table Of Contents

Subject: 32. Pseudo Random Number Generator in Assembly Language

Mark Adler wrote a set or pseudo random number generators based upon
algorithms from Knuth's "Art of Computer Programming", vol 2, 2nd ed.  The
file comes with full assembly source and .obj files for all major memory
models.  While written to link with Turbo C, the .obj files when linked
with Microsoft C worked well, except for the procedure that return a double
random number.  The reason was because the return protocol is different
between Borland C and Microsoft C.  Once the code was modified to work with
Microsoft C, the code worked well.

To test the algorithms, I created an array of 100 random numbers and then
generated random numbers and tried to determine if the original pattern was
ever repeated.  My program kept the length of the longest matching series. 
For real or double, the longest matching series was one after more that a
billion random numbers.  For ints, 0 and 1 as the only selections produced
the longest matching series of 31 matches after more than a billion random
numbers.  Increasing the range of acceptable numbers quickly reduced the
longest matching series to 2 in over 250 million random numbers.  My short
testing revealed that the longest matching series seldom increased after
this number.

Lastly, to test the distribution, I counted the number of hits for each
number between 0 and 100.  I collected about 100,000 hits for each number. 
The standard deviation was only 319 or less than 0.33%.

While my testing was not a rigorous mathematical testing of the algorithm
and its implementation, I believe for most uses, these procedures are

The file is available:

Note that the description of this file is inaccurate.

Contributor:  Raymond Moon,
Last changed: 4 May 96

Return to the Table Of Contents

Subject: 33. Command Line Arguments


DOS loads the command line into the PSP.  The length of the command line is
stored in a byte at offset 80h.  The command line is stored in the next 127
bytes starting at 81h.  As, generally, there is a space between the
filename and the start of the command line argument, a space usually is the
first character in this string.  The string is terminated with a carriage
return character, 0dh.

At startup for both .COM and .EXE format programs, DS and ES point to the 


See Subject #8, How to Redirect Stderr to a File.  I have written a
demonstration program that contains assembly language startup code that
parses the command line arguments onto the stack and provides them as argc
and *argv[] to the main procedure.  Anyone interested in accessing command
line arguments should look at this code.

Contributor:  Raymond Moon,
Last changed: 15 Jun 96

Return to the Table Of Contents

Subject: 34. Free 32 bit and DJGPP Assemblers

34.1  Brennan Underwood's Guide to Inline Assembly under DJGPP.

This is an introduction to inline assembly under DJGPP and is based upon
GCC.  The AT&T/UNIX syntax is explained.  The URL is:


Andrew Ly has a web page covering:
    URLs to FAQs
    AT&T x86 ASM Syntax
    Some inline ASM information
    converting .obj/.lib files

The URL to this page is:


Francois-Rene Rideau has authored a FAQ on free 32-bit assemblers or Linus
x86 Assembly HowTo.  It is available:

Contributor:  Raymond Moon,
Last changed: 19 Jun 96

Return to the Table Of Contents

Subject: 35. TERSE Programming Language

Jim Neil has just announced his TERSE Programming Language.  TERSE gives
all of the control available in assembly language with the look-and-feel
and ease-of-use found in high-level languages.

It is available:

Contributor:  Raymond Moon,
Last changed: 19 Aug 96

Return to the Table Of Contents

Subject: 36. Assembly Language IDEs REVISED

36.1    ASMEDIT

ASMEDIT is an Integrated Development Environment (IDE) for Assembly
Language programmers.  This IDE has a build in editor that provides syntax
coloring, editing of files up to 256 Mbytes, dissammembly of short code
pieces, and shelling to run external assemblers, linkers, debuggers and
make programs.

The real benefit of ASMEDIT is its extensive help.  This help covers:
    80x86 ASM mnemonics up to 686 including FPU and MMX;
    Complete Opcode Tables;
    BIOS Interrupts;
    DOS Interrupts and DOS Functions;
    EMS and Mouse Functions;
    BIOS and DOS Data Structures;
    Diagnostic Codes; and
    VGA programming information.

ASMEDIT is available from simtel or any of its mirrors:

36.2 ALAB

Assembler Laboratory is an assembler IDE, packed with nice features such

     syntax and error highlighting 
     proc, macro and data browsers 
     tasm, masm, a86 and dlink support. 
     heuristic scan 
     opcode help, extended ascii chart, scan codes, calculator 
     much more!

The latest version is available from the author's homepage:


The latest version of ASMIDE, 4.01, has the following features:
    contains all the features of a conventional editor, such as Finding,
        Replacing, Cutting, Copying, Pasting.
    has the ability to open multiple files, allowing you to transfer text
        between the files. Multiple windows can be Tiled or Cascaded, and
        features Scroll bars.
    has mouse support.

    features a simple, 4 function, 3 mode calculator, and an Ascii Chart.
    has menu systems allowing you to assemble, link, run and debug your
        program.  Short cut keys are also provided.
    allows you to specify your own assembler, linker and debugger in the
        configuration file.
    features setup dialogs that provide support for TASM, TLINK, MASM and

ASMIDE is available:


NASM-IDE is a front end for NASM which allows multiple files to be worked
on within the same editing environment.  Written in Turbo Pascal and Turbo
Vision, the NASM-IDE interface is clear and straightforward.  Features

    Turbo Vision point-and-click style interface
    Automatic syntax highlighting of source code
    An ASM Assistant to guide users through the creation of assembler
    On-line help system
    Support for three main output file formats - flat file binary and DOS
        16 bit and Win32 object files

Learn more about NASIDE and download it from:

36.5 MicroASM                                                           NEW

MicroASM is written by Ole Saether.  It is a Windows 95 & NT windows editor
with support for MS-DOS command line assemblers.

With MicroAsm you can: 

     Create and edit text files. 
     Run the files through your favorite command-line assembler. 
     Automatically highlight lines containing errors.

To learn more about it and download it, visit: 

36.6 TASM IDE                                                           NEW

Joost Vrielink has developed a Turbo Assembler IDE.  It is free for
downloading from his web site:

The IDE is an editor just like WordPad, but compile/link/run/debug can be
accomplished with just one click  It also has a built-in dec/hex/bin/oct
converter, and syntax highlighting is almost finished.  It is perfectly
suited to make simple 16-bit DOS programs within the Windows 95/98
environment.  Changes are being added quite often, so remember to return
and check every now and then.

Contributor: Raymond Moon,
Last Changed: 19 Sep 98

Return to the Table Of Contents

Subject 37. Dissassemblers

38.1 Review of Disassemblers

Jerzy Tarasiuk has reviewed some commercial and shareware disassemblers. 
The shareware assemblers are available in this directory.  The review is

Contributor: Raymond Moon,
Last Changed: 13 Oct 96

Return to the Table Of Contents

Subject: 38. How to Optimize for the Pentium


The below site is updated as new information becomes available and contains
information not found elsewhere.


Much useful literature can be downloaded for free from Intel's www site:

The documents are in various different file formats.  If a particular
document is in a format not supported by your word processing software then
you may seek an appropriate file viewer somewhere on the Internet.  Many
software companies are offering such file viewers for free to support their
file formats.

Tutorials for Optimizing the Pentium, and Pentium Pro/Pentium II can be
downloaded from:

Manuals for the Pentium and Pentium Pro processors can be downloaded from:

Detailed information on the MMX processors can be found in the documents:
"MMX Technology Developers Guide", and "Programmers Reference Manual", both
of which are available from:

Many other sources other than Intel also have useful information.  I would
particularly recommend:

Contributor: Ray Moon,
Last Changed: 20 Dec 97

Return to the Table Of Contents

Subject: 39. Assembly Language Programming Style Guidelines

Randy Hyde has done it again.  He has written a style guide that will help
you write more readable and maintainable assembly language code.  The URL

Contributor: Ray Moon,
Last Changed: 21 May 97

Return to the Table Of Contents

Subject: 40. Other Assembly-Related Newsgroups

Here are some other assembly language newsgroups that may be of interest.

Contributor: Ray Moon,
Last Changed: 26 Dec 97

Return to the Table Of Contents

Subject: 41. ZD-86 Debugger


ZD86 is a full featured Assembler Debugging Environment, that provides
Symbolic Debugging for most common Assemblers, including A86, MASM, TASM,
etc.  The symbolic debugging capability displays and highlights your
statement labels and variable names where you have placed them in your
code.  It is a powerful tool for the advanced assembly language programmer
yet friendly enough for someone just starting with assembly language.


The ZD86 Debugger is available from:

Contributor: Ray Moon,
Last Changed: 22 Jun 97

Return to the Table Of Contents

Subject: 42. Acknowledgments

I would like to acknowledge all the people who have assisted me or any of
the contributors.  For their time and effort, this FAQ is a better product.

David Boedicker, Barry Brey, Paolo Ciccone, Giuseppe De Marco, Morten
Elling, Kris Heidenstrom, Alan Illeman, Don Krull, Chabad Lubavitch, Thanh
Ma, Jeff Owens, Ed Parry, Keith Petersen, Michael Roberts, Russell Schulz,
Rocky Seelbach, Janos Szamosfalvi and Cedric Ware

Return to the Table Of Contents