Searching \ for 'MPLABC bugs?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/microchip/languages.htm?key=mplab
Search entire site for: 'MPLABC bugs?'.

Truncated match.
PICList Thread
'MPLABC bugs?'
1997\02\12@143631 by Geoff Cox

flavicon
face
I have been developing for the 16C65A for a few days now, and seem to already have uncovered 2 bugs with the MPLABC compiler (details below).

I am using "V1.10 Released". Is this already known to be fairly buggy, and should I be using something else?

------
BUG #1
------

void NW_SEND_STRING (byte *the_string) {
   while ((the_char = *the_string) != 0) {
       NW_SEND_CHAR(the_char);
       the_string++;
   }
}

This routine, when executed, consistently caused a stack overflow. I determined that the routine was not correctly detecting a zero on the end of the string argument. In otherwords, the "!= 0" in the second line of the code isn't working.

The code assembled as follows:

0056                              void NW_SEND_STRING (byte *the_string) {
0071 1283    BCF    03,5
0072 00D6    MOVWF  56
0073 0804    MOVF   04,W
0074 00D7    MOVWF  57
0075 287D    GOTO   007Dh             while ((the_char = *the_string) != 0) {
0076 307F    MOVLW  7Fh          
0077 1283    BCF    03,5          
0078 0557    ANDWF  57,W          
0079 008A    MOVWF  0A            
007A 3001    MOVLW  01h          
007B 0756    ADDWF  56,W          
007C 0082    MOVWF  02            
007D 2076    CALL   0076h        
007E 1283    BCF    03,5          
007F 00D5    MOVWF  55            
0080 1903    BTFSC  03,2     <------------notice here    
0081 288A    GOTO   008Ah        
0082                                      NW_SEND_CHAR(the_char);
0082 1283    BCF    03,5
0083 0855    MOVF   55,W
0084 2058    CALL   0058h
0085 1283    BCF    03,5                  the_string++;
0086 0AD6    INCF   56
0087 1903    BTFSC  03,2
0088 0AD7    INCF   57
0089 2875    GOTO   0075h             }
008A 0008    RETURN               }


I flowcharted this code, and determined that the line I have highlighted ("notice here") is where the test "!= 0" requires that the zero bit of the status word be correctly set. The W register does contain zero when I expect it to, but it hasn't been tested, so the test does not work properly.

------
BUG #1
------

At the place marked "observe here" in the code below, the compiler is adding 1 to an index before fetching a byte of data which is stored using the RETLW construct. However, the data is a string which happens to cross the boundary from 0x1FF to 0x200. Notice that the addition of the 1 to address 6A is not carried to the high byte in 6B. Thus, the Program Counter (registers 0A and 02) is incorrectly set to address 0x100 instead of 0x200, and all is lost.

006A                              void NW_SEND_STRING (byte *the_string) {
0070 1283    BCF    03,5
0071 00EA    MOVWF  6A
0072 0804    MOVF   04,W
0073 00EB    MOVWF  6B
                                     do {
0074 287C    GOTO   007Ch                 Char_Sent = *the_string;
0075 307F    MOVLW  7Fh
0076 1283    BCF    03,5
0077 056B    ANDWF  6B,W         <-----the high byte
0078 008A    MOVWF  0A
0079 3001    MOVLW  01h          <-----observe here (adding one to...)
007A 076A    ADDWF  6A,W         <-----observe here (...the low byte )
007B 0082    MOVWF  02
007C 2075    CALL   0075h
007D 1283    BCF    03,5
007E 00E8    MOVWF  68
007F 08E8    MOVF   68                    if (Char_Sent != 0)                  
                                               NW_SEND_CHAR(Char_Sent);
0080 1903    BTFSC  03,2
0081 2885    GOTO   0085h
0082 1283    BCF    03,5
0083 0868    MOVF   68,W
0084 2057    CALL   0057h
0085 1283    BCF    03,5                 the_string++;
0086 0AEA    INCF   6A
0087 1903    BTFSC  03,2
0088 0AEB    INCF   6B
                                     }
0089 08E8    MOVF   68                while (Char_Sent != 0);
008A 1D03    BTFSS  03,2
008B 2874    GOTO   0074h
008C 0008    RETURN               }

Any comments welcome.

Cheers,
       Geoff.

