You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MOVB (BX)(R8*4), AH
The assembler accepts this instruction but silently misassembles it to: MOVB (BX)(R8*4), SP
This is because we need the RAX prefix for the indexed address, but then the RAX prefix also forces the use of standard register naming instead of the weird *H register naming.
gas rejects this instruction movb (%rbx,%r8,4),%ah with can't encode register '%ah' in an instruction requiring REX prefix.
But expanding what I said yesterday just a bit: never use MOVB or MOVW with a register destination, since it's inefficient (it's a read-modify-write on the target register). Instead use MOVL for reg->reg and use MOVBLZX or MOVWLZX for mem->reg; those are pure writes on the target register.
Activity
[-]bad assembly accepted, misassembled[/-][+]cmd/asm: bad assembly accepted, misassembled[/+]rsc commentedon Feb 10, 2016
We'll catch this as part of the big asm fixup.
rsc commentedon Feb 10, 2016
But expanding what I said yesterday just a bit: never use MOVB or MOVW with a register destination, since it's inefficient (it's a read-modify-write on the target register). Instead use MOVL for reg->reg and use MOVBLZX or MOVWLZX for mem->reg; those are pure writes on the target register.
rsc commentedon Feb 10, 2016
Actually, on third glance I'm even more surprised you are trying to address AH (not AL). Why?
randall77 commentedon Feb 11, 2016
SSA never uses AH. I just ran into this while writing a test case.
[-]cmd/asm: bad assembly accepted, misassembled[/-][+]cmd/asm: accepts MOVB (BX)(R8*4), AH incorrectly[/+]gopherbot commentedon Oct 19, 2026
Change https://go.dev/cl/849950 mentions this issue:
cmd/internal/obj/x86: reject high byte registers with REX prefixcmd/internal/obj/x86: reject high byte registers with REX prefix