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

Semantic bug in LZCNT #515

Closed
basavesh opened this issue Jul 12, 2023 · 0 comments · Fixed by #516
Closed

Semantic bug in LZCNT #515

basavesh opened this issue Jul 12, 2023 · 0 comments · Fixed by #516
Assignees

Comments

@basavesh
Copy link
Collaborator

basavesh commented Jul 12, 2023

LZCNT instruction computes wrong value as it doesn't take care of the size parameter.

For example: executing LZCNT_16 R10 R12 -> lzcntw %r12w, %r10w leads to different values in Jasmin and H/W asm.

Before execution:

R10: 11689315489894297136
R12: 6104740341430370735

After execution in Jasmin:

R10: 11689315489894236176
R12: 6104740341430370735

After execution in H/W asm:

R10: 11689315489894236161
R12: 6104740341430370735

More details below:

Jasmin single step:

Initial state:
ip: 0
RAX: 12779401926263320820
RCX: 11809738235967653070
RDX: 14235405625157437496
RBX: 8305324555075843050
RSP: 11998830535613101673
RBP: 10095525653015111164
RSI: 15237392406662427857
RDI: 5050672628792123946
R8: 3481965236275870841
R9: 14865427843756515456
R10: 11689315489894297136
R11: 7207364775942046353
R12: 6104740341430370735
R13: 7896153421605611015
R14: 784843899963345240
R15: 4150172742681634750

Running instruction:
        lzcntw  %r12w, %r10w
        
New state:
ip: 1
RAX: 12779401926263320820
RCX: 11809738235967653070
RDX: 14235405625157437496
RBX: 8305324555075843050
RSP: 11998830535613101673
RBP: 10095525653015111164
RSI: 15237392406662427857
RDI: 5050672628792123946
R8: 3481965236275870841
R9: 14865427843756515456
R10: 11689315489894236176
R11: 7207364775942046353
R12: 6104740341430370735
R13: 7896153421605611015
R14: 784843899963345240
R15: 4150172742681634750

H/W single step:
Before:
Screenshot 2023-07-12 at 11 16 57 AM

After:
Screenshot 2023-07-12 at 11 18 15 AM

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

Successfully merging a pull request may close this issue.

1 participant