======================================================================
  Microsoft(R) Product Support Services Application Note (Text File)
              HA0620: Macro Assembler Questions & Answers
======================================================================
                                                  Revision Date: 10/92
                                                      No Disk Included

The following information applies to Microsoft Macro Assembler
versions 5.1 and 6.0.

 --------------------------------------------------------------------
| INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY    |
| ACCOMPANY THIS DOCUMENT (collectively referred to as an            |
| Application Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY      |
| KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO    |
| THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A     |
| PARTICULAR PURPOSE. The user assumes the entire risk as to the     |
| accuracy and the use of this Application Note. This Application    |
| Note may be copied and distributed subject to the following        |
| conditions: 1) All text must be copied without modification and    |
| all pages must be included; 2) If software is included, all files  |
| on the disk(s) must be copied without modification [the MS-DOS(R)  |
| utility DISKCOPY is appropriate for this purpose]; 3) All          |
| components of this Application Note must be distributed together;  |
| and 4) This Application Note may not be distributed for profit.    |
|                                                                    |
| Copyright 1992 Microsoft Corporation. All Rights Reserved.         |
| Microsoft and MS-DOS are registered trademarks and Windows         |
| is a trademark of Microsoft Corporation.                           |
 --------------------------------------------------------------------

1. Q. Why does my program hang or generate an illegal instruction
      when I use a .386, .386P, .486, or .486P processor directive?

   A. The 386 and 486 processors can operate with either 32-bit
      operations or 16-bit operations being the default. In either
      mode, a prefix byte (66h or 67h) at the beginning of the
      instruction tells the processor to treat an instruction as a
      nondefault operation. For example, if the processor sees a prefix
      byte while in a 16-bit segment, it executes the instruction as a
      32-bit operation.

      When you assemble a file that uses full segment declarations,
      Macro Assembler assumes that the default operations are 32 bit.
      To change this assumption, you must use a USE16 modifier on the
      SEGMENT directive. When you assemble a file that uses simplified
      segment declarations, Macro Assembler assumes that the default
      operations are 32 bit if a .386, .386P, .486, or .486P comes
      before the .MODEL directive. Placing the processor directive
      after the .MODEL assumes the 16-bit default operations.

2. Q. Why can't I display my Microsoft Macro Assembler source code
      under Microsoft CodeView debugger?

   A. If you are using full segment directives in your Macro Assembler
      file, remember to give any code segments the class CODE. If they
      are not given the class CODE, you cannot display the source file
      when you enter CodeView.

3. Q. Why do I get errors when I try to reassemble the startup
      source code that came with Microsoft C version 6.0?

   A. These source files were assembled with Microsoft Macro Assembler
      version 5.1 and include .INC files that were written specifically
      for Macro Assembler 5.1. If you are using Macro Assembler 6.0,
      you need to use the .INC files that come with Macro Assembler
      6.0. Also, place /DMS_STARTUP in the flags used by the assembler
      so that it uses the appropriate items out of the new .INC files.
   
       NOTE: These errors can also occur in Microsoft FORTRAN and
       earlier versions of Microsoft C Compiler.

4. Q. Why do I get an unresolved externals error when I link my
      assembly routine with Microsoft C Compiler?

   A. Microsoft C Compiler adds leading underscores to function and
      variable names and preserves the case of names. By default,
      Microsoft Macro Assembler does not add a leading underscore and
      converts names to all capital letters. To make the assembler
      match the behavior of the C compiler, use the .MODEL directive
      and specify the language. (For example, specify ".MODEL small,
      c.") To make the assembler preserve the case of names, use the
      /Cx assembler switch in Macro Assembler 6.0 and the /MX assembler
      switch in Macro Assembler versions 5.1 and earlier.

5. Q. Can I use Microsoft Programmer's WorkBench version 2.0,
      which comes with Microsoft C/C++ Compiler version 7.0, to invoke
      Microsoft Macro Assembler?

   A. Yes, you can invoke Macro Assembler 6.0 from Programmer's
      WorkBench 2.0. To do this, load the Macro Assembler extension
      file for Programmer's WorkBench (PWBMASM.XXT). This extension
      loads automatically if it has an .MXT extension and is located in
      the same directory as Programmer's WorkBench 2.0. However, this
      file, which is distributed with Programmer's WorkBench 2.0,
      initially has an .XXT extension. Use the MS-DOS RENAME command to
      rename the file from PWBMASM.XXT to PWBMASM.MXT.
   
       NOTE: The .MXT files that ship with Programmer's WorkBench 1.1
       do not work with Programmer's WorkBench 2.0.

6. Q. Why can't I place code at an absolute address with the
      SEGMENT AT and ORG directives?

   A. The linker that comes with Macro Assembler is designed to
      generate relocatable programs that can run under MS-DOS,
      Microsoft Windows, or OS/2. The linker is not designed to
      generate absolute addressable code. Third-party link and locate
      tools that generate absolute addressable code are available.
 
      The ORG directive is meant to give a relative offset to the first
      items in a segment (for example, 100h for .COM files). The
      SEGMENT AT directive is used when you want to access memory that
      is already in the computer at an absolute address (for example,
      the ROM BIOS).

7. Q. Why does my program hang when I return from a procedure?

   A. This problem typically occurs when the stack becomes corrupt. If
      you push any registers onto the stack upon entry into a
      procedure, you must pop those registers off the stack upon exit
      from the procedure. You must have both an equal number of pushes
      and pops and a RET instruction at the end of the procedure.

