Searching \ for '[PIC]: 16-bit 16c7xx comparison code' 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/microchip/devices.htm?key=16C
Search entire site for: '16-bit 16c7xx comparison code'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 16-bit 16c7xx comparison code'
2001\04\10@135127 by M Core

picon face
Hi,
 I was just wondering if anyone had some code they could just throw on here
for checking if X:H,L < Y:H,L (and X > Y)- both RAM variables (16-bit).

 Yes, I checked the FAQ and I just was curious because there is some 16-bit
stuff there but the one by Scott Dattalo who said "...it'd be much quicker
to:..." appears to be wrong. And I'm looking for an 'optimized' simplest
method.
The problem I noticed is he substracts lower byte first, and checks if Z=1,
if not he adds one to the upper bit for carry propagation. However, he must
be assuming he wont come accross the case where there is no borrow ?! i.e.
A06-A05 = 1 C=1,Z=0 - which shouldn't add to the high byte of the 16 bit
number, but A06-A07 C=0, Z=0 should add to the MSB.... that code in the FAQ
adds in both cases to the upper byte.




_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\10@194549 by Antonio L Benci

flavicon
picon face
part 1 1489 bytes content-type:text/plain; charset=us-ascii (decoded 7bit)

Try the following attached code.

M Core wrote:
{Quote hidden}

Nino.
--
------------------------------------------------------
| Antonio (Nino) L. Benci                            |
| Professional Officer, Electronic Services          |
| School of Physics & Materials Engineering          |
| Monash University                                  |
| email: .....nino.benciKILLspamspam@spam@spme.monash.edu                  |
| T: 61 3 9905 3649. F: 61 3 9905 3637               |
| M: 0414 924 833                                    |
------------------------------------------------------


part 2 1544 bytes content-type:application/x-unknown-content-type-asm_auto_file; (decode)

part 3 586 bytes content-type:text/x-vcard; name=Nino.Benci.vcf; charset=us-ascii
(decoded 7bit)

begin:vcard
n:Benci;Antonio L
tel;cell:0414 924 833
tel;fax:+61 3 9905 3637
tel;home:0414 924 833
tel;work:+61 3 9905 3649
x-mozilla-html:FALSE
url:http://www.physics.monash.edu.au/~ninob
org:Monash University;School of Physics & Materials Engineering
version:2.1
email;internet:Nino.BencispamKILLspamspme.monash.edu
title:Professional Officer, Electronic Services
adr;quoted-printable:;;PO Box 27=0D=0ASchool of Physics and Materials Engineering=0D=0AMonash University;Monash University;VIC;3800;Australia
x-mozilla-cpt:;10672
fn:Antonio L Benci
end:vcard


part 4 136 bytes
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2001\04\10@233834 by Scott Dattalo

face
flavicon
face
On Wed, 11 Apr 2001, Antonio L Benci wrote:

> Try the following attached code.
>
> M Core wrote:
> >
> > Hi,
> >   I was just wondering if anyone had some code they could just throw on here
> > for checking if X:H,L < Y:H,L (and X > Y)- both RAM variables (16-bit).
> >
> >   Yes, I checked the FAQ and I just was curious because there is some 16-bit
> > stuff there but the one by Scott Dattalo who said "...it'd be much quicker
> > to:..." appears to be wrong. And I'm looking for an 'optimized' simplest
> > method.
> > The problem I noticed is he substracts lower byte first, and checks if Z=1,
> > if not he adds one to the upper bit for carry propagation. However, he must
> > be assuming he wont come accross the case where there is no borrow ?! i.e.
> > A06-A05 = 1 C=1,Z=0 - which shouldn't add to the high byte of the 16 bit
> > number, but A06-A07 C=0, Z=0 should add to the MSB.... that code in the FAQ
> > adds in both cases to the upper byte.
> >

(I accidently deleted the original post - hence the double quotes).

Could you post the code in question? If you're refering to the classic 6
instruction subtract:

;XH:XL  YH:YL

          movf    yl,w
          subwf   xl,w
          movf    yh,w
          skpz
;; piclist webpage has this-->  incf yh,w  ;propagate the carry from the...
           incfsz yh,w  ;propagate the carry from the low byte subtraction.
            subwf xh,w

          skpnc
           goto   x_is_greater_than_or_equal_to_y



I'm not the original author. I think Bob also got accused of writing that code
too. But in reality it predates both of us by years. There's nothing wrong with
the code, by the way (except that the incf should've been an incfsz).

Scott

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2001\04\11@004749 by M Core

picon face
From:  Scott Dattalo <scottspamspam_OUTDATTALO.COM>
Subject:  Re: [PIC]: 16-bit 16c7xx comparison code
Date:  Tue, 10 Apr 2001 22:33:19 -0500
MIME-Version: 1.0


Could you post the code in question? If you're refering to the classic 6
instruction subtract:

;XH:XL  YH:YL

          movf    yl,w
          subwf   xl,w
          movf    yh,w
          skpz
;; piclist webpage has this-->  incf yh,w  ;propagate the carry from the...
           incfsz yh,w  ;propagate the carry from the low byte subtraction.
            subwf xh,w

          skpnc
           goto   x_is_greater_than_or_equal_to_y


The code you posted was the one I had in question, it has incf instead of
incfsz, so your fix is correct. Hopefully someone will update that then ;)

