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

Syntax                        

VAR16D = label

set VAR16D to value of a label

VAR16D = value16

set VAR16D to value16

VAR16D = VAR16S

set VAR16D to VAR16S value

VAR16D = VAR32S(L)

set VAR16D to VAR32S(L) value

VAR16D = VAR32S(H)

set VAR16D to VAR32S(H) value

VAR16D, dm = value16

set VAR16D from dm to value16

VAR16D, dm = VAR16S

set VAR16D from dm to VAR16S

VAR16D = (VAR16S), TypeMem

set VAR16D to &(VAR16S) from TM

VAR16D = (VAR16S+), TypeMem

set VAR16D to &(VAR16S) from TM, then VAR16S += 1

(VAR16D), TypeMem = value16

set &( VAR16D) from TM to value16

(VAR16D), TypeMem = VAR16S

set &( VAR16D) from TM to VAR16S

(VAR16D+), TypeMem = value16

set &( VAR16D) from TM to value16, then VAR16D += 1

(VAR16D+), TypeMem = VAR16S

set &( VAR16D) from TM to VAR16S, then VAR16D += 1

VAR32D(L) = value16

set VAR32D low word to value16

VAR32D(L) = VAR16S

set VAR32D (L) to VAR16 value

VAR32D(H) = value16

set VAR32D high word to value16

VAR32D(H) = VAR16S

set VAR32D (H) to VAR16 value

 

               Legend: D (destination), S (source).

 

Operands        label: 16-bit address of a TML instruction label

value16: 16-bit integer immediate value

VAR16x: integer variable VAR16x

VAR32x(L): the low word of VAR32x long variable

VAR32x(H): the high word of VAR32x long variable

Dm: data memory operand

TypeMem: memory operand.

(VAR16x): contents of variable VAR16x, representing a 16-bit address of a variable

 

PlaceTMLOnline

Binary code

 

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

The destination is 16-bit TML variable and the source is: a 16-bit immediate value, a label, 16-bit TML variable, high or low part of a 32-bit TML variable or the contents of a memory location whose address is indicated by a 16-bit TML variable (a pointer).

The destination is a memory location whose address is indicated by a 16-bit TML variable (a pointer) and the source is: a 16-bit immediate value or a 16-bit TML variable.

The destination is the high or low part of a 32-bit TML variable and the source is: a 16-bit immediate value or a 16-bit TML variable.

If the pointer variable is followed by a + sign, after the assignment, it is incremented by 1. 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 16-bit value from the source to the destination

 

Example1                

int Var1;

Label1:        // Label1 = TML program address

...

Var1 = Label1;

 

Before instruction

 

After instruction

Label1

0x1234

 

Label1

0x1234

Var1

x

 

Var1

0x1234

 

Example2                

int Var1;

...

Var1 = 26438;

 

Before instruction

 

After instruction

Var1

x

 

Var1

26438

 

Example3                

int Var1, Var2;

...

Var2 = Var1;

       

Before instruction

 

After instruction

Var2

0x56AB

 

Var2

0x56AB

Var1

x

 

Var1

0x56AB

 

Example4                

int Var1;

long Var3;

...

Var1 = Var3(L);

       

Before instruction

 

After instruction

Var3

0x56ABCD98

 

Var3

0x56ABCD98

Var1

x

 

Var1

0xCD98

 

Example5                

int Var1;

long Var3;

....

Var1 = Var3(H);

       

Before instruction

 

After instruction

Var3

0x56ABCD98

 

Var3

0x56ABCD98

Var1

x

 

Var1

0x56AB

 

Example6        

               int Var1;

...

Var1, dm = 3321;

 

Before instruction

 

After instruction

Var1

x

 

Var1

3321

 

Example7                

int Var1, Var2;

...

Var1, dm = Var2;

       

Before instruction

 

After instruction

Var1

0x0A01

 

Var1

0x0A01

Var2

x

 

Var2

0x0A01

 

Example8        

int Var1, pVar2;

...

Var1 = (pVar2), dm;

       

Before instruction

 

After instruction

pVar2

0x0A01

 

pVar2

0x0A01

Data memory

 

 

Data memory

 

0x0A01

0x1234

 

0x0A01

0x1234

Var1

x

 

Var1

0x1234

 

Example9        

int Var1, pVar2;

...

Var1 = (pVar2+), dm;

       

Before instruction

 

After instruction

pVar2

0x0A01

 

pVar2

0x0A02

Data memory

 

 

Data memory

 

0x0A01

0x1234

 

0x0A02

0x0014

Var1

x

 

Var1

0x0014

 

Example10                

int pVar1;

...

(pVar1), spi = 0x5422;

       

Before instruction

 

After instruction

pVar1

0x5100

 

pVar1

0x5100

SPI data memory

 

 

SPI data memory

 

0x1100

x

 

0x1100

0x5422

 

 

 

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

 

Example11                

int pVar1;

...

(pVar1+), spi = 0x5422;

       

Before instruction

 

After instruction

pVar1

0x5100

 

pVar1

0x5101

SPI data memory

 

 

SPI data memory

 

0x1100

x

 

0x1100

0x5422

 

 

 

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

 

Example12                

int pVar1, Var2;

...

(pVar1), pm = Var2;

       

Before instruction

 

After instruction

pVar1

0x8200

 

pVar1

0x8200

Var2

0xA987

 

Var2

0xA987

pm data memory

 

 

pm data memory

 

0x8200

x

 

0x8200

0xA987

 

Example13        

int pVar1, Var2;

...

(pVar1+), pm = Var2;

       

Before instruction

 

After instruction

pVar1

0x8200

 

pVar1

0x8201

Var2

0xA987

 

Var2

0xA987

pm data memory

 

 

pm data memory

 

0x8200

x

 

0x8200

0xA987

 

Example14        

               long Var5;

...

Var5(H) = 0xAA55 ;

 

Before instruction

 

After instruction

Var5

0x12344321

 

Var5

0xAA554321

 

Example15                

long Var5;

...

Var5(L) = 0xAA55;

 

Before instruction

 

After instruction

Var5

0x12344321

 

Var5

0x1234AA55

 

Example16        

               int Var1;

long Var5;

...

Var5(H) = Var1;

 

Before instruction

 

After instruction

Var1

0x7711

 

Var1

0x7711

Var5

0x12344321

 

Var5

0x77114321

 

Example17        

int Var1;

long Var5;

...

Var5(L) = Var1;

 

Before instruction

 

After instruction

Var1

0x7711

 

Var1

0x7711

Var5

0x12344321

 

Var5

0x12347711