Hardware Reference
In-Depth Information
Character
Description
2 (minus sign)
Left justifies the converted argument.
FieldWidth
Integer number that specifies the minimum field width for the converted argument.
The argument will be displayed in a field at least this wide. The displayed
argument will be padded on the left or right if necessary.
. (period)
Separates the field width from the precision.
Precision
Integer number that specifies the maximum number of characters to display from
a string or the minimum number of digits for an integer.
h
To have an integer displayed as a short.
l (letter ell)
To have an integer displayed as a long.
Table 4.3 Optional formatting characters
The formatting characters supported by the printf() function are listed in Table 4.4. If the con-
version character following the percent sign is not one of the formatting characters shown in
this table or the characters shown in Table 4.3, the behavior of the printf() function is undefined.
The printf() function can be used to print a message. One example is as follows:
CR
equ
$0D
LF
equ
$0A
printf
equ
$EE88
ldd
#prompt
jsr
[printf,PCR]
prompt db “Flight simulation”,CR,LF,0
This instruction sequence will cause the message Flight simulation to be displayed, and
the cursor will be moved to the beginning of the next line.
Character
Argument Type; Displayed As
d, i
int; signed decimal number
o
int; unsigned octal number (without a leading zero)
x
int; unsigned hex number using abcdef for 10, . . . , 15
X
int; unsigned hex number using ABCDEF for 10, . . . , 15
u
int; unsigned decimal number
c
int; single character
s
char *; display from the string until a '\0' (NULL)
p
void *; pointer (implementation-dependent representation)
%
no argument is converted; print a %
Table 4.4 Printf() conversion characters
 
Search WWH ::




Custom Search