|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
#asm branch instruction not supported? |
Posted: Thu May 27, 2004 3:58 am |
|
|
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? |
Posted: Thu May 27, 2004 4:48 am |
|
|
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
|
|
Posted: Thu May 27, 2004 5:32 am |
|
|
Honestly I can't find that in the 18FXX2 datasheet...
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... |
|
|
Ttelmah Guest
|
|
Posted: Thu May 27, 2004 7:07 am |
|
|
Anonymous wrote: | Honestly I can't find that in the 18FXX2 datasheet...
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... |
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 |
|
|
|
|
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
|