flat assembler
Message board for the users of flat assembler.

Index > Main > jcxz and JECXZ error

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1088
Roman
I try compile in 64 bits jcxz and JECXZ and get error
illegal instruction.

Op code E3h
Post 08 Jan 2021, 19:53
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1088
Roman
I check in IDA Pro this and get jrcxz !
And this code work fine in IDA Pro.
Code:
mov       ecx,2
ll:  db 0E3h,5 ;this is jrcxz    l2 
     dec cx
     jmp ll
l2:  
    


jrcxz compile ok.
How i understood in 64 bits jecxz not support.
Post 08 Jan 2021, 19:59
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 510
Ali.Z
jcxz cannot be encoded in long-mode.

the default is jrcxz in long-mode.

jecxz is supported by using address size prefix.

_________________
Asm For Wise Humans
Post 08 Jan 2021, 22:04
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1088
Roman
Funny but asm op. code the same.
A mean jrcxz and jecxz have op. code 0E3h
Post 09 Jan 2021, 10:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18489
Location: In your JS exploiting you and your system
revolution
In 64-bit there is no jcxz, The binary code it used for jecxz instead. This is known as a "promoted" instruction, because the base case is jrcxz.

The is the same for pop and push. The same binary code is used for 64-bits push/pop as that used for 32-bit mode. Meaning there is no 32-bit push/pop at all in 64-bit mode.
Post 09 Jan 2021, 10:20
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1779
Furs
Yeah, but jcxz is 16-bit, not 32-bit, so it's not the same as push/pop situation.
Post 09 Jan 2021, 14:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18489
Location: In your JS exploiting you and your system
revolution
Yes, you are correct. I could have made that clearer.
Post 09 Jan 2021, 14:10
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7992
Location: Kraków, Poland
Tomasz Grysztar
This all traces back to how 386 used special prefix rules for LOOP/JCXZ family of instructions. The choice of CX or ECX was controlled (unusually) by 67h prefix, while 66h prefix controlled the size of target address computation. You can easily test all the combinations:
Code:
format PE at 400000h

        jecxz   dword 401000h   ; E3
        jecxz   word 1000h      ; 66 E3
        jcxz    dword 401000h   ; 67 E3
        jcxz    word 1000h      ; 66 67 E3    

In long mode the 67h prefix was kept, this time choosing between RCX and ECX, while 66h was discontinued, as obviously it would be quite useless.
Post 09 Jan 2021, 14:54
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 666
l4m2
So db 4x has totally no effect on E3, right?
Post 19 Jan 2021, 02:18
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 510
Ali.Z
no, because *CX register is used implicitly.

_________________
Asm For Wise Humans
Post 19 Jan 2021, 12:30
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.