KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q59086: Error C2094: Label "xxx" Was Undefined

Article: Q59086
Product(s): See article
Version(s): 2.00 2.01 2.50 2.51
Operating System(s): MS-DOS
Keyword(s): ENDUSER | s_quickasm S_C | mspl13_c
Last Modified: 18-NOV-1990

The following error occurs with inline assembly if one of the operands
is a hexadecimal value that starts with an alphanumeric character
(A-F, a-f):

   error C2094 : label 'xxx' was undefined

Sample Code
-----------

void main(void)
{
   _asm mov ah, f0h
}

This is expected behavior in inline assembly since "f0h" is a valid C
variable and it is also a valid label name. In the sample code, since
"f0h" was not declared as a variable and there is no label defined as
"f0h", the compiler returns with an error C2094.

To use a hexadecimal value that starts with an alphanumeric character
into a register, there are two options as follows:

1. Assign the value to a variable, then move the contents of the
   variable into the register, as follows:

      unsigned char hex_value = 0xf0;
      void main (void)
      {
         _asm mov ah, hex_value
      }

2. Instead of using Assembler notation (F0h), use C notation for
   the hex value, as follows:

      void main(void)
      {
         _asm mov ah, 0xf0
      }

3. Use a leading 0 (zero) [or multiple leading 0s (zeros)] on the
   MASM-style hex constant. This procedure sets the value for the high
   and low portion of the register, as follows:

      void main(void)
      {
         _asm mov ax, 000f0h
      }

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.

Copyright Microsoft Corporation 1986-2002.