| |||
| Home > RealView Debugger Commands > Alphabetical command reference > FPRINTF | |||
The FPRINTF command displays formatted text to a specified file or window.
FPRINTF windowid,
"format_string" [,argument]...
where:
windowidSpecifies a window or file number (in the range 50–1024).
format_stringSpecifies the format to be applied to argument.
argumentThe value or values to be written.
The command is similar to the C run-time fprintf function.
You select the windowid to use from the range 50..1024,
and it must be opened using the FOPEN command,
for output to a file, or the VOPEN command, for
output to a user window.
The text in is
defines what is displayed. If there are no format_string% characters
in the string, the text is written out and any other arguments to FPRINTF are
ignored. The % symbol is used to indicate the
start of an argument conversion specification. The syntax of the
specification is:
%<flag><fieldwidth><precision><lenmod><convspec>
where:
flagAn optional conversion modification flag -.
If specified, the result is left-justified within the field width.
If not specified, the result is right-justified.
fieldwidthAn optional minimum field width specified in decimal.
precisionAn
optional precision specified in decimal, with a preceding . (period character)
to identify it.
lenmodAn optional argument length specifier:
a 16-bit value
a 32-bit value
a 64-bit value
The possible conversion specifier characters, <convspec>,
are:
A
literal % character.
The mnemonic for the processor instruction in memory pointed to by the argument. The expansion includes a newline character. The information that is printed includes:
the memory address in hexadecimal
the memory contents in hexadecimal
the instruction mnemonic and arguments
an ASCII representation of the memory contents, if printable.
A line from the current source file, where the argument is the line number.
A line from the current source file, where the argument is the source line address (as opposed to a target memory address).
An integer
argument printed in decimal. d and i are
equivalent, and indicate a signed integer. u is used
for unsigned integers.
An integer argument
printed in unsigned hexadecimal. x indicates that the letters a to f are
used for the extra digits, and X indicates that the
letters A to F are used.
A single character argument.
A string argument. The string itself can be stored on the host or on the target.
A pointer argument. The value of the pointer is printed in hexadecimal.
A floating point argument, printed in scientific notation,
fixed point notation, or the shorter of the two. The capital letter
forms use a capital E in scientific notation
rather than an e.
Output is formatted beginning at the left of the format string and is copied to the Output pane. Whenever a conversion specification is encountered, the next argument is converted according to the specification, and the result is copied to the Output pane.
The following rules apply to the use of the FPRINTF command:
FPRINTF runs synchronously
must
be one of the predefined values or have been previously assigned by
an FOPEN or VOPEN command windowid
if there are too many arguments, some of them are not printed
if there are too few arguments (that is, there are
more conversion specifiers in the format string than there are arguments
after the format string), the string <invalid value> is
output instead
if the argument type does not correspond to its conversion field specification, arguments are converted incorrectly.
The following examples show how to use FPRINTF:
fprintf 50,"Syntax error\n"Write the string Syntax error to
the window or file.
fprintf 50, "Execution
time: %d seconds\n", tend-tstartPrint the result of the calculation to the window or file, in the format:
Execution time: 20 seconds
fprintf 50, "Value is
%d\n"Print the following to the window or file:
Value=<invalid value>
The following commands provide similar or related functionality: