[SOLVED] programming Microcontroller in assembly and C

Status
Not open for further replies.

yamine

Member level 1
Joined
May 4, 2012
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,507
Hi,
how can i program a PIC Microcontroller in assembly and c in the same time ?
can you give me an example?
thank you,
 

How it's done varies depending on the compiler you are using. Look up "in-line assembly" for your c-compiler to see how it's done.
 
Reactions: yamine

    yamine

    Points: 2
    Helpful Answer Positive Rating
i will use mplab, but i don't have any idea
 

It's really easy to use inline assembly in MPLAB, but it depends on which compiler you are using.

Assuming you are using C18, check out section 2.8.2 "Inline Assembly" in the C18 Compiler Users Guide: https://ww1.microchip.com/downloads/en/devicedoc/51288f.pdf

As the users guide explains, all you have to do is wrap the inline assembly with "_asm" and "_endasm" tags. Example from the users guide:

Code:
_asm
/* User assembly code */
MOVLW 10 // Move decimal 10 to count
MOVWF count, 0
/* Loop until count is 0 */
start:
DECFSZ count, 1, 0
GOTO done
BRA start
done:
_endasm

I hope this helped!
 
Reactions: yamine

    yamine

    Points: 2
    Helpful Answer Positive Rating
i found this example in the Users Guide, it resolve my problem
thank you for helping
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…