Jump to content
Sign in to follow this  
doozer

switch bug or feature?

Recommended Posts

Consider the following code snippit:

main()
{
int a,n;

for (n=0;n<2;n++) {
 switch (n) {
 case 0:
	 a = 9;
	 break;
 case 1:
	 a = 8;
	 break;
 default:
	 a = 8;
 }
}
}

The above code compiles fine.

Now consider the revised fragment:

 

main()
{
int a,n;

for (n=0;n<2;n++) {
 switch (n) {
 case 0:
	 a = 9;
	 break;
 case 1:
 default:
	 a = 8;
 }
}
}

 

Compiling the 2nd example gives the following MPASM error:

...

Assembling...

 

C:\PROGRA~1\MPLABI~1\MCHIP_~1\MPASMWIN.EXE /aINHX8M /pPIC16F877A /rHEX /w2 /q test.asm

 

Error[113]   C:\PROGRAM FILES\PICANT\SAMPLES\C\TEST.ASM 637 : Symbol not previously defined (label_0007)

Done

 

Failed

-----

Is this just a limitation of c2c, or is it a bug?

Share this post


Link to post
Share on other sites
Guest Pavel
So does no reply mean its not a bug?

No reply usually means that nobody looked into the issue yet. Try to find a workaround till the problem is solved.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Guest pcansix

I've found the same huge mistake.

Looking for a reason, one can found a messed up asm generation.

The loop or switch control variable is referenced as n and not, as should be, _n

 

Fix needed, please...

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...