x86asm: disassemble CMP instruction's arguments in the opposite order

That way it matches what the compiler's -S flag generates, and what we write
in assembly.

  CMP AX, $16
  JLE foo

should get to foo if AX <= 16. Without this CL, the disassembly looks like

  CMP $16, AX
  JLE foo

which reads like we should get to foo if 16 <= AX, which is not what these
two instructions actually do.

It was originally this way because the CMP instruction parallels the SUB
instruction, except it throws away the non-flags result. We write that
subtraction as

  SUB $16, AX  // AX <- AX-16

but we don't need to match the SUB's disassembly order, as CMP is not
writing to a register output.

Update golang/go#60920
(This fixes the underlying issue, but the actual "fixes" comment needs to go
on the CL that vendors x/arch containing this CL into the main branch.)

Change-Id: Ifa8d3878453d6e33ae144bfdb01b34171c2106a1
Reviewed-on: https://go-review.googlesource.com/c/arch/+/505375
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 files changed
tree: 61ed10c6c0163c64bbd4134b07a06c6cc24dcc4b
  1. arm/
  2. arm64/
  3. ppc64/
  4. x86/
  5. codereview.cfg
  6. CONTRIBUTING.md
  7. go.mod
  8. go.sum
  9. LICENSE
  10. PATENTS
  11. README.md
README.md

arch

Go Reference

This repository holds machine architecture information used by the Go toolchain. The parts needed in the main Go repository are copied in.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.

The main issue tracker for the arch repository is located at https://github.com/golang/go/issues. Prefix your issue with “x/arch:” in the subject line, so it is easy to find.