The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on July 31, 2008, 01:11:47 PM

Title: jnz to offset problem
Post by: ragdog on July 31, 2008, 01:11:47 PM
Hi

I have a small problem!


with the call works perfect,why noz with this jnz jump?


. Data
Proc1 dd 0049E103h
Lable1 dd 005438DDh
Call dword ptr [Proc1]; Works
..
..
jnz dword ptr [Lable1]; Works not

I get this error message, error A2077: instruction does not allow NEAR indirect addressing

have your an idea?

greets,
ragdog
Title: Re: jnz to offset problem
Post by: FORTRANS on July 31, 2008, 01:49:30 PM
Hi,

   Basically, what the error message says.  A CALL can have
different forms.

It can CALL with an offset (direct)
It can CALL using a value in a register or memory (indirect)
It can CALL using an absolute value.

   But a conditional jump can only be done using an offset.
So the JNZ instruction does not allow indirect addressing.

Greets,

Steve N.
Title: Re: jnz to offset problem
Post by: PBrennick on July 31, 2008, 02:42:16 PM
This is an untested idea -- you might be able to put that pointer into a variable and to something like

jnz eax

The reason this might work is because the address is resolved by putting it into a variable and then becomes a direct branch.

Let me know if it works.

-- Paul
Title: Re: jnz to offset problem
Post by: ragdog on July 31, 2008, 07:27:36 PM
hi

I have with this way solved!

       jnz    @F
       ...
       ..
       .
@@:
       jmp dword ptr [Lable1]

greets
Title: Re: jnz to offset problem
Post by: Tedd on August 01, 2008, 03:08:35 PM
The conditional jumps only allow an 8-bit displacement, so if you want anything different (larger displacement, direct address, indirect address, etc) the best you can do is jcc to another jmp that goes where you really want.

(Which is what you did :wink)
Title: Re: jnz to offset problem
Post by: FORTRANS on August 05, 2008, 01:59:00 PM
   Actually, since the 386 the displacement can be 16 or 32 bits for Jcc (Jump
condition code).  LOOP and JCXZ seem to remain 8 bit.

Regards,

Steve N.