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

#asm branch instruction not supported?

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








#asm branch instruction not supported?
PostPosted: Thu May 27, 2004 3:58 am     Reply with quote

Code:

    #ASM
      rrcf   TMR1H, 0    // rotate timer 1 register through carry
      bc      3           // if carry then jump 3 further
      movlw   0           // clear w register
      movwf   LATB        // set port B
      bra      3           // jump 3 further
      movlw   16          // set bit 5 of w register
      movwf   LATB        // set port B
      nop               // nop
      nop               // nop
    #ENDASM


When I compile, I get an error 'Expecting an identifier'. When I comment out the 'bc' and the 'bra' instruction, it works.

Is the branch not correct?

Using v3.179
Ttelmah
Guest







Re: #asm branch instruction not supported?
PostPosted: Thu May 27, 2004 4:48 am     Reply with quote

Anonymous wrote:
Code:

    #ASM
      rrcf   TMR1H, 0    // rotate timer 1 register through carry
      bc      3           // if carry then jump 3 further
      movlw   0           // clear w register
      movwf   LATB        // set port B
      bra      3           // jump 3 further
      movlw   16          // set bit 5 of w register
      movwf   LATB        // set port B
      nop               // nop
      nop               // nop
    #ENDASM


When I compile, I get an error 'Expecting an identifier'. When I comment out the 'bc' and the 'bra' instruction, it works.

Is the branch not correct?

Using v3.179


Use a label.
So:
[code]
#ASM
rrcf TMR1H, 0 // rotate timer 1 register through carry
bc 3 // if carry then jump 3 further
movlw 0 // clear w register
movwf LATB // set port B
bra past // jump past
movlw 16 // set bit 5 of w register
movwf LATB // set port B
past:
nop // nop
nop // nop
#ENDASM
[code]

Best Wishes
Guest








PostPosted: Thu May 27, 2004 5:32 am     Reply with quote

Honestly I can't find that in the 18FXX2 datasheet...

Code:
HERE BC 5

Should execute as follows:
Quote:
Before instruction:
PC = address (HERE)
After instruction:
If Carry: PC = address (HERE + 12)
If no Carry: PC = address (HERE + 2)

Which should mean the BC instruction needs a relative address and not a label. Still PCWH comes up with an error... Question
Ttelmah
Guest







PostPosted: Thu May 27, 2004 7:07 am     Reply with quote

Anonymous wrote:
Honestly I can't find that in the 18FXX2 datasheet...

Code:
HERE BC 5

Should execute as follows:
Quote:
Before instruction:
PC = address (HERE)
After instruction:
If Carry: PC = address (HERE + 12)
If no Carry: PC = address (HERE + 2)

Which should mean the BC instruction needs a relative address and not a label. Still PCWH comes up with an error... Question


Understand, that the compiler does _not_ accept standard Microchip assembler. The syntax is closer to a C/ASM hybrid. It expects to receive a 'target', and work out for itself the offset value that is needed, rather than receiving the offset directly. You have to comply with the CCS form, rather than the Microchip form. Unfortunately, CCS, document this really badly....
The BC instruction, and the BRA instruction using a label compiles fine for me.

Best Wishes
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