What is the difference between the media types "Constant" and "K Constant"?

FAQ #100123

The main difference is the different range of values for this two types "Constant" (type "Const" in the Symbol Editor) and "K Constant" (type "K" in the Symbol Editor).


min valuemax value
Const-2'147'483'648  2'147'483'647


The difference can be explained with the structure of a codeline, which has the length of 32 bit:


ADDK100; 1. Codeline of instruction
 R100; 2. Codeline of instruction
 R101; 3. Codeline of instruction

All informations of each codeline are stored into 32 Bit (4 byte). Since the first codeline needs 18 bits  for instruction (e.g. ADD) and media code (K, R, I,...), there are 14 bits left which can - in case the media code is K - be used for the value of the "K constant". Therefore the value range of the "K constant" is 0..16383.

A "K constant" is marked by the media code (bits 14 and 15 are high) and so it can be used instead of e.g. a register (given the instruction supports it).

Note that the "K Constant" can only be used as parameter for instruction that requires a media code.

Load instructions (LD, LDL, LDH) only accept "Constants" without mediacode for its second codeline. See below:


LDR200; Load register 200
 2147483647; with the value 2147483647

Since on the second codeline of the LD instruction no media type is allowed but only a value is possible, the whole 32 bit of the codeline may be used as the value (-2'147'483'648..2'147'483'647) of this constant.

Note that the "Constant" only can be used with Load Mnemonics; further on it never can not be 
passed to an FB as parameter.