Searching \ for 'Dumb question' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=dumb+question
Search entire site for: 'Dumb question'.

Truncated match.
PICList Thread
'Dumb question'
1998\03\03@063507 by Peter Baines

flavicon
face
hello folks,
               I know this is a dumb question and I will probably want to crawl
into a
hole when I get the answer but ..... does anybody have some code to
subtract one 16 bit number from another NOT using 2s compliment so that it
returns an ABS result with a flag (AKA register) to say if it is negative.

P.

====================================
Remember .... Every Silver Lining
Has It's Cloud
====================================
Mailto:spam_OUTefocTakeThisOuTspamcyberstop.net

1998\03\03@115208 by Andrew Warren

face
flavicon
face
Peter Baines <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

> does anybody have some code to subtract one 16 bit number from
> another NOT using 2s compliment so that it returns an ABS result
> with a flag (AKA register) to say if it is negative.

Peter:

This routine computes DEST = DEST - SOURCE.  After it executes, the
Carry flag is valid (i.e., Carry = 0 if the result is negative,
Carry = 1 if the result is zero or positive).  Note that the Zero
flag is NOT necessarily valid after execution.

   MOVF   SOURCELO,W
   SUBWF  DESTLO
   MOVF   SOURCEHI,W
   SKPC
   INCFSZ SOURCEHI,W
   SUBWF  DESTHI

-Andy

=== Andrew Warren - fastfwdspamKILLspamix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1998\03\04@041652 by Caisson

flavicon
face
----------
> Van: Peter Baines <.....efocKILLspamspam.....CYBERSTOP.NET>
> Aan: EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
> Onderwerp: Dumb question
> Datum: dinsdag 3 maart 1998 12:32
>
> hello folks,
>                 I know this is a dumb question and I will probably want
to crawl into a
> hole when I get the answer but ..... does anybody have some code to
> subtract one 16 bit number from another NOT using 2s compliment so that
it
> returns an ABS result with a flag (AKA register) to say if it is
negative.
>
> P.

Take the 2's complement of your answer _IF_ you get a Borrow (Not-Carry)
from your subtraction.

Remember my son, don't fight the force of your opponent, but use it to get
what
you want .... (You didn't want to use 2's complement, I'm using it twice
:-)

Greetz,
 Rudy Wieser

1998\03\04@152042 by Ray Gardiner

flavicon
face
{Quote hidden}

Peter,
Try this... returns ABS(DEST-SOURCE) in DEST

       MOVF   SOURCELO,W
       SUBWF  DESTLO
       MOVF   SOURCEHI,W
       SKPC
       INCFSZ SOURCEHI,W
       SUBWF  DESTHI
;
       SKPNC
       GOTO DONE        ; DEST > SOURCE
                        ;
       COMF    DESTLO   ; NEGATE if SOURCE > DEST
       INCF    DESTLO
       SKPNZ
       DECF    DESTHI
       COMF    DESTHI

DONE    ; DEST = ABS( DEST - SOURCE )

I don't know if there is any simpler way, seem like there
should be some cleverer way of doing the subtract.


Ray Gardiner (DSP Systems) @spam@rayKILLspamspamdsp-systems.com http://www.dsp-systems.com
private email to:- KILLspamrayKILLspamspamnetspace.net.au


'Dumb Question'
2003\07\29@233526 by Adi Linden
flavicon
face
Ok, it's late and I am tired and I can't wrap my head around attaching an
LCD with Hitachi controller and a 3x4 keypad to the same single 8-bit
port. Some hints would be much appreciated.

Adi

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

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