Author Topic: I want to produce 2 byte code with JECXZ instruction in long mode....  (Read 3469 times)

Offline kono

  • Jr. Member
  • *
  • Posts: 3
Hi, in long mode I'm coding
Code: [Select]
jecxz label
label:
and NASM produces 3 byte instruction code.
If it is possible, how can I force NASM to produce 2 byte wide code?

Offline sapero

  • Jr. Member
  • *
  • Posts: 9
Re: I want to produce 2 byte code with JECXZ instruction in long mode....
« Reply #1 on: August 30, 2010, 06:06:21 AM »
Turning ON basic optimizations with -O1 switch, generates "E3 00".

Offline kono

  • Jr. Member
  • *
  • Posts: 3
Re: I want to produce 2 byte code with JECXZ instruction in long mode....
« Reply #2 on: August 30, 2010, 07:13:29 AM »
Thanks for reply.
Doing this makes a lot of error messages to appear. Now I have not time to rewrite the entire code. I think I will use jrcxz instead jecxz, this produce 2 byte code and no error messages.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2379
  • Country: us
Re: I want to produce 2 byte code with JECXZ instruction in long mode....
« Reply #3 on: August 30, 2010, 01:51:06 PM »
In the most recent versions of Nasm, "-O1" actually reduces the optimization - "-Ox" is the default. I hope all the error messages were "short jump out of range". If not, that may be a bug(?)...

If "jrcxz" is what you want, that's what you should use. The "third byte" with "jecxz" is 0x67 - the "address size override prefix". Although you might expect 0x66, the "operand size override prefix", 0x67 is correct for "j?cxz" (was a bug in 0.98). "jcxz" is apparently "not supported in 64-bit mode"...

Best,
Frank


Offline kono

  • Jr. Member
  • *
  • Posts: 3
Re: I want to produce 2 byte code with JECXZ instruction in long mode....
« Reply #4 on: September 01, 2010, 04:47:20 AM »
With jrcxz I achieve 2 byte instruction. I have not hex editor, I know this after testing it with the TIMES command. And yes, at now this make the work for me, becouse the timing for this instruction appears to be the same when operating with diferent size registers, and becouse the upper 32 bits of the RCX are set to 0 before I execute the jrcxz instruction.

Yes, when I use "-O1" almost all of the errors are the "jump out of range" type. I probably dont use the last version of NASM but it works at now and I am content :) .