![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
skyforme
Joined: 18 Jul 2005 Posts: 14
|
Bra command in C. |
Posted: Mon Aug 22, 2005 2:10 pm |
|
|
Hello again.
Can I use bra command (or call or goto) outside of a function?
For example can I use like this?
void main()
{
#ASM
bsf INTCONbits.PEIE //LOW INT
bsf INTCONbits.GIE //HIGH INT
Main:
goto Main
PWM_INTERRUPT:
retfie 1
#ENDASM
}
void Int_Handler_High(void)
{
#asm
btfsc PIR3bits.PTIF //;PWM interrupt?
call PWM_INTERRUPT
RETFIE 1
#endasm
}
#org 0x08,0x0A
/****************************************************************************
* DESCRIPTION: Wrapper for the high priority interrupt
* RETURN: none
* ALGORITHM: none
* NOTES: none
*****************************************************************************/
void Int_Handler_High_Wrapper(void)
{
Int_Handler_High();
}
For the high int wrapper, I used a function someone posted.
In addition, I still do not figure out that I can use high(ABC), low(ABC).
Please help me. |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Aug 22, 2005 2:21 pm |
|
|
I think you are making it very difficult to yourself. Either program everything in assembler or do everything in C, trying to mix both will result in a program that is hard to understand now and in 6 months even you will no longer have a clue as to what you were trying to do. Another problem is that you might confuse the compiler and get unexpected results (bugs).
In C there is a convention to never use the goto instruction as there is no need to and it often results into spaghetti code. Only sometimes when programming some very low level routines like a bootloader you need the goto instruction to jump to a hard coded memory address, in CCS you can do this by calling the goto_address() function. |
|
![](templates/subSilver/images/spacer.gif) |
skyforme
Joined: 18 Jul 2005 Posts: 14
|
|
Posted: Mon Aug 22, 2005 2:59 pm |
|
|
Thank you.
It seems that make8 will the thing that I want.
Yeah..I also don't want to have mixed code.
I am just trying to be a CCS user.
Many of my code will be changed to C format.
And Mplab asm has high low operator as far as I know.
Thank you for your reply. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Aug 23, 2005 3:01 am |
|
|
The comment on this is obvious. CCS 'C', is a 'C', not an assembler. It does contain a limited assembler, but this uses 'C' conventions internally, not assembler conventions. It is possible now, to do 99+% of things directly without using assembler at all, and this is what you should be doing. For the odd fraction of a percent, the syntax is very different from the MPLAB assembler. In the case of a variable for example, you can access it using 'C' names, rather than assembler forms. So, if you have a 16bit variable 'counter', in CCS assembler, you access the low byte, by just using 'counter', while you access the high byte using '&counter+1'. If you have a fixed 'define' (perhaps #define val (0x1234)), you can just use the low byte, with 'val & 0xFF', and the high byte with 'val>>8'. These cost nothing in use, since the compiler identifies these as 'fixed' values, and does the conversions while compiling, and not when the program runs.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|