[A86] Re: Comparing signed numbers


[Prev][Next][Index][Thread]

[A86] Re: Comparing signed numbers




Crap! I didnt think it was /that/ easy...
The results I was getting were wrong because my routine was for the max of 4 
signed numbers no wonder. So something else must be wrong on that routine.  
Thanks for you help! (Jonah, always the one with the quick email responses! 
:)
Now this is searchable for,
greater than
less than
signed numbers
negatives
compare
bigger
smaller
two's complement

And here is some source confirming this:

#include "ti86asm.inc"

.org _asm_exec_ram

ProgStart:
call _clrLCD
call _homeup
ld a,2
ld b,-2
cp b
jp p,aissignedandbigger
bissignedandbigger:
ld hl,bisbigger
jp _puts
aissignedandbigger:
ld hl,aisbigger
jp _puts


aisbigger:
.text "a bigger"
bisbigger:
.text "b bigger"


.end


Ricky Cobb III
arcadesdude@hotmail.com
icq 41440378

----------------ORIGINAL MESSAGE----------------
>From: ComAsYuAre@aol.com
>Reply-To: assembly-86@lists.ticalc.org
>To: assembly-86@lists.ticalc.org
>Subject: [A86] Re: Comparing signed numbers
>Date: Sat, 9 Jun 2001 08:48:33 EDT
>
>In a message dated 6/9/2001 8:40:00 AM Eastern Daylight Time,
>arcadesdude@hotmail.com writes:
>
>
> > Ive looked all over and this list is my last resort.
> >
> > What I need to know is this:
> >
> > How do you compare 2 signed (ranging from -127 to
> > 127) numbers and jr/jp on the biggest of the two?
> >
> > I know for unsigned numbers its as simple as
> >
> > getmax:
> > ld a,1
> > ld b,2
> > cp b
> > jr nc,aisbigger
> >
> > But when working with negatives the negative number
> > is assumed bigger (because its 7th bit is set).
> >
> > I looked around and saw the 'p' and 'm' flag are for
> > something like this but Im not sure if they just
> > return 'p'ositive or 'm'inus for a number or if they
> > are like the greater or less than flags (nc and c
> > respectively)
> >
> > Would it be as simple as this for negative numbers?
> >
> > getmaxofsigned:
> > ld a,2
> > ld b,-2
> > cp b
> > jp p,aissignedandbigger
> >
>
>Yes.  :-)
>
>
>----
>Jonah Cohen
><ComAsYuAre@aol.com>
>http://jonah.ticalc.org
>
>
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com