KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q34501: word Causes "Illegal Operand Size" Warning

Article: Q34501
Product(s): See article
Version(s): 5.10   | 5.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_masm
Last Modified: 12-JAN-1989

The following command causes the warning "illegal operand size:"

lds  dx, word ptr [bp+6]

However, using dword assembles clean.

The line is from the code below. The procedure foo function
receives a pointer to a string and writes it to the screen.

It accept dword and not word because the LDS assembler instruction
reads and stores a far pointer specified by the source-memory operand.
Using the word type should cause a warning with small model.
The following sample code demonstrates the problem:

 .model     medium

 .code
            PUBLIC  _foo
_foo        PROC
            push    bp
            mov     bp, sp

            lds     dx, word ptr [bp+6]    ;causes 'illegal operand size'.
                                           ;but not with use of 'dword'

            mov     ah, 40h
            mov     bx, 1
            mov     cx, 17
            int     21h

            pop     bp
            ret
_foo        ENDP
            END

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.