I have a quick question: is it possible to use assembly code in C?
My experience was that in C++ (oh, how I miss C++), you could have code like this:
/* Assembly code goes here */
I was wondering if the same thing would be possible with the compiler supplied by FIRST?
Thanks in advance!
This is called ‘inline assembly’ and is a nonstandard feature of most compilers, and they all seem to implement it in a slightly different way. Luckily, though, you don’t have to look any further than the default code to find an example.
void _startup (void)
/* Initialize the stack pointer */
lfsr 1, _stack lfsr 2, _stack clrf TBLPTRU, 0 /* 1st silicon doesn't do this on POR */
bcf FPFLAGS,RND,0 /* Initialize rounding flag for floating point libs */
/* initialize the flash memory access configuration. this is harmless */
/* for non-flash devices, so we do it on all parts. */
bsf 0xa6, 7, 0
bcf 0xa6, 6, 0
/* Call the user's main routine */
} /* end _startup() */
There’s several other examples in that file as well.
Thanks for your response! That clears up a lot of questions.
Just in case anyone else might find assembly code useful, I found a link containing a list of commands - I’ll have to test it but from the source code I’ve seen these are the commands used to program low level functions for the robot controller.