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

"Expecting an opcode mnemonic banksel"

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



Joined: 16 May 2008
Posts: 14

View user's profile Send private message

"Expecting an opcode mnemonic banksel"
PostPosted: Fri May 16, 2008 7:51 am     Reply with quote

Hello,

I work with MPLAB and CCS V4.

in my C program, I inserted a function in ASM between the keywords "#ASM" and "#ENDASM".

It works but when I use the opcode "banksel" I have "Expecting an opcode mnemonic banksel".

source files: main.c
header files: 16F877A.h
object files: none
other files: main.SYM, main.TRE

main.c:

////////////////////////////////////////////////////////
#include <16F877A.h>

#define duree 1000000000

void tempo(unsigned int count);

void main(void)
{

#ASM
banksel PORTB
MOVLW 0xFF
MOVWF PORTB
banksel TRISB
MOVLW 0x00
MOVWF TRISB
#ENDASM

}

void tempo(unsigned int compte)
{
while(compte--);
}
////////////////////////////////////////////////////////

thanks, julien lochen
Ttelmah
Guest







PostPosted: Fri May 16, 2008 7:59 am     Reply with quote

You don't need to use banksel.
The CCS 'assembler', doesn't work like a full/normal assembler. Instead it is quite smart. If you tell it:

#ASM
MOVLW 0xFF
MOVWF PORTB
MOVLW 0x00
MOVWF TRISB
#ENDASM

It will _automatically_ perform the bank selection operation as needed.
In fact though, you don't even need to use assembler at all. The single line:

output_b(0xFF);

will automatically output 0xFF, on portB, and change the TRIS for you as well, without using any assembler.

Best Wishes
julien lochen



Joined: 16 May 2008
Posts: 14

View user's profile Send private message

PostPosted: Fri May 16, 2008 8:11 am     Reply with quote

I stared coding in assembleur, I will continue using the C functions of CCS like output_b(X) ...

I just want to reuse the assembleur allready written.

I removed the line bankdel, now I have:
"Error 12 "main.c" Line 22(1,6): Undefined identifier PORTB"

/////////////////////////////////////////
#include <16F877A.h>

#define duree 1000000000

void tempo(unsigned int count);

void main(void)
{

#ASM
//banksel PORTB
MOVLW 0xFF
MOVWF PORTB
//banksel TRISB
MOVLW 0x00
MOVWF TRISB
#ENDASM

}

void tempo(unsigned int compte)
{
while(compte--);
}

/////////////////////////

thanks, julien
Ttelmah
Guest







PostPosted: Fri May 16, 2008 8:21 am     Reply with quote

You have to define things like PORTB, the assembler has no implicit 'knowledge' of things like this. Use the #byte directive to tell it where this register is (and the same for the TRIS).
The normal assembler also doesn't have this knowledge, but there is normally a header file that defines all the standard registers etc., for you.

Best Wishes
Guest








PostPosted: Fri May 16, 2008 9:22 am     Reply with quote

ok, I declared PORTB and TRISB as byte, but they are not assigned as long as I do not use the opcode "banksel":



#include <16F877A.h>

#define duree 1000000000

#byte PORTB = 0xFF
#byte TRISB = 0xFF

void tempo(unsigned int count);

void main(void)
{

#ASM
//banksel PORTB
MOVLW 0xFF
MOVWF PORTB

banksel PORTB
//banksel TRISB
MOVLW 0x00
MOVWF TRISB
#ENDASM
}

void tempo(unsigned int compte)
{
while(compte--);
}
Ttelmah
Guest







PostPosted: Fri May 16, 2008 9:42 am     Reply with quote

AArgh!.....
You have to declare them at their proper addresses. You have declared them at the _same_ (wrong) address. TRISB, is at 0x86, and PORTB is at 06.
So:
Code:

#byte PORTB = 0x6
#byte TRISB = 0x86


Best Wishes
Ttelmah
Guest







PostPosted: Fri May 16, 2008 9:57 am     Reply with quote

As a comment, how is the code ever going to get to 'tempo'?...
Just as a demo, of what you should have if you want to use the assembler:
Code:

#byte PORTB = 0x6
#byte TRISB = 0x86

#ASM
MOVLW 0xFF
MOVWF PORTB
MOVLW 0x00
MOVWF TRISB
#ENDASM


Which if included in a program, and compiled, generates (in the .LST file):
Code:

.................... MOVLW 0xFF
000C:  MOVLW  FF
.................... MOVWF PORTB
000D:  BCF    03.5
000E:  MOVWF  06
.................... MOVLW 0x00
000F:  MOVLW  00
.................... MOVWF TRISB
0010:  BSF    03.5
0011:  MOVWF  06

Note the BCF 03.5, and the BSF 03.5, which are the bank selection operations.

Best Wishes
julien lochen



Joined: 16 May 2008
Posts: 14

View user's profile Send private message

PostPosted: Fri May 16, 2008 11:06 am     Reply with quote

works fine, thank u veru much
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