Searching \ for '12 bit signed compare' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: '12 bit signed compare'.

Truncated match.
PICList Thread
'12 bit signed compare'
1995\07\05@062916 by Siegfried Grob

Hello Antonio and all of the PICLIST,

An obvious attempt to solve the 12bit signed compare task maybe the following:

12bit integers range from -2048..2047 (if I calculated right). If you add 2048
to each of the numbers, you can now do an unsigned compare, which should not
be a real problem for you. Adding 2048 can easily be done by inverting (xor-ing)
the 12th bit. If you add #8 to the high byte (= 12th bit) instead, be careful
to clear the 13th bit.

The other way would be to expand the 12bit integer into a 16bit integer and do
the (signed) comparison with 16bit. Expansion is done by setting bits 13..16
equal to bit 12, e. g. if bit 12=1 (integer negative), then bit13..16 := 1111,
else if bit12=0 (integer non-negative), then bit 13..16 := 0000.

A 16bit compare can be found somewhere in the Embedded Control Handbook, I
assume. Wasn't this problem already discussed several weeks/months ago in the

Siegfried Grob

---- the orginial message was: --------------------------------------

From:   Antonio L. Benci ("spam_OUTNino.BenciTakeThisOuTspamSCI.MONASH.EDU.AU"TakeThisOuTspamumcTakeThisOuTspamMFSERV)
Date:    5-JUL-1995 01:54:28.29
To:     Multiple recipients of list PICLIST
Subj:   12 Bit signed compare. HELLLPPPPPP.

I am having trouble in writing code for the PIC16C71 to compare two
12bit 'signed' numbers. Once the comparison is done I need to save
the lesser of the 12bit number, for example;

       LOADA   word1       ;get 12 bit signed value into acca
       CMPA    word2       ;compare word1 to word2
       BLE     savewd1     ;if word1 << word2 then save word1
       STORA   word2       ;if word1 >> word2, save word1 -> word2
       STORA   rseln       ;save word1 value

Excuse the mnemonics chosen. I hope that its clear as to what I need
to do. Any pointers would be appreciated.

Nino Benci
* EMAIL -       *                         *

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