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

Issue with calculating overflow flag(v) in nzcv #1

Open
MohGanji opened this issue Jan 6, 2020 · 1 comment
Open

Issue with calculating overflow flag(v) in nzcv #1

MohGanji opened this issue Jan 6, 2020 · 1 comment

Comments

@MohGanji
Copy link

MohGanji commented Jan 6, 2020

Hi,
We faced an issue with your code in some special case when calculating overflow flag with your method.

Take any arbitrary positive number and 10000000000000000000000000000000. if these are the inputs of CMP or SUB commands, the overflow flag will be set to 0. However, it should be 1. This happens because neg of above number will equal itself, and cin and cout will both be zero.

@MohGanji
Copy link
Author

MohGanji commented Jan 6, 2020

To solve this, you can calculate overflow flag by comparing signs of numbers and the result, like this:

{nzcv[1], result} = op1 - op2;
nzcv[0] = (op1[N-1] ^ op2[N-1]) & (op1[N-1] ^ result[N-1]);

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

No branches or pull requests

1 participant