ARM7
ARM7 copied to clipboard
Issue with calculating overflow flag(v) in nzcv
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.
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]);