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
Milestone

Comments

@randall77
Copy link
Contributor

@randall77 randall77 commented Feb 10, 2016

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

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Feb 10, 2016

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

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc 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

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Feb 10, 2016

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

@randall77

This comment has been minimized.

Copy link
Contributor Author

@randall77 randall77 commented Feb 11, 2016

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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.