Author Topic: error: cannot use high register in rex instruction  (Read 11447 times)

Offline Olsonist

  • Jr. Member
  • *
  • Posts: 26
error: cannot use high register in rex instruction
« on: January 01, 2017, 07:35:58 PM »
According to the Intel manual:

***In 64-bit mode, r/m8 can not be encoded to access the following byte registers if a REX prefix is used: AH, BH, CH, DH.

So mov R8B,BH can't assemble. I know that.

%use      smartalign
ALIGNMODE   generic,16
BITS      64

section      .text

      mov      R8B,BH  ; assembly error
      mov      AH,AL   ; no assembly error
      mov      BH,BPL  ; assembly error

nasm -f macho64 xx.s -o xx.o
xx.s:7: error: cannot use high register in rex instruction
xx.s:9: error: cannot use high register in rex instruction

This is in 64-bit mode. mov AH,AL assembles. The third move gets the cannot use high register in rex instruction error.
Is this correct? I don't believe that mov BH,BPL generates a REX prefix. Is this a NASM bug?

Edit: Well, I'm seeing from other sources that BPL requires a REX prefix. I didn't know that or rather it didn't sink in. So I'll have to move my register assignments around.
« Last Edit: January 01, 2017, 08:56:09 PM by Olsonist »