Searching \ for 'STATUS flags' 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=status+flags
Search entire site for: 'STATUS flags'.

Truncated match.
PICList Thread
'STATUS flags'
1998\01\28@203651 by tsk3000

picon face
Hey all!

This is just a little somthing that I wanted to verify...

I am using 'subwf' on a 16C54 to compare two bytes, and I saw in the
programmers manual how the Carry flag is set... the Zero flag is still
set according to the result, correct?  Really, I'm doing a greater
than/less than/equal to thing, so, first I should check the Z flag to
see if the result was zero, if it was, I'll branch, if not, then test
the C flag and go from there, right?

So, when using 'subwf':
If (f) - (W) is positive,
  (f) > (W) / Z = 0, C = 1.
If (f) - (W) is zero,
  (f) = (W) / Z = 1, C = 1.
If (f) - (W) is negative,
  (f) < (W) / Z = 0, C = 0.

Is everything I said about the flags correct?

Thanks again,
--
~Keith
spam_OUTtsk3000TakeThisOuTspamProdigy.Net
http://pages.prodigy.net/tsk3000/

1998\01\29@004411 by Andrew Warren

face
flavicon
face
Keith Burzinski <.....tsk3000KILLspamspam@spam@Prodigy.Net> wrote:

> I am using 'subwf' on a 16C54 to compare two bytes, and I saw in the
> programmers manual how the Carry flag is set... the Zero flag is
> still set according to the result, correct?

   Correct, Keith.

> Really, I'm doing a greater than/less than/equal to thing, so,
> first I should check the Z flag to see if the result was zero, if
> it was, I'll branch, if not, then test the C flag and go from
> there, right?

   Actually, it'll be faster to check the C flag first, then only
   check the Z flag if the C flag was set... That way, you only
   check one flag when the result is negative (a much more-likely
   occurence than a "0" result).

> So, when using 'subwf':
> If (f) - (W) is positive,
>    (f) > (W) / Z = 0, C = 1.
> If (f) - (W) is zero,
>    (f) = (W) / Z = 1, C = 1.
> If (f) - (W) is negative,
>    (f) < (W) / Z = 0, C = 0.
>
> Is everything I said about the flags correct?

   Yes, if you treat the contents of "f" and "w" as unsigned (i.e.,
   non-negative) numbers.

   -Andy

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

1998\01\31@153141 by tsk3000

picon face
Andrew Warren wrote:
{Quote hidden}

Okay, this works!  Thanks!

Now I've run into another problem, though.  What's the quickest way to
check if a number is negative?  Can I just test bit 7?  I just tried
subtracting 0 from the register using 'subwf', but that seems to
_always_ leave the C flag set.  And if I add 0 using 'addwf', it always
leaves the C flag clear.  Will just tesing bit 7 of the reg always work?

Thanks again,
--
~Keith
.....tsk3000KILLspamspam.....Prodigy.Net
http://pages.prodigy.net/tsk3000/

1998\01\31@160502 by Andrew Warren

face
flavicon
face
Keith Burzinski <EraseMEtsk3000spam_OUTspamTakeThisOuTProdigy.Net> wrote:

> What's the quickest way to check if a number is negative?  Can I
> just test bit 7?

   Yes.

> I just tried subtracting 0 from the register using 'subwf', but
> that seems to _always_ leave the C flag set.

   Of course it does; SUBWF treats the two numbers as UNSIGNED
   (i.e., non-negative), so subtracting 0 always gives (as far as
   SUBWF is concerned) a non-negative result.

> And if I add 0 using 'addwf', it always leaves the C flag clear.

   This happens because the ADDWF instruction only sets the carry
   flag if the result is greater than 255, and adding 0 to an 8-bit
   number can NEVER result in an answer that's greater than 255.

> Will just tesing bit 7 of the reg always work?

   Yes.

   -Andy

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

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