Keil™, An ARM® Company

µVision® User's Guide

Constants

The µVision3 accepts decimal constants, HEX constants, octal constants, binary constants, floating-point constants, character constants, and string constants.

Binary, Decimal, HEX, and Octal Constants

By default, numeric constants are decimal or base ten numbers. When you enter 10, this is the number ten and not the HEX value 10h. The following table shows the prefixes and suffixes that are required to enter constants in base 2 (binary), base 8 (octal), base 10 (decimal), and base 16 (HEX).

BasePrefixSuffixExample
Binary:NoneY or y11111111Y
Decimal:NoneT or none1234T or 1234
Hexadecimal:0x or 0XH or h1234H or 0x1234
Octal:NoneQ, q, O, or o777q or 777Q or 777o

Following are a few points to note about numeric constants.

  • Numbers may be grouped with the dollar sign character ("$") to make them easier to read. For example, 1111$1111y is the same as 11111111y.
  • HEX constants must begin prefixed with a leading zero when the first digit in the constant is A-F.
  • By default, numeric constants are 16-bit values. They may be followed with an L to make them long, 32-bit values. For example: 0x1234L, 1234L, 1255HL.
  • When a number is entered that is larger than the range of a 16-bit integer , the number is promoted automatically to a 32-bit integer.

Floating-Point Constants

Floating-point constants are entered in one of the following formats.

number . number

number e[+|-] number

number . number [e[+|-] number]

For example, 4.12, 0.1e3, and 12.12e–5. In contrast with the C programming language, floating-point numbers must have a digit before the decimal point. For example, .12 is not allowed. It must be entered as 0.12.

Character Constants

The rules of the C programming language for character constants apply to the µVision3 debugger. For example, the following are all valid character constants.

'a', '1', '\n', '\v', '\x0FE', '\015'

Also escape sequences are supported as listed in the following table:

SequenceDescription
\\Backslash character ( \ ).
\"Double quote.
\'Single quote.
\aAlert, bell.
\bBackspace.
\fForm feed.
\nNewline.
\rCarriage return.
\tTab.
\0nnOctal constant.
\XnnnHEX constant.

String Constants

The rules of the C programming language for string constants also apply to µVision3. For example:

"string\x007\n"                      "value of %s = %04XH\n"

Nested strings may be required in some cases. For example, double quotes for a nested string must be escaped. For example:

"printf (\"hello world!\n\")"

In contrast with the C programming language, successive strings are not concatenated into a single string. For example, "string1+" "string2" is not combined into a single string.