Asm Declaration - mikroElektronika PIC Microcontrollers PIC12 User Manual

Mikroc user's manual
Table of Contents

Advertisement

mikroC
making it simple...

asm Declaration

C allows embedding assembly in the source code by means of asm declaration.
Declarations _asm and __asm are also allowed in mikroC, and have the same
meaning. Note that you cannot use numerals as absolute addresses for SFR or
GPR variables in assembly instructions. You may use symbolic names instead
(listing will display these names as well as addresses).
You can group assembly instructions by the
asm {
block of assembly instructions
}
C comments (both single-line and multi-line) are allowed in embedded assembly
code. Assembly-style comments starting with semicolon are not allowed.
If you plan to use a certain C variable in embedded assembly only, be sure to at
least initialize it in C code; otherwise, linker will issue an error. This does not
apply to predefined globals such as
For example, the following code will not be compiled, as linker won't be able to
recognize variable
unsigned myvar;
void main() {
asm {
}
}
Adding the following line (or similar) above
variable is used:
myvar := 0;
Note: mikroC will not check if the banks are set appropriately for your variable.
You need to set the banks manually in assembly code.
MikroElektronika: Development tools - Books - Compilers
:
myvar
MOVLW 10
// just a test
MOVLW test_main_global_myvar_1
mikroC - C Compiler for Microchip PIC microcontrollers
keyword (or
asm
.
PORTB
block would let linker know that
asm
, or
):
_asm
__asm
page
93

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents