Walter
MOD/DIV are just other words for AND/ASR
I forgot to mention two important conditions, so my statement is really true:
A) the divisor has to be a power of two
B) the divisor has to be constant expression.

If one of these conditions is not met, the complier generates a division instead of AND/ASR.

For bit (or subfield) manipulations Oberon-07 offers different means
1) SET: *, -, +, /, INCL, EXCL, IN
2) LSL, ASR, ROR, ODD, SYSTEM.BIT (SYSTEM depends on your compiler)
3) DIV, MOD (with the conditions above)
4) PACK, UNPK bit manipulations on REALs

Jörg

Am 30.10.2018 um 01:14 schrieb Walter Gallegos <waltergallegos@vera.com.uy>:


...MOD/DIV are just other words for AND/ASR...

All times I use SET when working with hardware registers; so, I was curious about the generated code for MOD/DIV alternative

A simple test for extracting some bits from a 16 bits value

    a := 2345H;
    b := a DIV 100H MOD 7;

Generate :

10    40002345    MOV    R0    R0    9029
11    A0D00000    STR    R0    SB    0

12    80D00000    LDR    R0    SB    0
13    40020008    ASR    R0    R0    8
14    400B0007    DIV    R0    R0    7
15    20000000    MOV'    R0    R0    R0
16    A0D00004    STR    R0    SB    4

I forget something ?