Keywords: sdccman

Subsections

- 4.7.19.1 Stack size

## 4.7.19 PIC16 Port – Tips

Here you can find some general tips for compiling programs with SDCC/pic16.

### 4.7.19.1 Stack size

The default stack size (that is 64 bytes) probably is enough for many programs. One must take care that when there are many levels of function nesting, or there is excessive usage of stack, its size should be extended. An example of such a case is the printf/sprintf family of functions. If you encounter problems like not being able to print integers, then you need to set the stack size around the maximum (256 for small stack model). The following diagram shows what happens when calling printf to print an integer:

  printf () --> ltoa () --> ultoa () --> divschar ()

It is should be understood that stack is easily consumed when calling complicated functions. Using command line arguments like —fomit-frame-pointer might reduce stack usage by not creating unnecessary stack frames. Other ways to reduce stack usage may exist.