News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Just wondering...

Started by The_Grey_Beast, March 22, 2005, 03:51:36 PM

Previous topic - Next topic

The_Grey_Beast

Can rep be used for other instructions than string operations? For example:

; add ax to itself 6 times
mov ecx, 6
rep add ax, ax


Does the above code work? Thanks.


Tedd

REP is only for MOVS/LODS/CMPS/SCAS/INS/OUTS
For all other instructions it's 'illegal' (technically, it's 'undefined' - ie. you shouldn't use it.)

The LOOP instruction does what you want though (just don't mention this to any of the optimizer freaks :lol)


   mov ecx,6
@loopy:
   add ax,ax
   loop @loopy


(obviously, a number of instructions can go in the 'loop' - as long as the jump is still short)
No snowflake in an avalanche feels responsible.

hutch--


    mov ecx, -6
  @@:
    add ax, ax
    add ecx, 1
    jnz @B

   
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php