Hi, I couldn't find this on google, so two quick questions: 1. If you have 0x00 in a reg, then do decf reg,f (therefore reg = 0xFF) does the carry flag get set? 2. If you have 0x00 in the working register and 0x00 in a reg, then you do subwf reg,f will the carry flag get set? I'm getting otherwise inexplicable behaviour from the MPLAB simulator and a 16F84. Thanks for any help ch424
i wouldn't go that far, the sim does have some limitations (thou most seam documented... now) but its often someone does something silly (like let MCLR float) and can't figure out why their code isn't behaving properly. The art of PIC programming is reading the datasheets. Multipule monitors kick arse for this! (or a laptop or something to read the datasheets (product line + device datasheet).
I wouldnt try one for the Mid-Range MCU Family Reference manual though Maybe sections, but not the whole thing.
Ah, great thanks - I hadn't thought of checking the actual datasheet! QUOTE: "2: Yes" explains why I'm getting these problems! I'll have to re-write that bit of the program then! thanks again ch424
Which page http://ww1.microchip.com/downloads/en/DeviceDoc/35007b.pdf I mean how do you know that 0-0 is a carry? It's on page 43, but it doesn't say that there.
It's just due to the way you subtract 2's compliment numbers. ConKbot.. I have the midrange manual, and 16 of the PIC datasheets for 10F, 12F, 16F and 18F series printed out. )
data sheets http://ww1.microchip.com/downloads/en/DeviceDoc/33023a.pdf page 562, explains it in more detail, you see because 0s 2's compliment is 255d how it works. trick with PICs as most digital electronics is skill with the datasheets.