The MASM Forum

General => The Campus => Topic started by: xandaz on November 28, 2020, 02:47:52 AM

Title: a masm32 bug?
Post by: xandaz on November 28, 2020, 02:47:52 AM
i have this code
         .elseif ax==IDM_CLOSE
            invoke  CloseHandle,hProject
            mov     ecx,noMdiChild
            or      ecx,ecx
            jz      no_close
loop_3:
            push    ecx
            invoke  SendMessage,hMdi,WM_MDIGETACTIVE,0,0
            invoke  SendMessage,hMdi,WM_MDIDESTROY,eax,0
            pop     ecx
            loop    loop_1
no_close:


gives jumo destination too far: by 214 bytes
Can someone explain this?
Title: Re: a masm32 bug?
Post by: jj2007 on November 28, 2020, 03:00:02 AM
loop_1: is too far.
Title: Re: a masm32 bug?
Post by: xandaz on November 28, 2020, 03:01:56 AM
   yeah...sorry my bad. the error was pointing to next line.
Title: Re: a masm32 bug?
Post by: LordAdef on December 13, 2020, 10:37:51 AM
Sorry, where is loop_1??
Title: Re: a masm32 bug?
Post by: HSE on December 13, 2020, 11:23:36 AM
Quote from: LordAdef on December 13, 2020, 10:37:51 AM
Sorry, where is loop_1??
Quote from: jj2007 on November 28, 2020, 03:00:02 AM
loop_1: is too far.

loop have a limited range, of 128 bytes of opcodes.
Title: Re: a masm32 bug?
Post by: hutch-- on December 13, 2020, 12:35:27 PM
Guys,

Its worth the effort to ditch very old instructions like LOOP and construct your loop code with CMP/Jxx code. its much faster and has no range limitations. Old code like LOOP are junk dumped into microcode in the CPU and are there purely for backwards compatibility. Any modern code (after 1995) is done better with the lower level CMP/Jxx style of code.