I know this is a dumb question and I will probably want to crawl
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.
Remember .... Every Silver Lining
Has It's Cloud
Peter Baines <MITVMA.MIT.EDU> wrote: PICLIST
> 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.
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.
=== Andrew Warren - ix.netcom.comfastfwd
=== Fast Forward Engineering - Vista, California
> Van: Peter Baines <CYBERSTOP.NET> efoc
> Aan: MITVMA.MIT.EDUPICLIST
> 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
> returns an ABS result with a flag (AKA register) to say if it is
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
you want .... (You didn't want to use 2's complement, I'm using it twice
Try this... returns ABS(DEST-SOURCE) in DEST
GOTO DONE ; DEST > SOURCE
COMF DESTLO ; NEGATE if SOURCE > DEST
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) dsp-systems.com rayhttp://www.dsp-systems.com
private email to:- netspace.net.auray
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.
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email mitvma.mit.edu with SET PICList DIGEST in the body listserv
More... (looser matching)
- Last day of these posts
- In 2003
, 2004 only
- New search...