• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Combining assembly & C code

I'm doing some Microchip PIC programming in C with MPLAB but I need to do some serial communication (receive only actually) so I'm using some assembly code from their app notes. Right now I'm just doing the SCI by itself in its own project, but I don't know how to call the assembly and get the return via C. I only know C from what I've done with this project and next to no assembly. The CCS compiler manual I have has only a tiny note about #ASM. Basically I want to use C in my test program to check if one of the asm bits is clear or not (indicating if a a receive is in progress or not) then when it becomes clear I need to pull the byte of data from one of the asm registers.

Can someone give me a basic example how to do that?

The code from the 'main program loop' is below.

Basically I guess I'd like to do the same things that happen there in a while loop in my void main() since I feel more comfortable with C. Like I don't know if I can call ASM functions like I would call a C function or what, and if the interrupts happen the same way as in C.
 
anyone?

At this point I'm learning more assembly to try and do some simple things in all assembly since all of the SCI code is assembly. I just want to say blink an LED each time I receive a byte so I know the communication is working. But I feel much more comfortable in C (though I only have learned this from starting on this PIC project) and I'll need to integrate the SCI assembly into my C code as soon as I verify the SCI works by itself.
 
I have *NO* idea how your CCS compiler works. I could probably help you if you were using gcc or Microsoft's compiler.
 
Back
Top