Instructions and directives requiring one or more operands differ in the size and address range of the required operand values of the operands.
For example, the function of the instruction "MOV r, #byte" is to transfer the value indicated by "byte" to register "r". Because the register is an 8-bit register, the data size of "byte" must be 8 bits or less.
An assembly error will occur at the statement "MOV R0, 0x100", because the value of the second operand (0x100) cannot be expressed with 8 bits.
Therefore, it is necessary to bear the following points in mind when describing operands.
Whether the size and address range are suitable for an operand of that instruction (numeric value, name, label) |
There are conditions that limit the size and address ranges of numeric values, names and labels used as instruction operands.
For instructions, the size and address range of operands are limited by the operand representation. For directives, they are limited by the directive type.
These limiting conditions are as follows.
The mirror destination area and the internal RAM area are the valid ranges, and the actual ranges of these areas are determined by referring to the device file. When the device file is not referred to, the valid range is 0xF0000 to 0xFFFFF. |
The address range of the mirror source area differs depending to the device. For details, see the user's manual of the device. |
The saddr area is determined by referring to the device file. When the device file is not referred to, the valid range is 0xFFE20 to 0xFFF1F. |
The address range for SFR symbols is determined by referring to the device file. When the device file is not referenced, SFR symbols must not be used. The address range for SFR symbols is 0xFFF00 to 0xFFFFF, but the address range from 0xFFF00 to 0xFFF1F is regarded as saddr even if an SFR symbol is used. |
When an SFR symbol or an extended SFR (2ndSFR) symbol is used as an operand, "!SFR" or "!2ndSFR" can be written as "!addr16" and a code for "!addr16" is generated. |
Only an even value is allowed for an operand in a 16-bit instruction (16-bit data transfer instruction or 16-bit operation instruction). |
The range differs between numeric constants and labels for the following reason.
When a code is generated for operand "word" or "addr16", the range of the values that can be output is 0x0000 to 0xFFFF. Therefore, when a numeric constant is specified as an operand, it is checked for this range. However, when a label is specified as an operand, the range is determined as follows considering the meaning of each value.
The actual location to be accessed is 0xF0000 to 0xFFFFF in the based addressing. Therefore, a label is checked for this address range.
The actual location to be accessed is 0xF0000 to 0xFFFFF except for the BR and CALL instructions. Therefore, a label is checked for this address range.
For a bit symbol, the range is as follows: |
||
Initial value setting: 0x00000000 00000000 to 0xFFFFFFFF FFFFFFFF |
||
Alignment condition value : 2 or a greater even number less than 231 |
Instructions can be classified into machine instructions and directives. When they require immediate data or symbols, the size of the required operand differs according to the instruction or directive. An error occurs when source code specifies data that is larger than the required operand.
Evaluation of an expression is done in 32 bits, both during calculation and for the calculation result. Therefore, even an overflow value is handled in 32 bits.
However, when a relocatable symbol is specified as an operand, its value cannot be determined by the assembler. In this case, the linker determines the value and checks its range.
Among the instructions that allow a symbol to be specified as an operand, the attribute (absolute, relocatable, or external reference) of symbols that can be specified differ depending on the instruction.
Reference direction for symbols can be backward reference or forward reference.
Backward reference : A symbol referenced as an operand, which is defined in a line above (before) the name or label |
Forward reference : A symbol referenced as an operand, which is defined in a line below (after) the name or label |
The following shows the attributes of symbols that can be specified as operands for machine-language instructions.
When a relocatable symbol is used, the optimizing linker determines its value and checks its range. |
The defined symbol specifying sfr or sfrp (sfr area where saddr and sfr are not overlapped) as an operand of .EQU directive is only referenced backward. Forward reference is prohibited. |
If an SFR symbols in the saddr area has been described for an instruction in which a combination of sfr/sfrp changed from saddr/saddrp exists in the operand combination, a code is output as saddr/saddrp. |
!SFR, !2ndSFR, and SFR can be specified only for operand !addr16 of instructions other than BR and CALL. |
When a relocatable symbol is used, the optimizing linker determines its value and checks its range. |