What have you done with Joe ???????????????????? I know he can handle this easily. Give him his grain back and let him get on with it. Binary numbers wrap around. Anything going past the top starts again from the bottom and vive versa - a= s I know Joe knows. If you map other number systems (such as decimal) onto the binary count you follow the count (money?) where it leads. Let's use a nice 3 bit counter to keep life easy. Binary / Decimal 000 0 001 1 010 2 011 3 100 4 101 -3 110 -2 111 -1 (Confusing aside:You can get one more +ve range count than -ve range count as 0 steals what would have been the most negative place in 2's complement notation.) If you insist on counting backwards from the "top" past where your system allow you to you "com in via the back door" So 111 -1 110 -2 101 -3 100 -4 <- wraps into +ve space 011 -5 010 -6 001 -7 000 -8 <- at bottom of positive space 111 -9 <- back in negative space again - 2^N counts lower than the first time. ie locations repeat each multiple of 2^N counts with value 2^N different than before. A lot easier to do some counting while reasing this that trying to follow tis blind. Russell On 4 January 2011 15:24, IVP wrote: > Hi all, and hi to my brain, wherever it went for Christmas. Come > back soon, miss you > > I'm trying to rationalise this testing and limiting to express it in > assembler > > If Result > 32767 then Result =3D 32767 > > If Result < -32768 then Result =3D -32768 > > It would help if I could get an idea of how more-negative works > past 16 bits. I've not found anything specifically useful after some > looking around > > In this example, -32768 - (+20) > > mov #20,w0 ;temp0 =3D 20 =3D 0x0014 > mov w0,temp0 > mov -#32768,w1 ;temp1 =3D -32768 =3D 0x8000 > mov w1,temp1 > > mov temp0,w0 > mov temp1,w1 > sub w0,w1,w2 ;w2 =3D 0x8014 =3D -32748 > > In this example, -32768 - (-20) > > mov -#20,w0 ;temp0 =3D -20 =3D 0xFFEC > mov w0,temp0 > mov -#32768,w1 ;temp1 =3D -32768 =3D 0x8000 > mov w1,temp1 > > mov temp0,w0 > mov temp1,w1 > sub w0,w1,w2 ;w2 =3D 0x7FEC =3D -20 (bit15 =3D 0= ) > > Questions - > > (1) what does - 32769 look like ? > (2) what would be a method to test for < -32768 on a dsPIC ? > > Should I be looking at the 40-bit Accumulators for this ? > > TIA > > Joe > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .