09-19-2014, 02:22 AM
Ne koristim MPLABX pa ne znam sintaksu za miksovanje C i asm koda kod njega.
To će morati da ti objasni neko ko koristi MPLABX.
Inače u folderu MPLABX imaš podfolder Docs, gde se nalazi njegov User Guide, takođe i u folderu gde ti je kompajler.
Mora da piše tamo.
Evo na primer, u uputstvu mog kompajlera piše ovo:
---------------------------------------------------
5.11.3 #asm, #endasm and asm()
PIC18 instructions may also be directly embedded in C code using the directives #asm, #endasmand
the statement asm(). The #asm and #endasmdirectives are used to start and end a block of assembler
instructions which are to be embedded inside C code. The asm()statement is used to embed a single
assembler instruction in the code generated by the C compiler. The following example shows both
methods used to rotate a byte left through carry:
unsigned char var;
void main(void)
{
var = 1;
#asm // like this...
movlb (_var) >> 8
rlcf (_var)&0ffh,f
#endasm
// or like this
asm(“movlb (_var) >> 8”);
asm("rlcf (_var)&0ffh,f");
}
When using in-line assembler code, great care must be taken to avoid interacting with compiler-generated code. If in doubt, compile your program with the PICC18 -Soption and examine the
assembler code generated by the compiler.
IMPORTANT NOTE: the #asmand #endasmconstruct is not syntactically part of the C program, and
thus it does notobey normal C flow-of-control rules. For example, you cannot use a #asmblock with an
ifstatement and expect it to work correctly. If you use in-line assembler around any C constructs such as if, while, doetc. they you should use only the asm("")form, which is a C statement and will
correctly interact with all C flow-of-control structures.
------------------------------------------
Mora da ima toga i u tvom uputstvu. Potraži.
Pozz
To će morati da ti objasni neko ko koristi MPLABX.
Inače u folderu MPLABX imaš podfolder Docs, gde se nalazi njegov User Guide, takođe i u folderu gde ti je kompajler.
Mora da piše tamo.
Evo na primer, u uputstvu mog kompajlera piše ovo:
---------------------------------------------------
5.11.3 #asm, #endasm and asm()
PIC18 instructions may also be directly embedded in C code using the directives #asm, #endasmand
the statement asm(). The #asm and #endasmdirectives are used to start and end a block of assembler
instructions which are to be embedded inside C code. The asm()statement is used to embed a single
assembler instruction in the code generated by the C compiler. The following example shows both
methods used to rotate a byte left through carry:
unsigned char var;
void main(void)
{
var = 1;
#asm // like this...
movlb (_var) >> 8
rlcf (_var)&0ffh,f
#endasm
// or like this
asm(“movlb (_var) >> 8”);
asm("rlcf (_var)&0ffh,f");
}
When using in-line assembler code, great care must be taken to avoid interacting with compiler-generated code. If in doubt, compile your program with the PICC18 -Soption and examine the
assembler code generated by the compiler.
IMPORTANT NOTE: the #asmand #endasmconstruct is not syntactically part of the C program, and
thus it does notobey normal C flow-of-control rules. For example, you cannot use a #asmblock with an
ifstatement and expect it to work correctly. If you use in-line assembler around any C constructs such as if, while, doetc. they you should use only the asm("")form, which is a C statement and will
correctly interact with all C flow-of-control structures.
------------------------------------------
Mora da ima toga i u tvom uputstvu. Potraži.
Pozz