* src/pic16/gen.c: fixed bug #1106975,
[fw/sdcc] / doc / sdccman.lyx
index 5a54930de135e087111ba83ff777d7f621b0476c..a7748be022e02a48775452e46baeadf4007ab8db 100644 (file)
@@ -83,7 +83,7 @@ SDCC Compiler User Guide
 
 
 \size normal 
-SDCC 2.4.6
+SDCC 2.4.8
 \size footnotesize 
 
 \newline 
@@ -6043,7 +6043,33 @@ status Collapsed
 
 \end_inset 
 
- Causes the linker use unused register banks for data variables or stack.
+ Causes the linker to use unused register banks for data variables and pack
+ data, idata and stack together.
+ This is the default now.
+\layout List
+\labelwidthstring 00.00.0000
+
+
+\series bold 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-no-pack-iram
+\series default 
+\SpecialChar ~
+
+\begin_inset LatexCommand \index{-\/-pack-iram}
+
+\end_inset 
+
+ Causes the linker to use old style for allocating memory areas.
 \layout Subsection
 
 DS390 / DS400 Options
@@ -6905,6 +6931,7 @@ reentrant
  Parameters and Local Variables for more details.
  If this option is used all source files in the project should be compiled
  with this option.
+ It automatically implies --int-long-reent and --float-reent.
  
 \layout List
 \labelwidthstring 00.00.0000
@@ -7184,8 +7211,8 @@ status Collapsed
 /
 \end_inset 
 
--nostdincl
-\begin_inset LatexCommand \index{-\/-nostdincl}
+-nostdinc
+\begin_inset LatexCommand \index{-\/-nostdinc}
 
 \end_inset 
 
@@ -8245,8 +8272,10 @@ pdata
 
 \layout Standard
 
-Paged xdata access is currently not as straightforward as using the other
- addressing modes of a 8051.
+Paged xdata access is just as straightforward as using the other addressing
+ modes of a 8051.
+ It is typically located at the start of xdata and has a maximum size of
+ 256 bytes.
  The following example writes 0x01 to the address pointed to.
  Please note, pdata access physically accesses xdata memory.
  The high byte of the address is determined by port P2 
@@ -8329,7 +8358,7 @@ F2\SpecialChar ~
 movx @r0,a 
 \layout Standard
 
-Be extremely carefull if you use pdata together with the -
+If the -
 \begin_inset ERT
 status Collapsed
 
@@ -8344,7 +8373,8 @@ status Collapsed
 
 \end_inset 
 
- option.
+ option is used the pdata memory area is followed by the xstack memory area
+ and the sum of their sizes is limited to 256 bytes.
 \layout Subsubsection
 
 code
@@ -8775,14 +8805,15 @@ data
 
  grows, it will use up the remaining register banks, and the 16 bytes used
  by the 128 bit variables, and 80 bytes for general purpose use.
- If any bit variables are used, the data variables will be placed after
- the byte holding the last bit variable.
+ If any bit variables are used, the data variables will be placed in unused
register banks and after the byte holding the last bit variable.
  For example, if register banks 0 and 1 are used, and there are 9 bit variables
  (two bytes used), 
 \emph on 
 data
 \emph default 
- variables will be placed starting at address 0x22.
+ variables will be placed starting from address 0x10 to 0x20 and continue
+ at address 0x22.
  You can also use -
 \begin_inset ERT
 status Collapsed
@@ -8824,7 +8855,7 @@ idata
  
 \layout Standard
 
-By default the 8051 linker will place the stack after the last byte of data
+By default the 8051 linker will place the stack after the last byte of (i)data
  variables.
  Option -
 \begin_inset ERT
@@ -11060,10 +11091,30 @@ _sdcc_external_startup()
  or perform some other critical operation prior to static & global variable
  initialization.
  On some mcs51 variants xdata has to be explicitly enabled before it can
- be accessed, this is the place to do it.
- The startup code clears the complete 256 byte of idata memory, this might
- cause problems for 128 byte devices (endless loop reported for Chipcon
- CC1010).
+ be accessed or if the watchdog needs to be disabled, this is the place
+ to do it.
+ The startup code clears all internal data memory, 256 bytes by default,
+ but from 0 to n-1 if 
+\emph on 
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-iram-size
+\begin_inset LatexCommand \index{-\/-iram-size}
+
+\end_inset 
+
+n
+\emph default 
+ is used.
+ (recommended for Chipcon CC1010).
 \layout Standard
 
 See also the compiler option 
@@ -13913,15 +13964,6 @@ External Stack
 
 \layout Standard
 
-
-\series bold 
-Attention
-\series default 
-: this option wasn't maintained for a long time and is quite buggy.
- Small programs might work.
- You've been warned!
-\layout Standard
-
 The external stack (-
 \begin_inset ERT
 status Collapsed
@@ -13942,8 +13984,9 @@ status Collapsed
 
 \end_inset 
 
- memory (usually at the start of the external ram segment) and is 256 bytes
- in size.
+ memory (usually at the start of the external ram segment) and uses all
+ unused space in pdata (max.
+ 256 bytes).
  When -
 \begin_inset ERT
 status Collapsed
@@ -13979,7 +14022,8 @@ status Collapsed
 
  option, all parameters and local variables are allocated on the external
  stack (note: support libraries will need to be recompiled with the same
- options).
+ options.
+ There is a predefined target in the library makefile).
 \layout Standard
 
 The compiler outputs the higher order address byte of the external ram segment
@@ -15339,97 +15383,6 @@ status Collapsed
 /
 \end_inset 
 
--nodefaultlibs do not link default libraries when linking.
-\layout List
-\labelwidthstring 00.00.0000
-
--
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--obanksel=# Set optimization level for inserting BANKSELs.
-\begin_deeper 
-\layout List
-\labelwidthstring 00.00.0000
-
-0 is no optimization
-\layout List
-\labelwidthstring 00.00.0000
-
-1 checkes previous used register and if it is the same then doesn't emit
- BANKSEL, accounts only for labels.
-\end_deeper 
-\layout List
-\labelwidthstring 00.00.0000
-
--
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--pomit-config-words Omit the generation of the configuration words.
-\layout List
-\labelwidthstring 00.00.0000
-
--
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--pomit-ivt Omit the generation of the interrupt vectors.
-\layout List
-\labelwidthstring 00.00.0000
-
--
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--pleave-reset-vector Used in conjuction with -
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
--pomit-ivt, instructs the port NOT to omit the reset vector.
-\layout List
-\labelwidthstring 00.00.0000
-
--
-\begin_inset ERT
-status Collapsed
-
-\layout Standard
-
-\backslash 
-/
-\end_inset 
-
 -stack-model=[model] Used in conjuction with the command above.
  Defines the stack model to be used, valid stack models are : 
 \begin_deeper 
@@ -15526,7 +15479,24 @@ status Collapsed
 /
 \end_inset 
 
--call-tree dump call tree in .calltree file
+-mplab-comp MPLAB compatibility option.
+ Currently only suppresses special gpasm directives.
+\layout Subsubsection
+
+Optimization Options
+\layout Standard
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-optimize-goto Try to use (conditional) BRA instead of GOTO
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -15540,8 +15510,30 @@ status Collapsed
 /
 \end_inset 
 
--mplab-comp MPLAB compatibility option.
- Currently only suppresses special gpasm directives.
+-obanksel=nn Set optimization level for inserting BANKSELs.
+\newline 
+
+\begin_deeper 
+\layout List
+\labelwidthstring 00.00.0000
+
+0 is no optimization
+\layout List
+\labelwidthstring 00.00.0000
+
+1 checks previous used register and if it is the same then does not emit
+ BANKSEL, accounts only for labels.
+\layout List
+\labelwidthstring 00.00.0000
+
+2 tries to check the location of (even different) symbols and removes BANKSELs
+ if they are in the same bank.
+ Important: This will only work properly if the linker script does not have
+ sections across bank borders!
+\end_deeper 
+\layout Subsubsection
+
+Linking Options
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -15555,7 +15547,7 @@ status Collapsed
 /
 \end_inset 
 
