gnupic@linuxhacker.org

gnupic@linuxhacker.org


Subject: Re: SDCC/PIC Newbie questions
From: Greg Hill
Date: Wed, 24 Sep 2003 09:09:33 -0600 (MDT)

You're doing fine.

> 	BSF	(_NOT_POR >> 3), (_NOT_POR & 7)

I can't find exactly where the definition is located just now (should be
somewhere in the .h file sdcc used), but it turns out that the constant
_NOT_POR actually has two pieces of information in it. This is a favorite
method used by systems programming people to store two numbers but only
use one name. In this case, the lowest three bits are interpreted as one
field, and the remaining upper bits are interpreted as a second field. The
first field indicates which bit of the sfr (special function register?) we
want to write to, and the second field indicates the register number.

This is why you see the >> and & operators in the statement.
(_NOT_POR >> 3) removes the "which bit" field, leaving only the "register
number" field. (_NOT_POR & 7) gets the "which bit" field and masks out
the "register number" field.

Greg

gnupic@linuxhacker.org