SW500008 Microchip Technology, SW500008 Datasheet - Page 86

PICC-18 STD

SW500008

Manufacturer Part Number
SW500008
Description
PICC-18 STD
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC18r
Datasheets

Specifications of SW500008

Supported Families
PIC18
Core Architecture
PIC
Software Edition
Standard
Kit Contents
Software And Docs
Mcu Supported Families
PIC18
Tool Function
Compiler
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / RoHS Compliant
For Use With/related Products
PIC18 Series
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
015
778-1001
778-1001
Mixing C and Assembler Code
3.11.2.1 Accessing special function register names from assembler
If writing separate assembly modules, SFR definitions will not automatically be present. If writing
assembler code from within a C module, SFRs may be accessed by referring to the symbols defined
by the chip-specific C header files. Whenever you include <htc.h> into a C module, all the available
SFRs are defined as absolute C variables. As the contents of this file is C code, it cannot be included
into an assembler module, but assembler code can uses these definitions. To use a SFR in in-line
assembler code from within the same C module that includes <htc.h>, simply use the symbol with
an underscore character prepended to the name. For example:
Alternately, an assembler equivalent of htc.h is provided. If an assembler source includes the file
aspic18.h, equivalent assembler definitions of the devices’ SFRs will be available.
3.11.3 #asm, #endasm and asm()
PIC18 instructions may also be directly embedded “in-line” into C code using the directives #asm,
#endasm or the statement asm().
are to be embedded into the assembly output of the code generator. The #asm and #endasm construct
is not syntactically part of the C program, and thus it does not obey normal C flow-of-control rules,
however you can easily include multiple instructions with this form of in-line assembly.
72
The #asm and #endasm directives are used to start and end a block of assembly instructions which
C identifiers are assigned different symbols in the output assembly code so that an as-
sembly identifier cannot conflict with an identifier defined in C code. If assembly pro-
grammers choose identifier names that do not begin with an underscore, these identifiers
will never conflict with C identifiers. Importantly, this implies that the assembly identi-
fier, i, and the C identifier i relate to different objects at different memory locations.
#include <htc.h>
void main(void)
{
}
PORTA = 0x55;
asm("movlw 0xAA");
asm("movwf _PORTA");
...
C Language Features

Related parts for SW500008