|
From: Royce & S. Pereira. <be...@im...> - 2001-09-18 10:10:49
|
Insert a break; before each of the case statements, so that the program
doesnt carry on right upto pos=0x80;
In the present case no matter what the value of pos, it always ends up
containing 0x80;
SDCC is smart enough to figure this out & ignores the earlier case
statements!!
-Royce.
----- Original Message -----
From: "Matthias Weißer" <wei...@t-...>
To: <sdc...@li...>
Sent: Saturday, September 15, 2001 8:09 PM
Subject: [Sdcc-user] Problem with the switch statement
> Hi
>
> the SDCC (latest winbin (cygwin.dll version)) makeing this
>
> 00123$:
> mov a,r4
> add a,acc
> add a,r4
> mov dptr,#00124$
> jmp @a+dptr
> 00124$:
> ljmp 00103$
> ljmp 00104$
> ljmp 00105$
> ljmp 00106$
> ljmp 00107$
> ljmp 00108$
> ljmp 00109$
> ljmp 00110$
> ; grafik.c 253
> 00103$:
> ; grafik.c 255
> 00104$:
> ; grafik.c 257
> 00105$:
> ; grafik.c 259
> 00106$:
> ; grafik.c 261
> 00107$:
> ; grafik.c 263
> 00108$:
> ; grafik.c 265
> 00109$:
> ; grafik.c 267
> 00110$:
> mov r4,#0x80
>
> out of
>
> switch(pos)
> {
> case 0:
> pos = 0x01;
> case 1:
> pos = 0x02;
> case 2:
> pos = 0x04;
> case 3:
> pos = 0x08;
> case 4:
> pos = 0x10;
> case 5:
> pos = 0x20;
> case 6:
> pos = 0x40;
> case 7:
> pos = 0x80;
> }
>
> I think this couldn't be right? Or what i'm doing wrong?
>
>
>
> Matthias Weißer
>
> Wer einen Rechtschreibfehler findet darf ihn behalten
>
> http://www.matwei.de/
> mat...@ma...
>
>
>
> _______________________________________________
> Sdcc-user mailing list
> Sdc...@li...
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
|