<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"><pre class="moz-quote-pre" wrap=""><font color="#000000" face="UICTFontTextStyleTallBody"><span style="caret-color: rgb(0, 0, 0); white-space: normal; background-color: rgba(255, 255, 255, 0);">Walter</span></font></pre></div><blockquote type="cite"><div dir="ltr"><blockquote type="cite" cite="mid:6DD503A0-A4CA-44F8-8A67-AFA2F59232FB@iaeth.ch"><pre class="moz-quote-pre" wrap=""><font color="#000000" face="UICTFontTextStyleTallBody"><span style="caret-color: rgb(0, 0, 0); white-space: normal; background-color: rgba(255, 255, 255, 0);">MOD/DIV are just other words for AND/ASR</span></font></pre></blockquote></div></blockquote>I forgot to mention two important conditions, so my statement is really true:<div>A) the divisor has to be a power of two</div><div>B) the divisor has to be constant expression.</div><div><br></div><div>If one of these conditions is not met, the complier generates a division instead of AND/ASR.</div><div><br></div><div>For bit (or subfield) manipulations Oberon-07 offers different means</div><div>1) SET: *, -, +, /, INCL, EXCL, IN</div><div>2) LSL, ASR, ROR, ODD, SYSTEM.BIT (SYSTEM depends on your compiler)</div><div>3) DIV, MOD (with the conditions above)</div><div>4) PACK, UNPK bit manipulations on REALs</div><div><br><div dir="ltr">Jörg</div><div dir="ltr"><br>Am 30.10.2018 um 01:14 schrieb Walter Gallegos <<a href="mailto:waltergallegos@vera.com.uy">waltergallegos@vera.com.uy</a>>:<br><br></div><blockquote type="cite"><div dir="ltr">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<p><br>
</p>
<blockquote type="cite" cite="mid:6DD503A0-A4CA-44F8-8A67-AFA2F59232FB@iaeth.ch">
<pre class="moz-quote-pre" wrap="">...MOD/DIV are just other words for AND/ASR...
</pre>
</blockquote>
<p><font size="-1">All times I use SET when working with hardware
registers; </font><font size="-1"><span id="result_box" class="" lang="en"><span class="">so, I was curious about the
generated code for MOD/DIV alternative</span><br>
<span class=""><br>
</span></span></font></p>
<p><font size="-1"><span id="result_box" class="" lang="en"><span class="">A simple test</span></span> </font> <font size="-1">for extracting some bits from a 16 bits value <br>
</font> <font size="-1"><br>
a := 2345H; <br>
b := a DIV 100H MOD 7; <br>
</font> <font size="-1"><br>
Generate : <br>
</font> <font size="-1"><br>
10 40002345 MOV R0 R0 9029 <br>
11 A0D00000 STR R0 SB 0 </font><font size="-1"><br>
12 80D00000 LDR R0 SB 0 <br>
13 40020008 ASR R0 R0 8 <br>
14 400B0007 DIV R0 R0 7 <br>
15 20000000 MOV' R0 R0 R0 <br>
16 A0D00004 STR R0 SB 4 <br>
</font> <font size="-1"><br>
I forget something ? </font></p>
</div></blockquote></div></body></html>