--use-crt= Use a custom run-time module instead of the defaults.
+-nodefaultlibs do not link default libraries when linking
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -15569,7 +15561,7 @@ status Collapsed
 /
 \end_inset 
 
--no-crt Don't link the default run-time modules
+-use-crt= Use a custom run-time module instead of the defaults.
 \layout List
 \labelwidthstring 00.00.0000
 
@@ -15583,8 +15575,7 @@ status Collapsed
 /
 \end_inset 
 
--flr-support When entering/leaving a function, call support functions to
- store/restore used registers
+-no-crt Don't link the default run-time modules
 \layout Subsubsection
 
 Debugging Options
@@ -15679,6 +15670,20 @@ status Collapsed
 \end_inset 
 
 -gstack Trace push/pops for stack pointer overflow
+\layout List
+\labelwidthstring 00.00.0000
+
+-
+\begin_inset ERT
+status Collapsed
+
+\layout Standard
+
+\backslash 
+/
+\end_inset 
+
+-call-tree dump call tree in .calltree file
 \layout Subsection
 
 Preprocessor Macros
@@ -15885,25 +15890,24 @@ PIC16 port currently supports the following pragmas:
 
 stack pragma stack forces the code generator to initialize the stack & frame
  pointers at a specific address.
- This is an adhoc solution since gplink does not support yet stack.
- When the gplink issue is resolved the pragma will be deprecated
-\begin_inset Foot
-collapsed true
+ This is an adhoc solution for cases where no STACK directive is available
+ in the linker script or gplink is not instructed to create a stack section.
+\newline 
+The stack pragma should be used only once in a project.
+ Multiple pragmas may result in indeterminate behaviour of the program.
+\newline 
+The format is as follows:
+\layout LyX-Code
 
+#pragma stack bottom_address [stack_size]
 \layout Standard
 
 
 \emph on 
-It is important to initialize the stack, otherwise strange things can happen.
- Stack is not initialized by default because there are some sources that
- do not require it.
- (like library sources)
-\end_inset 
-
-.
-\newline 
-The stack pragma should be used only once in a project.
- Multiple pragmas may result in indeterminate behaviour of the program.
+bottom_address
+\emph default 
+ is the lower bound of the stack section.
+ The stack pointer initially will point at address (bottom_address+stack_size-1).
 \layout LyX-Code
 
 Example:
@@ -15911,30 +15915,24 @@ Example:
 
 \layout LyX-Code
 
-/* initializes stack at RAM address 0x5ff */
+/* initializes stack of 100 bytes at RAM address 0x200 */
 \layout LyX-Code
 
-#pragma stack 0x5ff
+#pragma stack 0x200 100
 \layout List
 \labelwidthstring 00.00.0000
 
-code place a function symbol at static FLASH address
-\layout LyX-Code
-
-Example:
-\layout LyX-Code
-
+wparam use the WREG to pass one byte of the first function argument.
+ This improves speed but you may not use this for functions with arguments
+ that are called via function pointers, otherwise one byte of the first
+ parameter will get lost.
+ This pragma should be placed in the header file to propagate the calling
+ convention to all callers.
 \layout LyX-Code
 
-/* place function test_func at 0x4000 */
+#pragma wparam function1[, function2, ...]
 \layout LyX-Code
 
-#pragma code test_func 0x4000
-\layout List
-\labelwidthstring 00.00.0000
-
-udata pragma udata instructs the compiler to emit code so that linker will
- place a variable at a specific memory bank
 \layout LyX-Code
 
 Example:
@@ -15942,64 +15940,355 @@ Example:
 
 \layout LyX-Code
 
-/* places variable foo at bank2 */
+/* pass one byte via stack and one byte via WREG */
 \layout LyX-Code
 
-#pragma udata bank2 foo
+#pragma wparam foo
 \layout LyX-Code
 
-char foo;
+void foo(int x);
 \layout Standard
 
-In order for this pragma to work there are some changes that must be made
- in the .lkr script used in link stage.
- In the following example a sample .lkr file is shown:
+The same effect with 
+\emph on 
+wparam pragma
+\emph default 
+ can be achieved with the function attribute 
+\emph on 
+wparam
+\emph default 
+.
+ Usage:
 \layout LyX-Code
 
+void func_wparam(int a) wparam
 \layout LyX-Code
 
-// Sample linker script for the PIC18F452 processor
+{
 \layout LyX-Code
 
-LIBPATH .
+...
 \layout LyX-Code
 
-CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
-\layout LyX-Code
+}
+\layout Standard
 
-CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
-\layout LyX-Code
+Limitations of wparam pragma apply for wparam function attribute, too.
+\layout List
+\labelwidthstring 00.00.0000
 
-CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
+code place a function symbol at static FLASH address
 \layout LyX-Code
 
-CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
+Example:
 \layout LyX-Code
 
-CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
 \layout LyX-Code
 
-CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
+/* place function test_func at 0x4000 */
 \layout LyX-Code
 
-ACCESSBANK NAME=accessram  START=0x0            END=0x7F
+#pragma code test_func 0x4000
 \layout LyX-Code
 
-\layout LyX-Code
+\layout List
+\labelwidthstring 00.00.0000
 
-DATABANK   NAME=gpr0       START=0x80           END=0xFF
+library instructs the linker to use a library module.
+\newline 
+Usage:
 \layout LyX-Code
 
-DATABANK   NAME=gpr1       START=0x100          END=0x1FF
-\layout LyX-Code
+#pragma library module_name
+\layout Standard
 
-DATABANK   NAME=gpr2       START=0x200          END=0x2FF
-\layout LyX-Code
 
-DATABANK   NAME=gpr3       START=0x300          END=0x3FF
-\layout LyX-Code
+\emph on 
+module_name
+\emph default 
+ can be any library or object file (including its path).
+ Note that there are four reserved keywords which have special meaning.
+ These are:
+\layout Standard
+\align center 
 
-DATABANK   NAME=gpr4       START=0x400          END=0x4FF
+\begin_inset  Tabular
+<lyxtabular version="3" rows="6" columns="3">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="block" valignment="top" leftline="true" width="20page%">
+<column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Keyword
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Description
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Module to link
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+ignore
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+ignore all library pragmas
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+(none)
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+c
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+link the C library
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+libc18f
+\emph default 
+.lib
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+math
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+link the Math libarary
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+libm18f
+\emph default 
+.lib
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+io
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+link the I/O library
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+libio18f*
+\emph default 
+.lib
+\end_inset 
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\series bold 
+debug
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+link the debug library
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+libdebug
+\emph default 
+.lib
+\end_inset 
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset 
+
+
+\newline 
+* is the device number, i.e.
+ 452 for PIC18F452 MCU.
+\layout Standard
+
+This feature allows for linking with specific libraries withoug having to
+ explicit name them in the command line.
+ Note that the 
+\noun on 
+ignore
+\noun default 
+ keyword will reject all modules specified by the library pragma.
+\layout List
+\labelwidthstring 00.00.0000
+
+udata pragma udata instructs the compiler to emit code so that linker will
+ place a variable at a specific memory bank
+\layout LyX-Code
+
+Example:
+\layout LyX-Code
+
+\layout LyX-Code
+
+/* places variable foo at bank2 */
+\layout LyX-Code
+
+#pragma udata bank2 foo
+\layout LyX-Code
+
+char foo;
+\layout Standard
+
+In order for this pragma to work extra SECTION directives should be added
+ in the .lkr script.
+ In the following example a sample .lkr file is shown:
+\layout LyX-Code
+
+\layout LyX-Code
+
+// Sample linker script for the PIC18F452 processor
+\layout LyX-Code
+
+LIBPATH .
+\layout LyX-Code
+
+CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
+\layout LyX-Code
+
+CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
+\layout LyX-Code
+
+CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
+\layout LyX-Code
+
+CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
+\layout LyX-Code
+
+CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
+\layout LyX-Code
+
+CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
+\layout LyX-Code
+
+ACCESSBANK NAME=accessram  START=0x0            END=0x7F
+\layout LyX-Code
+
+\layout LyX-Code
+
+DATABANK   NAME=gpr0       START=0x80           END=0xFF
+\layout LyX-Code
+
+DATABANK   NAME=gpr1       START=0x100          END=0x1FF
+\layout LyX-Code
+
+DATABANK   NAME=gpr2       START=0x200          END=0x2FF
+\layout LyX-Code
+
+DATABANK   NAME=gpr3       START=0x300          END=0x3FF
+\layout LyX-Code
+
+DATABANK   NAME=gpr4       START=0x400          END=0x4FF
 \layout LyX-Code
 
 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
