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

Failed to encode comparison immediate #234

Open
abrown opened this issue Aug 4, 2020 · 2 comments
Open

Failed to encode comparison immediate #234

abrown opened this issue Aug 4, 2020 · 2 comments

Comments

@abrown
Copy link

abrown commented Aug 4, 2020

@markcharney, I think I found an issue where xed-asmparse-main fails to encode the instruction when the immediate is 0:

$ xed-asmparse-main 'cmpps xmm7, xmm15, 0'
Forcing mode to 64b based on regs used
Guessing 32b EOSZ
MODE=64, EOSZ=32
ERROR: Failed to encode input: GENERAL_ERROR

$ xed-asmparse-main 'cmpps xmm7, xmm15, 1'
Forcing mode to 64b based on regs used
Guessing 32b EOSZ
MODE=64, EOSZ=32
Result: 41 0f c2 ff 01

I wouldn't expect that first one to fail, but maybe I'm doing something wrong?

@markcharney markcharney self-assigned this Aug 4, 2020
@markcharney
Copy link
Contributor

I looked. Use 00 instead of 0 and it'll work fine.

This is a little quirk of the parser for numbers that begin with 0's. For numbers that begin with zero's it assumes hex and it assumes someone was trying to specify some explicit hex value with a specific width. So it sees 0, one nibble, so 4 bits. And then the encoder says there is no such cmpps with a 4b immediate, which is technically true. Possibly I should change this. I'll think about it.

For values that do not begin with 0, it just gives 1/2/4/8 bytes (mutiplied by 8 for bits) depending on the actual numerical value.

@abrown
Copy link
Author

abrown commented Aug 4, 2020

Ah, I see. I would have expected 0x... to parse as hex values and un-prefixed numerics to parse as decimal values.

For values that do not begin with 0, it just gives 1/2/4/8 bytes (mutiplied by 8 for bits) depending on the actual numerical value.

To make sure I understand, un-prefixed numerics are parsed as decimals?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants