printf − formatted output conversion #include <saio/saioctl.h> arg ] ...
places output on the console. Printf converts, formats, and prints its arguments after the first under control of the first argument. The first argument is a character string which contains two types of objects: plain characters, which are simply copied to the output stream, and conversion specifications, each of which causes conversion and printing of the next successive Each conversion specification is introduced by the character followed by a conversion character. The conversion characters and their meanings are The integer is converted to decimal, octal, or hexadecimal notation respectively. The character is printed. is taken to be a string (character pointer) and characters from the string are printed until a null character. The unsigned integer is converted to decimal and printed. The conversion character is used to decode device error registers and other values made up of single bit flags. Two arguments are required by this format character. The first should be an integer, the second should be a null terminated string of the form "<base><bitfmt>*" where: <base> is either \10 for octal or \20 for hex
each <bitfmt> is a sequence of characters, the first of which gives the bit number to be inspected (origin 1), and the next characters (up to a control character, i.e. a character <= 32), give the name of the bit. Thus:
printf("reg=%b0, 3, "102BITTWO1BITONE")
would print
reg=3<BITTWO,BITONE>
The %r and %R formats allow formatted prints of bit fields. Both %r and %R require two arguments, the first should be an integer and the second should be a pointer to the first element of an array of Each bit field is described by a struct reg_desc, multiple bit fields within a single word can be described by an array of reg_desc structures. The r conversion character outputs a string of the format "<bit field descriptions>" The R conversion charater outputs a string of the format "0x%x<bit field descriptions>" is defined as:
struct reg_desc {
unsigned rd_mask;/* mask to extract field */
int rd_shift;/* shift for extracted value, - >>, + << */
char *rd_name;/* field name */
char *rd_format;/* format to print field */
struct reg_values *rd_values;/* symbolic names of values */
};
The fields in a are: unsigned rd_mask An appropriate mask to isolate the bit field within a word, and’ed with val. A zero mask terminates the array of int rd_shift A shift amount to be done to the isolated bit field. Shift is done before printing the isolated bit field with rd_format and before searching for symbolic value names in rd_values. char *rd_name If non-null, a bit field name to label any output from rd_format or searching rd_values. If both rd_format or rd_values are null, rd_name is printed only if the isolated bit field is non-null. char *rd_format If non-null, the shifted bit field value is printed using this format. struct reg_values *rd_values If non-null, a pointer to a table pairing numeric values with symbolic names. Rd_values is searched and the symbolic name is printed if a match is found for the value of the bit field, if no match is found "???" is printed. A struct reg_values is defined as:
struct reg_values {
unsigned rv_value;
char *rv_name;
};
The fields in a are: unsigned rv_value A numeric value for a bit field. char *rv_name The symbolic name for this value. Print a ‘%’; no argument is converted.
/*
* CP0 cause register description
*/
struct reg_values exc_values[] = {
{ EXC_INT,"INT" },
{ EXC_MOD,"MOD" },
{ EXC_RMISS,"RMISS" },
{ EXC_WMISS,"WMISS" },
{ EXC_RADE,"RADE" },
{ EXC_WADE,"WADE" },
{ EXC_IBE,"IBE" },
{ EXC_DBE,"DBE" },
{ EXC_SYSCALL,"SYSCALL" },
{ EXC_BREAK,"BREAK" },
{ EXC_II,"II" },
{ EXC_CPU,"CPU" },
{ EXC_OV,"OV" },
{ 0,NULL },
};
struct reg_desc cause_desc[] = {
/* mask s