Skip to content

Improve INTEL_MASM formatter style#543

Open
widberg wants to merge 3 commits intozyantific:masterfrom
widberg:master
Open

Improve INTEL_MASM formatter style#543
widberg wants to merge 3 commits intozyantific:masterfrom
widberg:master

Conversation

@widberg
Copy link

@widberg widberg commented Dec 7, 2024

I made fixes for the INTEL_MASM formatter style to get it closer to emitting assembly MASM accepts. This should be enough of an improvement to close #535.

I added the style to ZydisInfo and added tests. I also needed to change how the formatted buffer and restore worked since I couldn't get it to omit the first operand of FUCOMP without also omitting the mnemonic. There's a good chance this wasn't necessary and I was doing something wrong. These changes should also fix #497.

MASM doesn't have a mnemonic for the F1 opcode like int1 in other assemblers, so I made it emit INVALID_MNEMONIC in that case. It is possible to use a byte directive to emit the byte value directly but that seems out of scope for Zydis, if there is a different way you want this to be handled let me know. For int3 I had to break it up into int 3h for MASM to emit the CC opcode, I did this pretty hackily in the MASM format instruction function so that other hooks would still be able to handle it normally, let me know of a better way.

This is my first PR here so please let me know what I need to change to get this merged. I would like to see MASM support improve.

@widberg widberg marked this pull request as ready for review December 10, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zydis Formats Invalid MASM With INTEL_MASM undocumented/unintended ZYDIS_FORMATTER_FUNC_POST_OPERAND behavior

1 participant