CensoredUsername / dynasm-rs

A dynasm-like tool for rust.
https://censoredusername.github.io/dynasm-rs/language/index.html
Mozilla Public License 2.0
705 stars 52 forks source link

Add support for direct stores (MOVDIRI) #90

Open eigenform opened 3 months ago

eigenform commented 3 months ago

Adds support for MOVDIRI instructions, and a feature flag for the associated "Direct Store" extension (in recent Intel microarchitectures).

This extension also includes the MOVDIR64B instruction, but I decided not to include it here because I have no particular use for it, and it wasn't immediately obvious how I should specify the encoding.

CensoredUsername commented 3 months ago

Heya, that looks pretty good. I see your issue with MOVDIR64B, right now the formatting logic doesn't have a way to specify a 64-byte memory address (and for the matter there's also no literal to specify that for the memory operand. It'd probably be ZWORD if we were to add one.

If you still want to take a stab at that you need to first add an entry for the size enum. It goes up to 32 bytes right now with HWORD. Honestly that whole naming convention there has been getting worse and worse there, and it's internal use only, so feel free to pick a name like B64 instead for this size.

Then at the parser you'd need to add another x64 name to the list that parses to that size hint. I think the correct thing here would be ZWORD, following nasm.

The trickiest changes will be here. Pick an unused letter to use for this new size constraint, and probably just copy the logic for HWORD as this shouldn't require any possible wildcarding.

And then you can use your new size constraint to specify a new format string.

Otherwise, this looks good and tests well, so I can add it no problem.

CensoredUsername commented 2 months ago

I've merged this into dev manually. I also wanted to try get movdir64b in there but turns out that next to the 512-bit memory operand, it has another constraint no other instruction has where the bare register size has to match in size with the memory operand address size.

I'll have to add another flag or two to handle that one. Address size overrides were like the one regular thing in the x64 instruction set. Mind if I keep this one open until that's done?

eigenform commented 2 months ago

Sorry, haven't had a chance to look at this in more detail. Yep, no worries here. Thanks!