PRB: No Error for Same Register Listed Twice in USES Clause

Last reviewed: January 9, 1995
Article ID: Q72727
The information in this article applies to:
  • Microsoft Macro Assembler for MS-DOS, versions 6.0, 6.0a, and 6.0b
  • Microsoft Macro Assembler for OS/2, versions 6.0, 6.0a, and 6.0b

SYMPTOMS

The USES clause was added to the PROC directive with the release of the Microsoft Macro Assembler (MASM) version 6.0. With USES, it is possible to specify the registers that your procedure will use. The assembler will then save the registers on the stack at function entry and restore them upon exit, saving the programmer from having to do so.

If you mistakenly list the same register twice in the USES clause, MASM will not generate a warning. The assembler will generate code to push and pop the register twice.

CAUSE

This is correct behavior. It is the programmer's responsibility to catch this type of error.

MORE INFORMATION

The sample code below illustrates this situation. In this example, the ES, DI, DS, SI, and CX registers were meant to be saved. However, DI is inadvertently saved twice, and SI is not saved at all.

Sample Code

; Assemble Options Needed: /Fl /Sg /c

.MODEL small, c .STACK 4096 .DATA

.CODE StrCmp PROC USES es di ds di cx,

             string1:FAR PTR, string2:FAR PTR, len:WORD
        CLD
        MOV   cx, len
        LES   di, string1
        LDS   si, string2
        REPE  cmpsb
        MOV   ax, cx
StrCmp ENDP END


Additional reference words: 6.00
KBCategory: kbtool kbprb
KBSubCategory: MLIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 9, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.