parisc asm questions

John Marvin jsm@udlkern.fc.hp.com
Sat, 21 Oct 2000 16:32:06 -0600 (MDT)


Randolph,

The add instruction doesn't use the carry bit as input, but it does
produce a carry bit.  The addc instruction both uses and produces a carry
bit.  The addi instruction also does not use the carry bit as input, but
it does produce a carry bit (I use the term "carry bit", although the
architecture has a set of "carry/borrow bits", but in terms of the
instructions referenced here, only one of the bits matters, so I refer to
it as the carry bit).

So I see a variety of problems with your examples:

1) Your first loop uses addc, which means that it will use the carry bit,
which may be in an undefined state the first time you execute it, if you
have done nothing to set it the way you want.  You can either use an add
instruction before the loop to do the first add, or you can do an "add
%r0,%r0,%r0" to clear the carry bit before the loop.

2) The addi in the loop messes with the carry bit, which you don't want.
In most cases it will set the carry bit, unless %arg1 is less than 4.
The normal convention would be to use ldo -4(%arg1),%arg1 instead.
The addib instruction is ok, since it does not use or set the carry
bit.

3) In the second loop the add instruction is not a noop, since it has the
effect of clearing the carry bit.