<html><head><base href="x-msg://331/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Word.Or(a, 0) always has type Word.T, which is currently defined to be INTEGER.</div><div>Word.Divide takes two Word.T, treats them as unsigned, and performs unsigned division on them, returning the bits as Word.T.</div><div>DIV takes two INTEGERs and performs signed division on them.</div><div><br></div><div>What was the question again?</div>
<br><div><div>On Nov 23, 2010, at 2:57 AM, Jay K wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; ">So, here are two maybe interesting cases.<br>At least to jog my brain and help make sense of the system.<br><br><br>DIV vs. Word.Divide of CARDINAL.<br>u is for unsigned, or word<br>C is for Cardinal.<br> Cardinal is [0..LAST(INTEGER)].<br><br><br><*NOWARN*>PROCEDURE uDivide_param_C_C(a:CARDINAL;b:CARDINAL):Word.T=BEGIN RETURN Word.Divide(a,b);END uDivide_param_C_C;<br><br><*NOWARN*>PROCEDURE Divide_param_C_C(a:CARDINAL;b:CARDINAL):CARDINAL=BEGIN RETURN a DIV b;END Divide_param_C_C;<br><br><br>(5579) begin_procedure procedure:0x178:Divide__Divide_param_C_C Divide__Divide_param_C_C<br>(5580) load var:0x2E5:a offset:0 src_t:word_64 dst_t:int_64<br>(5581) load var:0x2E6:b offset:0 src_t:word_64 dst_t:int_64<br>(5582) div type:int_64<br>(5583) check_lo type:int_64 0 code:1<br>(5584) exit_proc type:word_64<br>(5585) end_procedure procedure:0x178:Divide__Divide_param_C_C<br><br><br>(5571) begin_procedure procedure:0x177:Divide__uDivide_param_C_C Divide__uDivide_param_C_C<br>(5572) load var:0x2E2:a offset:0 src_t:word_64 dst_t:int_64<br>(5573) load var:0x2E3:b offset:0 src_t:word_64 dst_t:int_64<br>(5574) div type:word_64<br>(5575) exit_proc type:int_64<br>(5576) end_procedure procedure:0x177:Divide__uDivide_param_C_C<br><br><br>Thoughts?<br><br><br>Is it right for the load to convert from word to int?<br> (I'll see about removing the address_token for unsigned/signed-only conversions, if it is there.)<br> <br> <br>I can see how makes sense.<br>CARDINAL is just a subrange of INTEGER. So it is INTEGER.<br><br><br>If/when we are clever, we can represent the subranges in the types<br>in the backend, and the optimizer should notice, and these<br>would generate identical code, if they don't already.<br><br><br>But the return types of the divides vary as well.<br>There do exist unsigned types at this level.<br><br><br>Does that imply that<br>a,b:CARDINAL<br><br>Word.Or(a, 0) DIV Word.Or(b, 0)<br>is different than<br>a DIV b?<br><br><br>I guess so. Different code at least.<br>Given that cardinal is "half range", the results should always match.<br>That is, really, other than added/missing range checks, CARDINAL<br>will always act the same as INTEGER.<br>So then the unsigned types..don't mean anything?<br><br><br> - Jay<br><br><br><br><br></div></span></blockquote></div><br></body></html>