DOCERR: Repeat Prefix (REP) Documentation Error

Last reviewed: November 3, 1994
Article ID: Q66170
The information in this article applies to:
  • Microsoft Macro Assembler for MS-DOS, version 5.0
  • Microsoft Macro Assembler for OS/2, version 5.1

SUMMARY

On Page 368 of the "Microsoft Macro Assembler Programmer's Guide," the last sentence in the second paragraph from the bottom states the following:

   Segment overrides can be used safely when interrupts are turned
   off, when a string instruction is used without a segment override,
   or when a 80386 processor is used.

It should read as follows:

   Segment overrides can be used safely when interrupts are turned
   off, when a string instruction is used without a repeat prefix, or
   when a 80386 processor is used.

MORE INFORMATION

The repeat prefix may be used safely with segment overrides if a CLI instruction is performed before the REP instruction and a STI instruction is performed after it. This process shuts off interrupts during the REP instruction that contains a segment override. Clearing interrupts in this manner is only needed for instructions with segment overrides that are preceded with REP.

Please note that the execution of a repeated instruction can take a considerable amount of time; you may not want to have interrupts shut off for that much time. It is the programmer's responsibility to ensure that interrupts are not missed while interrupts are off.

A better alternative if you are moving a large amount of data is to change the DS register for the duration of the repeated instruction (so that the segment override is not needed) and restore it afterwards.

The following is an example of using the CLI instruction to disable interrupts and using the STI instruction to re-enable them:

    ;   set SI and DI

    MOV CX, 20   ; relatively small number of bytes--won't take long
    CLI
    REP MOVS dest,ES:source
    STI

    ;   ...

The following is an example of temporarily using the DS register to avoid the segment override:

    ;   set SI and DI

    MOV  CX, 4000h ; lots to move -- this will take some time
    PUSH DS        ; save for later
    PUSH ES        ; same as ES: override -- change for other overrides
    POP  DS        ; load into DS
    REP  MOVS dest, source
    POP  DS        ; restore DS


Additional reference words: 5.00 5.10
KBCategory: kbprg kbdocerr
KBSubcategory: MASMLngIss


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: November 3, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.