I am ashamed to admit that I am struggling to do this in a PIC18F88.
Subtract 1 from a sixteen bit number and indicate when it goes negative Can anyone spare my blushes? __________________________________________ David C Brown 43 Bings Road Whaley Bridge High Peak Phone: 01663 733236 Derbyshire eMail: [hidden email] SK23 7ND web: www.bings-knowle.co.uk/dcb <http://www.jb.man.ac.uk/~dcb> *Sent from my etch-a-sketch* -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist |
Quick first thought...
Subtract 1 from lower byte. If it goes negative, then you need to subtract 1 from upper byte (else you're done and result is not negative). If decrementing upper byte goes negative, then there's your negative flag. Cheers, -Neil. On 2/22/2021 2:21 PM, David C Brown wrote: > I am ashamed to admit that I am struggling to do this in a PIC18F88. > Subtract 1 from a sixteen bit number and indicate when it goes negative > Can anyone spare my blushes? > __________________________________________ > David C Brown > 43 Bings Road > Whaley Bridge > High Peak Phone: 01663 733236 > Derbyshire eMail: [hidden email] > SK23 7ND web: www.bings-knowle.co.uk/dcb > <http://www.jb.man.ac.uk/~dcb> > > > > *Sent from my etch-a-sketch* -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist |
Yeh. I was getting confused about knowing when it was negative.
Carry being clear when it goes negative always confuses me. But I am OK now, thanks __________________________________________ David C Brown 43 Bings Road Whaley Bridge High Peak Phone: 01663 733236 Derbyshire eMail: [hidden email] SK23 7ND web: www.bings-knowle.co.uk/dcb <http://www.jb.man.ac.uk/~dcb> *Sent from my etch-a-sketch* On Mon, 22 Feb 2021 at 19:34, Neil <[hidden email]> wrote: > Quick first thought... > Subtract 1 from lower byte. > If it goes negative, then you need to subtract 1 from upper byte (else > you're done and result is not negative). > If decrementing upper byte goes negative, then there's your negative flag. > > Cheers, > -Neil. > > > > On 2/22/2021 2:21 PM, David C Brown wrote: > > I am ashamed to admit that I am struggling to do this in a PIC18F88. > > Subtract 1 from a sixteen bit number and indicate when it goes negative > > Can anyone spare my blushes? > > __________________________________________ > > David C Brown > > 43 Bings Road > > Whaley Bridge > > High Peak Phone: 01663 733236 > > Derbyshire eMail: [hidden email] > > SK23 7ND web: www.bings-knowle.co.uk/dcb > > <http://www.jb.man.ac.uk/~dcb> > > > > > > > > *Sent from my etch-a-sketch* > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist |
Free forum by Nabble | Edit this page |