|
|||||||||||
Technical Support On-Line Manuals Cx51 User's Guide ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Memory ModelThe most significant impact on code size and execution speed is the selected memory model. Compiling in the small model always generates the smallest, fastest code possible. The SMALL directive instructs the compiler to use the small memory model. In this memory model, all variables are stored in the internal memory of the 8051 (unless they are explicitly located elsewhere). Memory access to internal data memory is very fast (typically performed in 1 or 2 clock cycles), and the code generated is much smaller than that generated for the compact or large models. For example, the following loop: for (i = 0; i < 100; i++) { do_nothing (); } is compiled in small model and large model to demonstrate the differences in the generated code.
In small model, the variable i is maintained in internal data memory. The instructions to access i, MOV A,i and INC i, require only two bytes each of code space. In addition, each of these instructions executes in only one clock cycle. In large model, the variable i is maintained in external data memory. To access i, the compiler must first load the data pointer and then perform an external memory access (see offset 0001h through 0004h in the above listing). These two instructions alone take 4 clock cycles. The code to increment i is found from offset 0011h to offset 0016h. This operation consumes 6 bytes of code space and takes 7 clock cycles to execute. | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.