I'm not so sure.  If you subtract two numbers of the same sign, you
can't overflow, but the sign of the difference can be positive or
negative depending on the magnitudes of the two operands.  I think the
way I had it before was correct.

On Thu, Jul 5, 2012 at 11:39 AM, Mark Marshall <[email protected]> wrote:
> Hi.
>
> I'm writing some test cases for the carry flags.  This code is wrong:
>
> void func_sub(const Instruction *ins, Pipeline *pipe, bool predicate, Result
> *r) {
>     unsigned long long a, b, c;
>
>     a = pipe->regfile[ins->rs].ui;
>     b = -pipe->regfile[ins->rd].ui;
>     c = a + b;
>
>     compute_result(r, ins, predicate, a, b, c);
> }
>
> It should be
>
> void func_sub(const Instruction *ins, Pipeline *pipe, bool predicate, Result
> *r) {
>     unsigned long long a, b, c;
>
>     a = pipe->regfile[ins->rs].ui;
>     b = pipe->regfile[ins->rd].ui;
>     c = a - b;
>
>     compute_result(r, ins, predicate, a, b, c);
> }
>
> We need to compute_flags on the original values.
>
> MM
>
> On 1 July 2012 20:22, Timothy Normand Miller <[email protected]> wrote:
>>
>> Here you can browse the source of the first compilable version of the
>> OGA2 simulator.
>>
>>
>> http://sourceforge.net/p/openshader/code/ci/9d84745908ebdf51569b5efaa8b718aa4d81ab4b/tree/simulator/
>>
>> My main goal was to get something to compile and run, however trivial.
>>  As a result, there is some truly horrid coding, which I apologize
>> for.  If you pull this tree and 'make' it, you'll get a demo that runs
>> three instructions in an infinite loop.
>>
>> --
>> Timothy Normand Miller, PhD
>> http://www.cse.ohio-state.edu/~millerti
>> Open Graphics Project
>> _______________________________________________
>> Open-graphics mailing list
>> [email protected]
>> http://lists.duskglow.com/mailman/listinfo/open-graphics
>> List service provided by Duskglow Consulting, LLC (www.duskglow.com)
>
>



-- 
Timothy Normand Miller, PhD
http://www.cse.ohio-state.edu/~millerti
Open Graphics Project
_______________________________________________
Open-graphics mailing list
[email protected]
http://lists.duskglow.com/mailman/listinfo/open-graphics
List service provided by Duskglow Consulting, LLC (www.duskglow.com)

Reply via email to