Searching \ for 'SUBWF v.s. DECF' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=subwf+decf
Search entire site for: 'SUBWF v.s. DECF'.

Truncated match.
PICList Thread
'SUBWF v.s. DECF'
1995\08\30@143432 by David G. Schmidt

picon face
How does the carry bit on a 16c54 work with the DECF opcode?

Using PSIM I saw that the carry bit is cleared when a subtraction results in
a borrow.  If I decrement a variable though, and a borrow occurs, why does
the carry bit not get affected?  The Data sheet on the chip says the DECF
affects the carry bit.  When does it?

Thanks
Dave
Applied Magnetics

1995\08\30@152734 by Mike Keitz

flavicon
face
> How does the carry bit on a 16c54 work with the DECF opcode?
>
It isn't changed.  The DECF affects only the Z flag, setting it if the
result is zero.  If you don't even want to do that, use DECFSZ then NOP,
this affects no flags at all.

Only the add, subtract and rotate instructions affect the carry flag.
Curiously, the RLF and RRF instructions don't affect Z, something else to
keep in mind.

>[...]
>  The Data sheet on the chip says the DECF
>affects the carry bit.

I haven't seen that.  The table in my (1994) book and the quick reference
card say that it doesn't.

-Mike

1995\08\30@165102 by o Soares

flavicon
face
> How does the carry bit on a 16c54 work with the DECF opcode?
>
> Using PSIM I saw that the carry bit is cleared when a subtraction results in
>a borrow.  If I decrement a variable though, and a borrow occurs, why does
>the carry bit not get affected?  The Data sheet on the chip says the DECF
>affects the carry bit.  When does it?
>
>Thanks
>Dave
>Applied Magnetics

Hi Dave.
The carry bit is not affected be INCF or DECF instructions. Only the zero
bit is affected. The instructions that affect the carry bit are:

BSF    STATUS,C        ;C=1
BCF    STATUS,C        ;C=0
CLRF   STATUS          ;C=0
ADDLW  DATA            ;depends of result, 1 if borrow
ADDWF  REG(,W)         ;depends of result, 1 if borrow
RLF    REG(,W)         ;C=MSB of REG
RRF    REG(,W)         ;C=LSB of REG
SUBLW  DATA            ;depends of result, 0 if borrow
SUBWF  REG(,W)         ;depends of result, 0 if borrow

My data sheets told me this and my experience confirms it. I use the
1994 and 1995 data books. I hope this helps.

Fernando Soares

1995\08\30@200249 by Eric Smith

flavicon
face
On Wed, 30 Aug 1995 22:51:20 +0200, Fernando Soares
<spam_OUTFernando.Manuel.Ramos.SoaresTakeThisOuTspamUNINOVA.PT> said:
> The carry bit is not affected be INCF or DECF instructions. Only the zero
> bit is affected. The instructions that affect the carry bit are:
[useful list of instructions deleted]

I suppose I am being nitpicky, but I think it should be pointed out that
any instruction with STATUS as its destination can affect the carry.  So
while INCF and DECF usually don't affect the carry, INCF STATUS will.

While I've never seen any reason to INCF or DECF STATUS, I have seen code that
uses RRF STATUS and RLF STATUS.

Cheers,
Eric

More... (looser matching)
- Last day of these posts
- In 1995 , 1996 only
- Today
- New search...