Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/asm: accepts MOVB (BX)(R8*4), AH incorrectly #14288

Open
randall77 opened this issue Feb 10, 2016 · 4 comments
Open

cmd/asm: accepts MOVB (BX)(R8*4), AH incorrectly #14288

randall77 opened this issue Feb 10, 2016 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@randall77
Copy link
Contributor

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.

@rsc

@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Feb 10, 2016
@bradfitz bradfitz changed the title bad assembly accepted, misassembled cmd/asm: bad assembly accepted, misassembled Feb 10, 2016
@rsc
Copy link
Contributor

rsc commented Feb 10, 2016

We'll catch this as part of the big asm fixup.

@rsc
Copy link
Contributor

rsc commented 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
Copy link
Contributor

rsc commented Feb 10, 2016

Actually, on third glance I'm even more surprised you are trying to address AH (not AL). Why?

@randall77
Copy link
Contributor Author

SSA never uses AH. I just ran into this while writing a test case.

@mdempsky mdempsky modified the milestones: Go1.8, Go1.7 May 19, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 5, 2016
@rsc rsc modified the milestones: Go1.9, Go1.8 Oct 21, 2016
@rsc rsc changed the title cmd/asm: bad assembly accepted, misassembled cmd/asm: accepts MOVB (BX)(R8*4), AH incorrectly Oct 21, 2016
@randall77 randall77 modified the milestones: Go1.10, Go1.9 Jun 26, 2017
@rsc rsc modified the milestones: Go1.10, Go1.11 Nov 22, 2017
@gopherbot gopherbot modified the milestones: Go1.11, Unplanned May 23, 2018
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants