= Assign a 32-bit value to a TML variable or a memory location |
Syntax
Operands value32: 32-bit long immediate value VAR32x: long variable VAR32x DM: data memory operand TypeMem: memory operand. One of dm (0x1), pm (0x0) or spi (0x2) values (VAR16x): contents of variable VAR16x, representing a 16-bit address of a variable
Binary code
The destination is 32-bit TML variable and the source is: a 32-bit immediate value, a 32-bit TML variable, a 16-bit TML variable left shifted by 0 to 16 bits, or the contents of 2 consecutive memory locations with the lower address indicated by a 16-bit TML variable (a pointer). Left shift is done with sign extension. The destination is 2 memory locations with the lower address indicated by a 16-bit TML variable (a pointer) and the source is: a 32-bit immediate value or a 32-bit TML variable. If the pointer variable is followed by a + sign, after the assignment, it is incremented by 2. The memory location can be of 3 types: RAM for data (dm), RAM for TML programs (pm), EEPROM SPI-connected for TML programs (spi). Some instructions use a 9-bit short address for the destination variable. Bit value X specifies the destination address range: All predefined or user-defined TML data are inside these address ranges, hence these instructions can be used without checking the variables addresses. However, considering future developments, the TML also includes assignment instructions using a full address where the destination address can be any 16-bit value. In this case destination variable is followed by “,dm”.
Execution Copies a 32-bit value from the source to the destination
Example1 long Var1; ... Var1 = 0x1122AABB;
Example2 long Var1, Var2; ... Var1 = Var2;
Example3 int Var1; long Var2; ... Var2 = Var1 << 4;
Example4 long Var1; ... Var1, dm = 0x1122AABB;
Example5 long Var1, Var2; ... Var1, dm = Var2;
Example6 long Var1; int pVar2; ... Var1 = (pVar2), dm;
Example7 long Var1; int pVar2; ... Var1 = (pVar2+), dm;
Example8 int pVar1; ... (pVar1), spi = 0x5422AFCD;
Example9 int pVar1; long Var2; ... (pVar1), pm = Var2;
Example10 int pVar1; ... (pVar1+), pm = 0x5422AFCD;
Example11 int pVar1; long Var2; ... (pVar1+), pm = Var2;
Remark: When destination is 2 consecutive memory locations and the source is an immediate value, the TML compiler checks the type and the dimension of the immediate value and based on this generates the binary code for a 16-bit or a 32-bit data transfer. Therefore if the immediate value has a decimal point, it is automatically considered as a fixed value. If the immediate value is outside the 16-bit integer range (-32768 to +32767), it is automatically considered as a long value. However, if the immediate value is inside the integer range, in order to execute a 32-bit data transfer it is necessary to add the suffix L after the value, for example: 200L or –1L. Examples: user_var = 0x29E; // write CPOS address in pointer variable user_var (user_var),dm = 1000000; // write 1000000 (0xF4240) in the CPOS parameter i.e // 0x4240 at address 0x29E and 0xF at address 0x29F (user_var+),dm = -1; // write -1 (0xFFFF) in CPOS(L). CPOS(H) remains // unchanged. CPOS is (0xFFFFF) i.e. 1048575, // and user_var is incremented by 2 user_var = 0x29E; // write CPOS address in pointer variable user_var (user_var+),dm = -1L; // write –1L long value (0xFFFFFFFF) in CPOS i.e. // CPOS(L) = 0xFFFF and CPOS(H) = 0xFFFF, // user_var is incremented by 2 user_var = 0x2A0; // write CSPD address in pointer variable user_var (user_var),dm = 1.5; // write 1.5 (0x18000) in the CSPD parameter i.e // 0x8000 at address 0x2A0 and 0x1 at address 0x2A1
|