@@ -16015,16 +16304,16 @@ SECTION    NAME=CONFIG     ROM=config
 
 \layout LyX-Code
 
-SECTION    NAME=bank0      RAM=gpr0
+SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
 \layout LyX-Code
 
-SECTION    NAME=bank1      RAM=gpr1
+SECTION    NAME=bank1      RAM=gpr1       # should be added to link
 \layout LyX-Code
 
-SECTION    NAME=bank2      RAM=gpr2
+SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
 \layout LyX-Code
 
-SECTION    NAME=bank3      RAM=gpr3
+SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
 \layout LyX-Code
 
 SECTION    NAME=bank4      RAM=gpr4
@@ -16091,6 +16380,60 @@ Libraries are created with gplib which is part of the gputils package
 \end_inset 
 
 .
+\layout Subsubsection
+
+Building the libraries
+\layout Standard
+
+Before using SDCC/pic16 there are some libraries that need to be compiled.
+ This process is not done automatically by SDCC since not all users use
+ SDCC for pic16 projects.
+ So each user should compile the libraries separately.
+\layout Standard
+
+The steps to compile the pic16 libraries under Linux are:
+\layout LyX-Code
+
+cd device/lib/pic16
+\layout LyX-Code
+
+./configure
+\layout LyX-Code
+
+make
+\layout LyX-Code
+
+cd ..
+\layout LyX-Code
+
+make model-pic16
+\layout LyX-Code
+
+su -c 'make install'     # install the libraries, you need the root password
+\layout Standard
+
+If you need to install the headers to, do:
+\layout LyX-Code
+
+cd device/include
+\layout LyX-Code
+
+su -c 'make install'     # install the headers, you need the root password
+\layout Standard
+
+There exist a special target to build the I/O libraries.
+ This target is not automatically build because it will build the I/O library
+ for 
+\emph on 
+every
+\emph default 
+ supported device.
+ This way building will take quite a lot of time.
+ Users are advised to edit the device/lib/pic16/pics.build file and then
+ execute:
+\layout LyX-Code
+
+make lib-io
 \layout Subsection
 
 Memory Models
@@ -16244,10 +16587,18 @@ FSR2 is assigned as frame pointer
 The following stack models are supported by the PIC16 port
 \layout Itemize
 
-small model
+
+\noun on 
+small
+\noun default 
+ model
 \layout Itemize
 
-large model
+
+\noun on 
+large
+\noun default 
+ model
 \layout Standard
 
 
@@ -16359,16 +16710,27 @@ Frame pointer FSR2
 \layout Standard
 
 
