CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

garbage char at end of string using latest PCM compiler

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
carterson2



Joined: 27 Aug 2006
Posts: 5
Location: Memphis

View user's profile Send private message Visit poster's website

garbage char at end of string using latest PCM compiler
PostPosted: Sun Aug 27, 2006 4:17 pm     Reply with quote

Hi,
Thanks for reading! I mean it! Any help appreciated. Rgds, Jim Pruett

Q: Why doesnt the following one-line program give any warnings?

#include <16f877a.h>
#pragma fuses NOWDT,HS, PUT, NOPROTECT, NODEBUG, BROWNOUT, NOLVP, NOCPD, NOWRT
#define compiler __PCM__

void lcdPutChar(char c) { }

void main() {
lcdPutChar("StuffOnMars ");
}

//-------------------//
You might say, "well the arguments are wrong". Ok, so why no warning?
Note: I use +DF +LN +T -A +M -Z +Y=0 +EA +EW
Whats weird is that the code works great, Except for
it writes out the NULL at the end of the string... Eg: it writes:
"StuffOnMars|"

You can see the problem/compiler-bug? in the listing below.
See the call(NULL)

2: #device PIC16F877A
0004 100A BCF 0xa, 0
0005 108A BCF 0xa, 0x1
0006 110A BCF 0xa, 0x2
0007 0782 ADDWF 0x2, F
0008 3453 RETLW 0x53
0009 3474 RETLW 0x74
000A 3475 RETLW 0x75
000B 3466 RETLW 0x66
000C 3466 RETLW 0x66
000D 344F RETLW 0x4f
000E 346E RETLW 0x6e
000F 344D RETLW 0x4d
0010 3461 RETLW 0x61
0011 3472 RETLW 0x72
0012 3473 RETLW 0x73
0013 3420 RETLW 0x20
0014 3400 RETLW 0
//
0000 3000 MOVLW 0
0001 008A MOVWF 0xa
0002 2816 GOTO 0x16
0003 0000 NOP
3: #include <16f877a.h>
4:
6: void lcdPutChar(char c)
7: {
8:
9: }
0015 3400 RETLW 0
10:
11:
12:
13: void main()
14: {
0016 0184 CLRF 0x4
0017 1383 BCF 0x3, 0x7
0018 301F MOVLW 0x1f
0019 0583 ANDWF 0x3, F
001A 1683 BSF 0x3, 0x5
001B 141F BSF 0x1f, 0
001C 149F BSF 0x1f, 0x1
001D 151F BSF 0x1f, 0x2
001E 119F BCF 0x1f, 0x3
001F 3007 MOVLW 0x7
0020 009C MOVWF 0x1c
0021 1283 BCF 0x3, 0x5
15:
16: lcdPutChar("StuffOnMars ");
0022 01A1 CLRF 0x21
0023 0821 MOVF 0x21, W
0024 2004 CALL 0x4
0025 3800 IORLW 0
0026 1903 BTFSC 0x3, 0x2
0027 282C GOTO 0x2c
0028 0AA1 INCF 0x21, F
0029 00A2 MOVWF 0x22
002A 2015 CALL 0x15 //this is correct
002B 2823 GOTO 0x23
002C 00A2 MOVWF 0x22
002D 2015 CALL 0x15 //This is wrong? CALL(arg=NULL)
17:
18:
002E 0063 SLEEP

//-----------end of listing--------------------
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Aug 27, 2006 4:47 pm     Reply with quote

Quote:
garbage char at end of string using latest PCM compiler
Please mention your version number. Referring to the latest compiler version is relative, next month someone scanning the archive will not know which version was the most recent version.
In fact, right now I don't know which version you mean. the latest stable version v3.249 or the v4.0xx beta version?

Quote:
Q: Why doesnt the following one-line program give any warnings?
Because it is valid code in CCS-C.
(CCS Manual March 2006, page 77) wrote:
A (non-standard) feature has been added to the compiler to help get around the problems created by the fact that pointers cannot be created to constant strings. A function that has one CHAR parameter will accept a constant string where it is called. The compiler will generate a loop that will call the function once for each character in the string.
Example:
void lcd_putc(char c ) {
...
}
lcd_putc ("Hi There.");


The output of the NULL character is strange, but without knowing your exact version number I can't test this.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group