Number format | Mark | Example |
---|---|---|

Decimal number | (none) | .equ Number = 123 |

Binary format | 0b | .equ Number = 0b1111011 |

Hexa decimal format | 0x | .equ Number = 0x7B |

Small letters in assembler are converted to capital letters, so

In expressions blanks and tab characters can be used to beautify the expression for the human reader. This is not allowed within operators that consist of more than one character, such as "!=" or "<=". Blanks and tab characters are completely removed from the assembler prior to expression processing.

It is essential to understand that only the assembler performs such expressions, and that only the final result of those expressions produces executable code. The controller is completely unaware of those calculations, as those calculations as such are not producing any code. The controller is only getting results of expressions if instruction words such as

or

is inserted to the code.

Note that in assembler all operations are pure integer. All numbers are integers and all calculations, even interim results within one formula, are rounded down. If you want rounding, you'll have to formulate like this:

```
.equ N1 = 2345
.equ N2 = 56
.equ Erg1 = N1 / N2 ; Division result is 41
.equ Erg = (N1 + N2 / 2) / N2 ; Rounded result is 42
```

Different assemblers handle integer values different: either with 32 or with 64 bit length. The number ranges that can be handled depend from that.

The following table lists all types of expressions in assembler.

Result type | Symbol Expression |
Description | Example |
---|---|---|---|

Logical | ! | Not, negation of the logical value | .equ f2 = ! f1 ; yields true (1) if f1 is false (0) |

&& | Combines the left and the right logical value with AND | .equ f = 1 && 0 ; yields false (0) | |

|| | Combines the left and the right logical value with OR | .equ f = 0 || 1 ; yields true (1) | |

Compare, logical | < | Compare if left expression is smaller than right expression | .equ f = 234 < 567 ; yields false (0) |

<= | Compare if left expression is smaller than or equal to right expression | .equ f = 234 /lt;= 234 ; yields true (1) | |

> | Compare if left expression is smaller than right expression | .equ f = 234 > 567 ; yields false (0) | |

>= | Compare if left expression is larger than or equal to right expression | .equ f = 234 >= 234 ; yields true (1) | |

== | Compare if left expression is equal to right expression | .equ f = 234 == 234 ; yields true (1) | |

!= | Compare if left expression is unequal to right expression | .equ f = 234 != 234 ; yields false (0) | |

Binary number | ~ | Bit-wise NOT (Bit-by-bit negation) | .equ 0b1010 ~ 0011 ; yields 0b1001 |

& | Bit-wise AND (Bit-by-bit-AND) | .equ f = 0b1010 & 0b0010 ; yields 0b0010 | |

| | Bit-wise OR (Bit-by-bit-OR) | .equ f = 0b1010 | 0b0011 ; yields 0b1011 | |

^ | Bit-wise XOR (Bit-by-bit exclusive-OR) | .equ f = 0b1010 | 0b0011 ; yields 0b1001 | |

<< | Left shift (Multiplication by 2^{n}) |
.equ f = 1 << 7 ; yields 0b1000000 | |

>> | Right shift (Division by 2^{n}) |
.equ f = 0b11000000 >> 2 ; yields 0b00110000 | |

Arithmetic, binary number | + | Plus, Addition | .equ f = 123 + 24 ; yields 147 |

- | Subtraction, Minus | .equ f = 123 - 24 ; yields 99 | |

* | Malnehmen, Multiplizieren | .equ f = 123 * 24 ; ergibt 2952 | |

/ | Teilen, Dividieren | .equ f = 123 / 24 ; ergibt 5! | |

% | Modulo, Division rest | .equ f = 123 % 24 ; yields 3 |

the left shifts are higher rated than the plus and are performed first.

If you are not sure or if you want to override the standard handling, use brackets: expressions in brackets are always processed first, e. g.:

Function | yields | Example |
---|---|---|

LOW | the lower 8 bits | .equ f = Low(0x1234) ; yields 0x34 |

HIGH | the upper 8 bits | .equ f = High(0x1234) ; yields 0x12 |

BYTE2 | Bits 8 to 15 | .equ f = Byte2(0x1234) ; ergibt 0x12 |

BYTE3 | Bits 16 to 23 | .equ f = Byte3(0x123456) ; yields 0x12 |

BYTE4 | Bits 24 to 31 | .equ f = Byte4(0x12345678) ; yields 0x12 |

LWRD | Bits 0 to 15 | .equ f = Lwrd(0x12345678) ; yields 0x5678 |

HWRD | Bits 16 to 31 | .equ f = Hwrd(0x12345678) ; yields 0x1234 |

EXP2 | Two powered by number | .equ f = Exp2(16) - 1 ; yields 65535 |

LOG2 | Logarithm of number by base 2 | .equ f = Log2(65535) ; yields 15 (!) |

©2018 by www.gsc-elektronic.net