You can embed PIC™ assembler code in subroutines and functions, as well as your main program code, by using an asm… end asm block. You can also declare local variables inside your subroutine or function and use them in you assembler code. For example,
function AddTen(pValue as byte) as byte
dim LocalVar as byte
LocalVar = 10
asm
movf LocalVar, W ; 10 into W
addwf pValue, W ; add parameter pValue to W
movwf Result ; move W into function result
end asm
end function
Please note that the compiler does not manage RAM banking in asm…end asm blocks. For further information on writing PIC™ assembler and issues relating to bank switching, refer to the Microchip document MPASM User's Guide.