Ok thanx, it works now! But... why a need for parentheses?
BTW there are a smallest and optimized way to do the same thing:
while (*LCD & MASK_BUSYFLAG); /* wait busy flag */
From: Eric Norum [mailto:e.norum@...]=20
Sent: Thursday, April 04, 2002 12:14 AM
To: EVANDRO LUIZ HAUENSTEIN
Subject: Re: [Sdcc-user] bit ordering (endian mode) bug?
On Wednesday, April 3, 2002, at 08:22 PM, EVANDRO LUIZ HAUENSTEIN wrote:
> something wrong with the asm code...
> #define MASK_BUSYFLAG 0x80
> #define BUSYFLAG 0x80
> /* LCD is a xdata pointer to 0xE002 */
> while (*LCD & MASK_BUSYFLAG =3D=3D BUSYFLAG); /* wait busy flag */
The problem is with your code. You need parentheses around the (*LCD &=20
Eric Norum <eric.norum@...>
Department of Electrical Engineering
University of Saskatchewan
Phone: (306) 966-5394 FAX: (306) 966-5407
From: Bodo Wenzel <bodowenzel@we...> - 2002-04-07 17:23:20
> Ok thanx, it works now! But... why a need for parentheses?
Because "==" has a higher priority than "&" (The C programming language,
ANSI-version, K & R). And the boolean result is stored in bit 0. So writing
'a & b == b' means implicitely 'a & (b == b)' equal to 'a & 1', but you ment
'(a & b) == b'.
> BTW there are a smallest and optimized way to do the same thing:
> while (*LCD & MASK_BUSYFLAG); /* wait busy flag */
Is it really worth to do the job of an optimizing compiler? I didn't take a
look at the listing, but I think '(a & b) == b' produces the same code like
'a & b', doesn't it? The best code to express what you mean might be '(a & b)
!= 0'. An "if" should always and ever get a boolean, it helps understanding
what the author ment ;-)
Get latest updates about Open Source Projects, Conferences and News.