Geoff Cox                                 Manager - Discrete Products
Eurotherm Controls Inc                           Phone (703) 471-4870
11485 Sunset Hills Rd.                             Fax (703) 787-3447
Reston, VA 22090               EMAIL spam_OUTGeoff.CoxTakeThisOuTspamControls.Eurotherm.Com
                                           HOME EMAIL .....PNJSKILLspamspam@spam@Nicom.Com

[Do not] put too much confidence in experimental results until they have
been confirmed by theory.---Sir Arthur Eddington

1997\02\12@152631 by John Dammeyer

flavicon
face
At 02:24 PM 12/02/1997 -0500, you wrote:
>I have been developing for the 16C65A for a few days now, and seem to
already have uncovered 2 bugs with the MPLABC compiler (details below).
>
>I am using "V1.10 Released". Is this already known to be fairly buggy, and
should I be using something else?

I finally gave up on MPLABC after chasing those kinds of bugs and falling
further and further behind on my project.  I switched over to MPC directly
from Bytecraft and my bad code generation problems went away except for one.
I duplicated the problem in a small test program and emailed it to
Bytecraft. Walter Banks at Bytecraft emailed me a Rev C later that day that
solved that problem.  Apparently that was the first bug found that actually
prevented further work.

So,  yes,  I am a satisfied customer but I did have to work around compiler
inconsistancies.  For example:

pHexChar = &NetMsg.Parameters.PARAMDATA[bufindex];

generates invalid code - First it makes the correct indexed pointer and then
promptly writes over it with the wrong value.

The work-around is:

pHexChar = &NetMsg.Parameters.PARAMDATA[0]+bufindex;
and generates one extra instruction.

Note that the manual states that the above C statement that failed is not
supported so to give credit where credit is due, I was breaking the rules.
<sigh>



Cheers,
John

Pioneers are the ones, face down in the mud,
with arrows in their backs.
Automation Artisans Inc.      Ph. 1-250-544-4950
PO Box 20002                  Fax 1-250-544-4954
Sidney, BC CANADA V8L 5C9

1997\02\12@211651 by treefrog

flavicon
face
Geoff,
 I started with V1.10 of MPLAB and have upgraded to V1.40 or something
like that I cannot remember.  That seemed to take care of most of my
problems with the W register.  You can get the newest version at
http://www.microchip.com



Matthew


At 02:24 PM 2/12/97 -0500, you wrote:
>I have been developing for the 16C65A for a few days now, and seem to
already have uncovered 2 bugs with the MPLABC compiler (details below).
>
>I am using "V1.10 Released". Is this already known to be fairly buggy, and
should I be using something else?
{Quote hidden}

determined that the routine was not correctly detecting a zero on the end
of the string argument. In otherwords, the "!= 0" in the second line of the
code isn't working.
{Quote hidden}

("notice here") is where the test "!= 0" requires that the zero bit of the
status word be correctly set. The W register does contain zero when I
expect it to, but it hasn't been tested, so the test does not work properly.
>
>------
>BUG #1
>------
>
>At the place marked "observe here" in the code below, the compiler is
adding 1 to an index before fetching a byte of data which is stored using
the RETLW construct. However, the data is a string which happens to cross
the boundary from 0x1FF to 0x200. Notice that the addition of the 1 to
address 6A is not carried to the high byte in 6B. Thus, the Program Counter
(registers 0A and 02) is incorrectly set to address 0x100 instead of 0x200,
and all is lost.
{Quote hidden}

Matthew J. Klueppel                Software Development Engineer

****************************************************************
The Connor-Winfield Corporation
2111 Comprehensive Drive Aurora, Illinois 60505
Phone: 630-851-4722, Fax: 630-851-5040, Work: 630-851-4722 E.128
****************************************************************
1601 Elm Park Ridge, Illinois 60068
Phone: 847-698-9838, Car: 708-280-5014
****************************************************************
E-mail: EraseMEtreefrogspam_OUTspamTakeThisOuTwebspun.com
       cwolinsspamspam_OUTorion.it.luc.edu
       @spam@mklueppelKILLspamspamconwin.com
****************************************************************
http://www.webspun.com/treefrog
****************************************************************
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2

mQCNAzFN9bEAAAEEAJu6HCD3uDqFfP+m8md9dx+eYdqnUS0RbPqqd3iKDU/BbI9W
l63dk5GK0jzMri+Ow9Wp0gEAUkEVI/Safy6kDnfl+fagmPMXyWwaqnJ+QKF3P0Z4
fG/tYzhNu4RkTyVYAvL/v5CaNuTa5Li28ffbFLFgjy8mt7Dlqf8Z/tRMB1o1AAUT
tC5NYXR0aGV3IEouIEtsdWVwcGVsIDxjd29saW5zQG9yaW9uLml0Lmx1Yy5lZHU+
-----END PGP PUBLIC KEY BLOCK-----

1997\02\12@234613 by tjaart

flavicon
face
John Dammeyer wrote:
{Quote hidden}

Hooorraay! I thought I was the only sod developing a peptic ulcer
because of
MPLABC. The joke (sic) is that there is a beta (the 256 line demo) of
the new
release, but there is no way I can get any kind of upgrade until the
middle of
this year, or the turn of the century.

The official Microchip line I received was :
"We don't want to release untested software to paying customers."
The reality is, however, that all the MPLABC users are also paying for
time
spent wondering what the heck is going wrong in their PIC code, and some
of us
(hint, hint) are MORE than willing to test beta versions.

I don't think I should start on MPLAB bugs, lest the PIClisters get a
tear
or two in their eyes ;)

Hey, Microchip! Yoohoo! Hallooooo!

--
Friendly Regards

Tjaart van der Walt
KILLspamtjaartKILLspamspamwasp.co.za
_____________________________________________________________
| Another sun-deprived R&D Engineer slaving away in a dungeon |
|             ASP International  http://wasp.co.za            |
|             GSM and GPS value-added applications            |
|  Voice : +27-(0)11-622-8686   |   Fax : +27-(0)11-622-8686  |
|_____________________________________________________________|

1997\02\13@020307 by James Musselman
flavicon
face
Tjaart van der Walt sharpened his pencil and wrote:

>I don't think I should start on MPLAB bugs, lest the PIClisters get a
>tear
>or two in their eyes ;)
>
>Hey, Microchip! Yoohoo! Hallooooo!
>
>--

I've been afraid to even take the shrink wrap off of my Microchip C compiler.

Of all the C compilers out there, do any of them support the 17CXX parts,
even the 17C756?

Do any of the existing compilers support the good stuff:  arrays of
structures, pointers to functions, and so on, or is it sort of hit and miss?

James

1997\02\13@023457 by John Dammeyer

flavicon
face
At 10:55 PM 12/02/1997 -0800, you wrote:
>Tjaart van der Walt sharpened his pencil and wrote:
>
>>I don't think I should start on MPLAB bugs, lest the PIClisters get a
>>tear
>>or two in their eyes ;)
>>
>>Hey, Microchip! Yoohoo! Hallooooo!
>>
>>--
>
>I've been afraid to even take the shrink wrap off of my Microchip C compiler.
>
>Of all the C compilers out there, do any of them support the 17CXX parts,
>even the 17C756?

Just another reason for changing to MPC.  17C42 is supported.
>
>Do any of the existing compilers support the good stuff:  arrays of
>structures, pointers to functions, and so on, or is it sort of hit and miss?

Some of it is hit and miss.  Think about it though;  the underlying machine
your compiling code for.  The C language implimented for a PIC as you get it
is nowhere near real C and can't ever be that.  True,  an implimentation
using pseudo heaps and stacks is possible for passing huge arrays and lots
of local variables but then you still only have a few bytes of RAM
available.  No complete implimentation of an HLL like C can run with so
little code and data space.  That was one of the first things I had to
re-orient myself to.  I wasn't writing in C I was writing in a simple
Algorithmic language that had much of the syntax of C.  Only then did I
become more productive and have fewer problems.

For example,  It's just not worth passing parameters to functions in most
cases.  The two byte size parameters are immediately placed into the W and
the FSR, then your function is called and then inside your function put into
the local RAM storage.  Except you can't overlay that RAM with any other
locals so it's gone forever.  Takes less code to just set the parameters
into overlayed locals yourself and then call the function ala assembler.
Not as neat but takes less space.

Cheers,

John
Pioneers are the ones, face down in the mud,
with arrows in their backs.
Automation Artisans Inc.      Ph. 1-250-544-4950
PO Box 20002                  Fax 1-250-544-4954
Sidney, BC CANADA V8L 5C9

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