<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: 'Calibri'; COLOR: #000000">
<DIV>You asked to be corrected.</DIV>
<DIV> </DIV>
<DIV>Consider Ten(37).</DIV>
<DIV> </DIV>
<DIV>Initially, e = 37.</DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New">37 > 0: TRUE ... ODD(37): TRUE ... 37 DIV
2 = 18</FONT></DIV>
<DIV><FONT face="Courier New">18 > 0: TRUE ... ODD(18): FALSE ... 18 DIV 2
= 9</FONT></DIV>
<DIV><FONT face="Courier New">9 > 0: TRUE ... ODD( 9): TRUE ... 9
DIV 2 = 4</FONT></DIV>
<DIV><FONT face="Courier New">4 > 0: TRUE ... ODD( 4): FALSE ... 4 DIV
2 = 2</FONT></DIV>
<DIV><FONT face="Courier New">2 > 0: TRUE ... ODD( 2): FALSE ... 2 DIV
2 = 1</FONT></DIV>
<DIV><FONT face="Courier New">1 > 0: TRUE ... ODD( 1): TRUE ... 1
DIV 2 = 0</FONT></DIV>
<DIV><FONT face="Courier New">0 > 0: FALSE *DING!*</FONT></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV>ODD(e) tests the least significant bit (LSB) of e.</DIV>
<DIV> </DIV>
<DIV>e = e DIV 2 shifts e right one bit, discarding the LSB and providing a new
one.</DIV>
<DIV> </DIV>
<DIV>It would be a worthwhile exercise on your part to expand the above, with
the values of t and x at each step. (Note: Instrumenting the Oberon code
to produce such a trace will be considered cheating.)</DIV>
<DIV> </DIV>
<DIV>-----Original Message----- </DIV>
<DIV>From: Srinivas Nayak </DIV>
<DIV>Sent: Sunday, June 12, 2016 10:34 AM </DIV>
<DIV>To: ETH Oberon and related systems </DIV>
<DIV>Subject: Re: [Oberon] Understanding ORS.Mod.txt </DIV>
<DIV> </DIV>
<DIV>Hmmm...</DIV>
<DIV> </DIV>
<DIV>I feel...while invoking Ten(), if e=5 (say),</DIV>
<DIV>then immediately inside WHILE,</DIV>
<DIV>IF ODD(e) THEN x := t * x END ;</DIV>
<DIV>will be executed and x will hold a value 10.</DIV>
<DIV> </DIV>
<DIV>After that e will never be ODD.</DIV>
<DIV>So t will gather the value 10000.</DIV>
<DIV> </DIV>
<DIV>While returning, we should multiply x to t resulting 100000.</DIV>
<DIV> </DIV>
<DIV>Please correct me.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>With thanks and best regards,</DIV>
<DIV> </DIV>
<DIV>Yours sincerely,</DIV>
<DIV>Srinivas Nayak</DIV>
<DIV> </DIV>
<DIV>Home: http://www.mathmeth.com/sn/</DIV>
<DIV>Blog: http://srinivas-nayak.blogspot.in/</DIV>
<DIV> </DIV>
<DIV>On 06/12/2016 08:48 PM, John R. Strohm wrote:</DIV>
<DIV>> "RETURN x" is correct.</DIV>
<DIV>></DIV>
<DIV>> On exit from the loop, e = 0. (Strictly, x <= 0, but DIV
preserves the sign of the dividend, so it is not possible for e to go
negative.)</DIV>
<DIV>></DIV>
<DIV>> On the pass immediately before exiting from the loop, e = 1.
ODD(1) is TRUE, so x := t * x will be executed in that pass.</DIV>
<DIV>></DIV>
<DIV>> -----Original Message----- From: Srinivas Nayak</DIV>
<DIV>> Sent: Sunday, June 12, 2016 8:41 AM</DIV>
<DIV>> To: ETH Oberon and related systems</DIV>
<DIV>> Subject: [Oberon] Understanding ORS.Mod.txt</DIV>
<DIV>></DIV>
<DIV>> We see</DIV>
<DIV>></DIV>
<DIV>> PROCEDURE Ten(e: LONGINT): REAL;</DIV>
<DIV>></DIV>
<DIV>> VAR x, t: REAL;</DIV>
<DIV>></DIV>
<DIV>> BEGIN x := 1.0; t := 10.0;</DIV>
<DIV>></DIV>
<DIV>> WHILE e > 0 DO</DIV>
<DIV>></DIV>
<DIV>> IF ODD(e) THEN x := t * x
END ;</DIV>
<DIV>></DIV>
<DIV>> t := t * t; e := e DIV
2</DIV>
<DIV>></DIV>
<DIV>> END ;</DIV>
<DIV>></DIV>
<DIV>> RETURN x</DIV>
<DIV>></DIV>
<DIV>> END Ten;</DIV>
<DIV>></DIV>
<DIV>> Should it be, RETURN x * t ?</DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>> With thanks and best regards,</DIV>
<DIV>></DIV>
<DIV>> Yours sincerely,</DIV>
<DIV>> Srinivas Nayak</DIV>
<DIV>></DIV>
<DIV>> Home: http://www.mathmeth.com/sn/</DIV>
<DIV>> Blog: http://srinivas-nayak.blogspot.in/</DIV>
<DIV>></DIV>
<DIV>> On 06/12/2016 07:01 PM, Srinivas Nayak wrote:</DIV>
<DIV>>> Dear Friends,</DIV>
<DIV>>></DIV>
<DIV>>> Finally I could gather my courage to read NW's compiler
implementation.</DIV>
<DIV>>> Hope to get your help when I get doubts.</DIV>
<DIV>>></DIV>
<DIV>>> In ORS.Mod.txt we see</DIV>
<DIV>>></DIV>
<DIV>>> PROCEDURE Mark*(msg: ARRAY OF CHAR);</DIV>
<DIV>>></DIV>
<DIV>>> VAR p: LONGINT;</DIV>
<DIV>>></DIV>
<DIV>>> BEGIN p := Pos();</DIV>
<DIV>>></DIV>
<DIV>>> IF (p > errpos) & (errcnt
< 25) THEN</DIV>
<DIV>>></DIV>
<DIV>>> Texts.WriteLn(W);
Texts.WriteString(W, " pos "); Texts.WriteInt(W, p, 1); Texts.Write(W, "
");</DIV>
<DIV>>></DIV>
<DIV>>> Texts.WriteString(W,
msg); Texts.Append(Oberon.Log, W.buf)</DIV>
<DIV>>></DIV>
<DIV>>> END ;</DIV>
<DIV>>></DIV>
<DIV>>> INC(errcnt); errpos := p + 4</DIV>
<DIV>>></DIV>
<DIV>>> END Mark;</DIV>
<DIV>>></DIV>
<DIV>>> Why we did, errpos := p + 4 ?</DIV>
<DIV>>> How do I understand/interpret this?</DIV>
<DIV>>> I was thinking, it should be errpos := p + 1 ...</DIV>
<DIV>>> Kindly correct me.</DIV>
<DIV>>></DIV>
<DIV>>></DIV>
<DIV>>> With thanks and best regards,</DIV>
<DIV>>></DIV>
<DIV>>> Yours sincerely,</DIV>
<DIV>>> Srinivas Nayak</DIV>
<DIV>>></DIV>
<DIV>>> Home: http://www.mathmeth.com/sn/</DIV>
<DIV>>> Blog: http://srinivas-nayak.blogspot.in/</DIV>
<DIV>> --</DIV>
<DIV>> Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related
systems</DIV>
<DIV>> https://lists.inf.ethz.ch/mailman/listinfo/oberon</DIV>
<DIV>></DIV>
<DIV>> ---</DIV>
<DIV>> This email has been checked for viruses by Avast antivirus
software.</DIV>
<DIV>> https://www.avast.com/antivirus</DIV>
<DIV>></DIV>
<DIV>> --</DIV>
<DIV>> Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related
systems</DIV>
<DIV>> https://lists.inf.ethz.ch/mailman/listinfo/oberon</DIV>
<DIV>></DIV>
<DIV>--</DIV>
<DIV>Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related
systems</DIV>
<DIV>https://lists.inf.ethz.ch/mailman/listinfo/oberon</DIV></DIV></DIV><br />
<table style="border-top: 1px solid #D3D4DE;">
<tr>
<td style="width: 55px; padding-top: 13px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2322-b" target="_blank"><img src="https://ipmcdn.avast.com/images/2016/icons/icon-envelope-tick-round-orange_184x116-v1.png" height="29px" /></a></td>
<td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2322-b" target="_blank" style="color: #4453ea;">Virus-free</a>
</td>
</tr>
</table></BODY></HTML>