-\series bold 
-Currently stack and frame pointers should be initialized explicit by the
- user at the desired Data RAM position (see 
-\begin_inset LatexCommand \ref{sub:PIC16_Pragmas}
+\noun on 
+Large 
+\noun default 
+stack model is currently not working properly throughout the code generator.
+ So its use is not advised.
+ Also there are some other points that need special care:
+\newline 
 
-\end_inset 
+\layout Enumerate
 
- Pragma stack).
- Uninitialized stack and frame pointers can result in unexpected behavior
- of the resulting binary.
+Do not create stack sections with size more than one physical bank (that
+ is 256 bytes)
+\layout Enumerate
+
+Stack sections should no cross physical bank limits (i.e.
+ #pragma stack 0x50 0x100)
+\layout Standard
+
+These limitations are caused by the fact that only FSRxL is modified when
+ using SMALL stack model, so no more than 256 bytes of stack can be used.
+ This problem will disappear after LARGE model is fully implemented.
 \layout Subsection
 
 Function return values
@@ -16503,6 +16865,192 @@ on stack, FSR0 points to the beginning
 Interrupts
 \layout Standard
 
+An interrupt servive routine (ISR) is declared using the 
+\emph on 
+interrupt
+\emph default 
+ keyword.
+\layout LyX-Code
+
+void isr(void) interrupt 
+\emph on 
+n
+\layout LyX-Code
+
+{
+\layout LyX-Code
+
+...
+\layout LyX-Code
+
+}
+\layout Standard
+
+
+\emph on 
+n
+\emph default 
+ is the interrupt number, which for PIC18F devices can be:
+\layout Standard
+\align center 
+
+\begin_inset  Tabular
+<lyxtabular version="3" rows="4" columns="3">
+<features>
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" width="0">
+<column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\emph on 
+n
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Interrupt Vector
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+Interrupt Vector Address
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+RESET vector
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0x000000
+\end_inset 
+</cell>
+</row>
+<row topline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+1
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+
+\family roman 
+\series medium 
+\shape up 
+\size normal 
+\emph off 
+\bar no 
+\noun off 
+\color none
+HIGH priority interrupts
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0x000008
+\end_inset 
+</cell>
+</row>
+<row topline="true" bottomline="true">
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+2
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+LOW priority interrupts
+\end_inset 
+</cell>
+<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\layout Standard
+
+0x000018
+\end_inset 
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset 
+
+
+\layout Standard
+
+When generating assembly code for ISR the code generator places a 
+\noun on 
+goto 
+\noun default 
+instruction at the 
+\emph on 
+Interrupt Vector Address
+\emph default 
+ which points at the genetated ISR.
+\layout Standard
+
+
+\emph on 
+n
+\emph default 
+ is possible to be omitted.
+ This way a function is generated similar to an ISR, but it is not assigned
+ to any interrupt.
+\layout Standard
+
 When entering an interrupt, currently the PIC16
 \begin_inset LatexCommand \index{PIC16}
 
@@ -16527,13 +17075,42 @@ FSR0 (FSR0L and FSR0H)
 \layout Standard
 
 These registers are restored upon return from the interrupt routine.
+\layout Subsubsection
+
+Using Shadow Registers
+\layout Standard
+
+When entering/exiting an ISR, it is possible to take advantage of the PIC18F
+ core shadow registers which hold the values of WREG, STATUS and BSR registers.
+ This can be done by adding the keyword 
+\emph on 
+shadowregs
+\emph default 
+ before the 
+\emph on 
+interrupt
+\emph default 
+ keyword in the function's header.
+\layout LyX-Code
+
+void isr_shadow(void) shadowregs interrupt 1
+\layout LyX-Code
+
+{
+\layout LyX-Code
+
+...
+\layout LyX-Code
+
+}
 \layout Standard
 
-When entering a high priority interrupt WREG, STATUS and BSR are not explicit
- saved by software.
- The hardware shadow registers for WREG, STATUS and BSR are used in these
- cases.
+
+\emph on 
+shadowregs
+\emph default 
+ instructs the code generator not to store/restore WREG, STATUS, BSR when
+ entering/exiting the ISR.
 \layout Standard