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

Bra command in C.

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



Joined: 18 Jul 2005
Posts: 14

View user's profile Send private message

Bra command in C.
PostPosted: Mon Aug 22, 2005 2:10 pm     Reply with quote

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.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Aug 22, 2005 2:21 pm     Reply with quote

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.
skyforme



Joined: 18 Jul 2005
Posts: 14

View user's profile Send private message

PostPosted: Mon Aug 22, 2005 2:59 pm     Reply with quote

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.
Ttelmah
Guest







PostPosted: Tue Aug 23, 2005 3:01 am     Reply with quote

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