Truncated match.
PICList
Thread
'SUBWF v.s. DECF'
1995\08\30@143432
by
David G. Schmidt
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
> 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
> 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
On Wed, 30 Aug 1995 22:51:20 +0200, Fernando Soares
<spam_OUTFernando.Manuel.Ramos.SoaresTakeThisOuT
UNINOVA.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...