The chapter delivers the information that in order to obtain a driver’s license or a pilot’s license, a hood or the cowling for pilots is required. It is not important to understand neither how each part of the engine works nor how to fix it. Generally, mechanics feel happy to take care of it. But a basic understanding of what is going on would help to be a better driver or pilot. If one understands the machine, one can control it better. If required, one can diagnose little problems and can do a little maintenance. Working with a compiler is not that dissimilar. Sometime ahead, one has to start looking under the hood to get the best performance out of it. The basics of string declaration to introduce the memory allocation techniques used by the MPLAB® C compiler for the PIC24 are also outlined. The chapter concludes delving with details of the engine compartment.
Whether you are trying to get a driver’s license or a pilot’s license, sooner or later you have to start looking under the hood, or the cowling for pilots. You don’t have to understand how each part of the engine works nor how to fix it – mechanics will be happy to do that for you. But a basic understanding of what is going on will help you be a better driver/pilot. If you understand the machine, you can control it better – it’s that simple. You can diagnose little problems, and you can do a little maintenance.
Working with a compiler is not that dissimilar – sooner or later you have to start looking under the hood if you want to get the best performance out of it. Since the very first lesson we have been peeking inside the engine compartment. This time we will delve into a little bit more detail.
In this lesson we will review the basics of string declaration as an excuse to introduce the memory allocation techniques used by the MPLAB® C compiler for the PIC24. The Harvard architecture of the PIC24 poses some interesting challenges that require innovative solutions. We will use several tools, including the Embedded Memory window, the Watches window and the Map file, to investigate how the MPLAB C compiler and linker operate in combination to generate the most compact and efficient code.
Similarly to previous lessons we will make use of the MPLAB X IDE, the MPLAB C Compiler for the PIC24, a programmer/debugger of your choice and pretty much any demo board that can host a PIC24FJ128GA010 microcontroller.
Use the New Project Setup checklist to create a new project called 6-Strings and a new source file similarly called strings.c.
Strings are treated in the C language as simple ASCII character arrays. Every string composed of characters is assumed to be stored sequentially in memory in consecutive 8-bit elements of the array. After the last character of the string an additional byte containing a value of zero (represented in a character notation with ‘