Thanks
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2001\04\11@005827 by Antonio L Benci

flavicon
picon face
part 1 1556 bytes content-type:text/plain; charset=us-ascii (decoded 7bit)

I re-attached it. I wrote this code about 6 years ago...

Scott Dattalo wrote:
{Quote hidden}

Nino.
--
------------------------------------------------------
| Antonio (Nino) L. Benci                            |
| Professional Officer, Electronic Services          |
| School of Physics & Materials Engineering          |
| Monash University                                  |
| email: KILLspamnino.benciKILLspamspamspme.monash.edu                  |
| T: 61 3 9905 3649. F: 61 3 9905 3637               |
| M: 0414 924 833                                    |
------------------------------------------------------


part 2 1544 bytes content-type:application/x-unknown-content-type-asm_auto_file; (decode)

part 3 586 bytes content-type:text/x-vcard; name=Nino.Benci.vcf; charset=us-ascii
(decoded 7bit)

begin:vcard
n:Benci;Antonio L
tel;cell:0414 924 833
tel;fax:+61 3 9905 3637
tel;home:0414 924 833
tel;work:+61 3 9905 3649
x-mozilla-html:FALSE
url:http://www.physics.monash.edu.au/~ninob
org:Monash University;School of Physics & Materials Engineering
version:2.1
email;internet:RemoveMENino.BenciTakeThisOuTspamspme.monash.edu
title:Professional Officer, Electronic Services
adr;quoted-printable:;;PO Box 27=0D=0ASchool of Physics and Materials Engineering=0D=0AMonash University;Monash University;VIC;3800;Australia
x-mozilla-cpt:;10672
fn:Antonio L Benci
end:vcard


part 4 105 bytes
--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu


2001\04\11@011410 by James Newton

face picon face
Updated the page at
www.piclist.com/techref/microchip/compcon.htm
anybody want to write a macro that incorporates EVERY one of the
optimizations listed at that page? <GRIN>

And thanks for letting me know that the page was wrong.

James Newton, PICList Admin #3
TakeThisOuTjamesnewtonEraseMEspamspam_OUTpiclist.com
1-619-652-0593 phone
http://www.piclist.com

{Original Message removed}

2001\04\11@175557 by M Core

picon face
Hi Scott,
 Just looking at that code again - I'm not sure now that your incfsz will
even fix it. For example if you have the number:

x0201 = X and xff02 = Y
then we will get to the incfsz point in the code and
the ff MSB will be incremented to 0, and the subtraction is skipped,
then it checks the C bit - which the incfsz instruction does not set - so
there is still problems with that code because the C bit is set from the LSB
previous subtraction still, but we are looking at the MSB now...






From:  Scott Dattalo <RemoveMEscottspamTakeThisOuTDATTALO.COM>
Subject:  Re: [PIC]: 16-bit 16c7xx comparison code
Date:  Tue, 10 Apr 2001 22:33:19 -0500
MIME-Version: 1.0

I'm not the original author. I think Bob also got accused of writing that
code
too. But in reality it predates both of us by years. There's nothing wrong
with
the code, by the way (except that the incf should've been an incfsz).

Scott


_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestEraseMEspam.....mitvma.mit.edu


2001\04\11@185616 by Scott Dattalo

face
flavicon
face
On Wed, 11 Apr 2001, M Core wrote:

> Hi Scott,
>   Just looking at that code again - I'm not sure now that your incfsz will
> even fix it. For example if you have the number:
>
> x0201 = X and xff02 = Y
> then we will get to the incfsz point in the code and
> the ff MSB will be incremented to 0, and the subtraction is skipped,
> then it checks the C bit - which the incfsz instruction does not set - so
> there is still problems with that code because the C bit is set from the LSB
> previous subtraction still, but we are looking at the MSB now...


Sigh, there are two mistakes (so far) in that snippet.

        ;XH:XL  YH:YL

          movf    yl,w
          subwf   xl,w
          movf    yh,w
          skpc          ;(was skpz)
           incfsz yh,w  ;(was incf)
            subwf xh,w

          skpnc
           goto   x_is_greater_than_or_equal_to_y

There are 8 instructions, so there may be 6 more mistakes!

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2001\04\12@125844 by jamesnewton

face picon face
Updated again.
---
James Newton (PICList Admin #3)
RemoveMEjamesnewtonEraseMEspamEraseMEpiclist.com 1-619-652-0593
PIC/PICList FAQ: http://www.piclist.com or .org

{Original Message removed}

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