=                Assign a 32-bit value to a TML variable or a memory location

Syntax                        

VAR32D = value32

set VAR32D to value32

VAR32D = VAR32S

set VAR32D to VAR32S value

VAR32D = VAR16S << N

set VAR32D to VAR16S << N

VAR32D, DM = value32

set long VAR32D from DM to value32

VAR32D, DM = VAR32S

set long VAR32D from DM to VAR32S

VAR32D = (VAR16S), TypeMem

set VAR32D to &(VAR16S) from TM

VAR32D = (VAR16S+), TypeMem

set VAR32D to &(VAR16S) from TM, then VAR16S += 2

(VAR16D), TypeMem = value32

set &( VAR16D) from TM to value32

(VAR16D), TypeMem = VAR32S

set &( VAR16D) from TM to VAR32S

(VAR16D+), TypeMem = value32

set &( VAR16D) from TM to value32, then VAR16D += 2

(VAR16D+), TypeMem = VAR32S

set &( VAR16D) from TM to VAR32S, then VAR16D += 2

 

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

 

PlaceTMLOnline

Binary code

 

 

DescriptionAssigns a 32-bit value to a TML variable or a memory location. The options are:

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).

TypeMem

Some instructions use a 9-bit short address for the destination variable. Bit

value X specifies the destination address range:

Addressrange

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;

 

Before instruction

 

After instruction

Var1

x

 

Var1

0x1122AABB

                                       

Example2                

long Var1, Var2;

...

Var1 = Var2;

       

Before instruction

 

After instruction

Var2

0xAABC1234

 

Var2

0xAABC1234

Var1

x

 

Var1

0xAABC1234

                               

Example3                

int Var1;

long Var2;

...

Var2 = Var1 << 4;

       

Before instruction

 

After instruction

Var1

0x9876

 

Var1

0x9876

Var2

x

 

Var2

0x00098760

 

Example4                

long Var1;

...

Var1, dm = 0x1122AABB;

 

Before instruction

 

After instruction

Var1

x

 

Var1

0x1122AABB

                                       

Example5                

long Var1, Var2;

...

Var1, dm = Var2;

       

Before instruction

 

After instruction

Var2

0xAABC1234

 

Var2

0xAABC1234

Var1

x

 

Var1

0xAABC1234

                               

Example6        

long Var1;

int pVar2;

...

Var1 = (pVar2), dm;

       

Before instruction

 

After instruction

pVar2

0x96AB

 

pVar2

0x96AB

Data memory

 

 

Data memory

 

0x96AB

0x1234

 

0x96AB

0x1234

0x96AC

0xABCD

 

0x96AC

0xABCD

Var1

x

 

Var1

0xABCD1234

                               

Example7        

               long Var1;

int pVar2;

...

Var1 = (pVar2+), dm;

       

Before instruction

 

After instruction

pVar2

0x0A02

 

pVar2

0x0A04

Data memory

 

 

Data memory

 

0x0A02

0x1234

 

0x0A02

0x1234

0x0A03

0xABCD

 

0x0A03

0xABCD

Var1

x

 

Var1

0xABCD1234

 

Example8                

int pVar1;

...

(pVar1), spi = 0x5422AFCD;

       

Before instruction

 

After instruction

pVar1

0x5100

 

pVar1

0x5100

SPI data memory

 

 

SPI data memory

 

0x1100

x

 

0x1100

0xAFCD

0x1101

x

 

0x1101

0x5422

 

 

 

(SPI memory offset is 0x4000, i.e. SPI addr = var.addr – 0x4000)

 

Example9                

int pVar1;

long Var2;

...

(pVar1), pm = Var2;

       

Before instruction

 

After instruction

pVar1

0x8200

 

pVar1

0x8200

Var2

0xA98711EF

 

Var2

0xA98711EF

pm data memory

 

 

pm data memory

 

0x8200

x

 

0x8200

0x11EF

0x8201

x

 

0x8201

0xA987

 

Example10                

int pVar1;

...

(pVar1+), pm = 0x5422AFCD;

 

Before instruction

 

After instruction

pVar1

0x8200

 

pVar1

0x8202

pm data memory

 

 

pm data memory

 

0x8200

x

 

0x8200

0xAFCD

0x8201

x

 

0x8201

0x5422

 

Example11                

int pVar1;

long Var2;

               ...

(pVar1+), pm = Var2;

       

Before instruction

 

After instruction

pVar1

0x8200

 

pVar1

0x8202

Var2

0xA98711EF

 

Var2

0xA98711EF

Pm data memory

 

 

pm data memory

 

0x8200

x

 

0x8200

0x11EF

0x8201

x

 

0x8201

0xA987

 

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