When writing assembly code by hand, you assume responsibility for managing certain features of the device and formatting your assembly instructions and operands. The following list describes some of the actions you must take.
movff
instruction on
PIC18 devices). Check your device data sheet to see the memory architecture of your
device, as well as the instructions and registers which control bank selection. Failure
to select the correct bank will lead to code failure.
The BANKSEL
pseudo instruction can be used to simplify this process (see Bank And Page Selection).movff
instruction on PIC18 devices). Check
your device data sheet to see what address operand instructions requires. Failure to
mask an address can lead to a fixup error (see How Do I Fix a Fixup Overflow Error?) or code
failure.
The BANKMASK
macro can truncate the address for you (see Accessing Registers From Assembly Code).PAGESEL
pseudo instruction (see Bank And Page Selection), or the
fcall
or ljmp
pseudo instructions (not required on
PIC18 devices) (see Long Jumps And Calls ) which will automatically add page selection instructions, if
required.DS
or DABS
(see Ds Directive or Dabs Directive). It is often easier
to define objects in C code rather than in assembly code.delta
, space
, reloc
and
class
flags (see Delta Flag and
Space Flag
Reloc Flag and
Class Flag).
If these are not set correctly, compile errors or code failure will almost certainly
result. If the psect specifies a class and that psect can be placed anywhere in the
memory range defined by that class (see A: Define Linker Class), you
do not need to specify any options for it to be linked; otherwise, you will need to link
the psect using a linker option (see P: Position Psect for the
usual way to link psects and WL: Linker Option which indicates how you can specify this option without
running the linker directly).
Assembly code that is placed in-line with C code will be
placed in the same psect as the compiler-generated assembly and you should not place
this into a separate psect.