|ARM Technical Support Knowledge Articles|
Applies to: C51 C Compiler
Information in this article applies to:
According to the Cx51 User Guide, it mentions "The total number of bytes that may be passed to printf is limited due to the memory restrictions imposed by the 8051." What does it mean? Could you explain it in detail?
The 8051 only has 128 bytes of directly addressable DATA memory.
C functions that use variable length argument lists normally have arguments passed on the stack.
With the 8051, using stack frames for function arguments uses up the memory very quickly. Simulating a stack frame in XDATA memory is VERY SLOW.
The best alternative is overlaying and re-using DATA memory by creating a call tree of the program at link time. However, one problem with this method is that variable length argument lists must be limited to some predetermined size.
By default, we limit that to 15 bytes of arguments for memory models that use DATA memory. The limit is 40 bytes for memory models using XDATA.
The MAXARGS compiler directive lets you change the default limit to whatever you desire. Note that since the limit if DATA space is 128 bytes (including register banks and the bit area) you can't just set MAXARGS to 128.
This is what is meant when the compiler manual refers to the limited number of bytes that may be passed to printf.
Article last edited on: 2006-10-24 12:08:01
Did you find this article helpful? Yes No
How can we improve this article?