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

instructions: support REP prefix #99

Open
mmcloughlin opened this issue Dec 16, 2019 · 8 comments
Open

instructions: support REP prefix #99

mmcloughlin opened this issue Dec 16, 2019 · 8 comments
Labels
enhancement New feature or request instructions Instruction database

Comments

@mmcloughlin
Copy link
Owner

@klauspost has expressed interest in using the REP prefix string instructions.

https://github.com/klauspost/compress/pull/186/files#diff-60d6e6209d2fc7873851f07b946a5dc7R685

Related #85

@mmcloughlin mmcloughlin added enhancement New feature or request instructions Instruction database labels Dec 16, 2019
@mmcloughlin
Copy link
Owner Author

#104 is a useful POC, thanks for the contribution @klauspost. I need to do some more research about how the Go assembler and opcode database handle these instructions, and it might also be useful to see how PeachPy represents them.

Some initial thoughts on the PR #104 itself:

  • I would prefer to keep the original Maratyszcza/Opcodes data file untouched, as it should make it easier to incorporate future updates to that repo. We could still follow the approach in Very basic REP+MOVS support #104 by having an extras.xml or something with the same schema.
  • These forms don't require register arguments in Go assembly (for example REP; MOVSB in runtime/memmove_amd64.s) so they shouldn't in avo either. We would need to use the implicit operands feature here.

Anyway, I need to do some more digging before I can decide on the cleanest way to support this.

@mmcloughlin
Copy link
Owner Author

From the Maratyszcza/Opcodes readme:

Current status section from Maratyszcza/Opcodes readme

Specifically: "Legacy string/streaming instructions (MOVS/SCAS/CMPS/STOS/LODS)"
and "LOCK and REP/REPZ/REPNZ prefixes" are not supported.

avo uses this database as the primary source of instructions, therefore they are currently missing.

@dgryski
Copy link
Collaborator

dgryski commented Jan 1, 2020

Another argument in favor of switching to Intel's data files?

@mmcloughlin
Copy link
Owner Author

Another argument in favor of switching to Intel's data files?

I'm definitely going to have to bite the bullet on this at some point! #23

The asmjit/asmdb database backing asmjit is also quite nice, providing the necessary information for this feature and the LOCK prefix #85. This could be a short term solution preferable to just adding instructions by hand.

https://github.com/asmjit/asmdb/blob/9de003dbe8e28971dfdb9d6345a2b9f0b61f7c92/x86data.js#L185-L202

@klauspost
Copy link
Contributor

These forms don't require register arguments in Go assembly.

I used BLENDVPS as a template, which has xmm0 as an implicit parameter, but it is still sent as parameter. Adding it like this will at least make it clear to the assembler there is a dependency on it and IMO makes it a tiny bit easier to use.

mmcloughlin added a commit that referenced this issue Jan 7, 2020
@mmcloughlin
Copy link
Owner Author

@klauspost Is this issue also blocking you?

@klauspost
Copy link
Contributor

klauspost commented Jan 20, 2020

@mmcloughlin No. I can work around this. Thanks for asking!

@cocotyty
Copy link

cocotyty commented Sep 3, 2023

After four years , avo still dose not support rep instruction.

Here is a demo for some guys who are looking for how to use rep instruction with avo:

	Load(Param("dest").Base(), reg.RDI)
	Load(Param("src").Base(), reg.RSI)
	Load(Param("length"), reg.RCX)
	Instruction(&ir.Instruction{Opcode: "REP"})
	Instruction(&ir.Instruction{Opcode: "MOVSB"})

CrackerCat pushed a commit to CrackerCat/avo that referenced this issue Jul 31, 2024
CrackerCat pushed a commit to CrackerCat/avo that referenced this issue Aug 1, 2024
CrackerCat pushed a commit to CrackerCat/avo that referenced this issue Aug 2, 2024
CrackerCat pushed a commit to CrackerCat/avo that referenced this issue Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request instructions Instruction database
Projects
None yet
Development

No branches or pull requests

4 participants