ARM Technical Support Knowledge Articles


Applies to: C166 C Compiler


Information in this article applies to:


In C166, I'm using sprintf to get formatted data into a far array of characters. My question is: Is it valid to pass strings that exist in far memory to sprintf as shown here?

#define achBuffer XARRAY ( char, 0x100000 )
sprintf( achBuffer, "%d", 1 );

If yes, which memory models (other than TINY) is it not valid for?


Yes. This is valid. In the C166, the following memory models, by default, assume that variables are of the indicated types.

Memory Model      Variable Memory
TINY              near
SMALL             near
COMPACT           far
HCOMPACT          huge
MEDIUM            near
LARGE             far
HLARGE            huge

In COMPACT and LARGE memory models, sprintf assumes that the buffer is in far memory (and a far pointer is needed).

Since a far pointer can be converted into a huge pointer, HCOMPACT and HLARGE models will also work for your example (because far pointers can be converted into huge pointers).

MEDIUM, SMALL, and TINY models will not work (unless you luck out and the far memory is in the same space as the near memory).


Article last edited on: 2005-07-15 10:38:51

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential