ARM7 icon indicating copy to clipboard operation
ARM7 copied to clipboard

Issue with calculating overflow flag(v) in nzcv

Open MohGanji opened this issue 5 years ago • 1 comments

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 avatar Jan 06 '20 16:01 MohGanji

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]);

MohGanji avatar Jan 06 '20 16:01 MohGanji