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 CCS Technical Support

#asm i can't compile asm part

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








#asm i can't compile asm part
PostPosted: Tue Apr 26, 2005 2:14 pm     Reply with quote

i get this code form http://www.ccsinfo.com/forum/viewtopic.php?t=17170&

i cant compile asm part. compiler highlights comma shown in red below, and says "expecting an identifier".

on first asm line:
MOVF DATA , W //copy pointer to first

i'm trying on pic18f452. DVDB says it working, but i can't do it.

i need help. thanks.

Code:

int calc_CRC(int* data,int byte_cntr)
{

int crc=0;

#ASM
     MOVF   DATA , W       //copy pointer to first databyte..
     MOVWF  FSR           //..to pointer register

loop:
     MOVF   INDF,W       //load w with next databyte
     xorwf crc,f        // xor with accumulated crc (accumulated crc is no longer valid now)
     movlw 0            //w will ccumulate the new crc
     btfsc crc,0
     xorlw 0x5e         //could also be iorlw
     btfsc crc,1
     xorlw 0xbc
     btfsc crc,2
     xorlw 0x61
     btfsc crc,3
     xorlw 0xc2
     btfsc crc,4
     xorlw 0x9d
     btfsc crc,5
     xorlw 0x23
     btfsc crc,6
     xorlw 0x46
     btfsc crc,7
     xorlw 0x8c
     movwf crc          //store accumulated crc
     INCF   FSR         //increment indirection register  to point to next databyte
     decfsz byte_cntr,F
     goto loop          //next databyte
                      //done, crc is in w

     movwf crc           //store in result
   

#ENDASM


return(crc);
}
[url][/url]
Guest








PostPosted: Tue Apr 26, 2005 2:16 pm     Reply with quote

i forgot to say, i tested with data, DATA (lowercase, uppercase)
still same.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 26, 2005 2:24 pm     Reply with quote

I made a full test program, and added definitions for your FSR and INDF
symbols, and it then compiled OK with PCM vs. 3.224.

Code:
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#define FSR   4
#define INDF  0

int calc_CRC(int* data, int byte_cntr);

//=================
void main()
{
char array[10];
char count;

calc_CRC(array, count);


while(1);
}
//===================================

int calc_CRC(int* data, int byte_cntr)
{

int crc=0;

#ASM
     MOVF   DATA , W       //copy pointer to first databyte..
     MOVWF  FSR           //..to pointer register

loop:
     MOVF   INDF,W       //load w with next databyte
     xorwf crc,f     // xor with acc'd crc (acc'd crc is no longer valid now)
     movlw 0        //w will ccumulate the new crc
     btfsc crc,0
     xorlw 0x5e         //could also be iorlw
     btfsc crc,1
     xorlw 0xbc
     btfsc crc,2
     xorlw 0x61
     btfsc crc,3
     xorlw 0xc2
     btfsc crc,4
     xorlw 0x9d
     btfsc crc,5
     xorlw 0x23
     btfsc crc,6
     xorlw 0x46
     btfsc crc,7
     xorlw 0x8c
     movwf crc          //store accumulated crc
     INCF   FSR         //inc. indirection reg to point to next databyte
     decfsz byte_cntr,F
     goto loop          //next databyte
                            //done, crc is in w
     movwf crc        //store in result

#ENDASM

return(crc);
}
Guest








PostPosted: Wed Apr 27, 2005 3:40 pm     Reply with quote

i copied, and pasted code posted by PCM programmer, compiled well.

but i switched to 18f452, no luck. still same problem.

test code here:


Code:


//#include <16F877.H>
//#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
//#use delay(clock=4000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#include <18F452.h>
#fuses XT, NOWDT,NOPROTECT, NOLVP, NOPROTECT, PUT
#use delay(clock=4000000)


#define FSR   4     //not for 18f452.
#define INDF  0    //i want to compile only. dont worry about these.

int calc_CRC(int* data, int byte_cntr);

//=================
void main()
{
char array[10];
char count;

calc_CRC(array, count);


while(1);
}
//===================================

int calc_CRC(int* DATA, int byte_cntr)
{

int crc=0;

#ASM
     MOVF   DATA , W       //copy pointer to first databyte..
     MOVWF  FSR           //..to pointer register

loop:
     MOVF   INDF,W       //load w with next databyte
     xorwf crc,f     // xor with acc'd crc (acc'd crc is no longer valid now)
     movlw 0        //w will ccumulate the new crc
     btfsc crc,0
     xorlw 0x5e         //could also be iorlw
     btfsc crc,1
     xorlw 0xbc
     btfsc crc,2
     xorlw 0x61
     btfsc crc,3
     xorlw 0xc2
     btfsc crc,4
     xorlw 0x9d
     btfsc crc,5
     xorlw 0x23
     btfsc crc,6
     xorlw 0x46
     btfsc crc,7
     xorlw 0x8c
     movwf crc          //store accumulated crc
     INCF   FSR         //inc. indirection reg to point to next databyte
     decfsz byte_cntr,F
     goto loop          //next databyte
                            //done, crc is in w
     movwf crc        //store in result

#ENDASM

return(crc);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 27, 2005 4:28 pm     Reply with quote

I think that DATA may be a keyword, because if you change it to DATA1
(in all instances), then it compiles OK.
Guest








PostPosted: Wed Apr 27, 2005 5:22 pm     Reply with quote

Thanks a lot, PCM programmer.

I can't believe, it worked... why 'data' causes this problem? i searched help file for "reserved' words, i didn't find anything. maybe i may look asm side. target device=16f877 no problem, target device=18f452 compile error, i didn't understand anything. this may be my homework.

In this case i think CCS must change their help file.
this lines coming from help file. topic: #ASM. this example also uses 'data' as parameter name.

Code:

int find_parity (int data)    {
   int count;
   #asm
   movlw   0x8
   movwf   count
   movlw   0
 loop:
   xorwf   data,w
   rrf     data,f
   decfsz  count,f
   goto    loop
   movwf   _return_
  #endasm
}


i copied and pasted same problem at 'xorwf data,w' with 18f452. if you select device=16f877 compiles succesfully...

hayri
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