diff options
author | Kartik Agaram <vc@akkartik.com> | 2020-10-05 10:16:53 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2020-10-05 10:25:25 -0700 |
commit | f13576b5d273ef9175e938b15f55bb1ead22fb1d (patch) | |
tree | a54c4667e384a7eec44d0e5e7c2da687b670b7e9 /html | |
parent | bb3ce6cdea12ff00b998c5a1c6dbf2c83dba77c2 (diff) | |
download | mu-f13576b5d273ef9175e938b15f55bb1ead22fb1d.tar.gz |
6957
The final fix to the raytracing program involves rounding modes. It turns out x86 processors round floats by default, unlike C which has trained me to expect truncation. Rather than mess with the MXCSR register, I added another instruction for truncation. Now milestone 3 emits perfectly correct results.
Diffstat (limited to 'html')
-rw-r--r-- | html/mu_instructions.html | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/html/mu_instructions.html b/html/mu_instructions.html index 8f21aa08..3f25242f 100644 --- a/html/mu_instructions.html +++ b/html/mu_instructions.html @@ -351,10 +351,19 @@ var/xreg <span class="SpecialChar"><-</span> convert var2/reg2 => <spa var/xreg <span class="SpecialChar"><-</span> convert var2 => <span class="Constant">"f3 0f 2a/convert-to-float *(ebp+"</span> var2.stack-offset <span class="Constant">") "</span> xreg <span class="Constant">"/x32"</span> var/xreg <span class="SpecialChar"><-</span> convert *var2/reg2 => <span class="Constant">"f3 0f 2a/convert-to-float *"</span> reg2 <span class="Constant">" "</span> xreg <span class="Constant">"/x32"</span> +Converting floats to ints performs rounding by default. (We don't mess with the +MXCSR control register.) + var/reg <span class="SpecialChar"><-</span> convert var2/xreg2 => <span class="Constant">"f3 0f 2d/convert-to-int %"</span> xreg2 <span class="Constant">" "</span> reg <span class="Constant">"/r32"</span> var/reg <span class="SpecialChar"><-</span> convert var2 => <span class="Constant">"f3 0f 2d/convert-to-int *(ebp+"</span> var2.stack-offset <span class="Constant">") "</span> reg <span class="Constant">"/r32"</span> var/reg <span class="SpecialChar"><-</span> convert *var2/reg2 => <span class="Constant">"f3 0f 2d/convert-to-int *"</span> reg2 <span class="Constant">" "</span> reg <span class="Constant">"/r32"</span> +There's a separate instruction for truncating the fractional part. + +var/reg <span class="SpecialChar"><-</span> truncate var2/xreg2 => <span class="Constant">"f3 0f 2c/truncate-to-int %"</span> xreg2 <span class="Constant">" "</span> reg <span class="Constant">"/r32"</span> +var/reg <span class="SpecialChar"><-</span> truncate var2 => <span class="Constant">"f3 0f 2c/truncate-to-int *(ebp+"</span> var2.stack-offset <span class="Constant">") "</span> reg <span class="Constant">"/r32"</span> +var/reg <span class="SpecialChar"><-</span> truncate *var2/reg2 => <span class="Constant">"f3 0f 2c/truncate-to-int *"</span> reg2 <span class="Constant">" "</span> reg <span class="Constant">"/r32"</span> + There are no instructions accepting floating-point literals. To obtain integer literals in floating-point registers, copy them to general-purpose registers and then convert them to floating-point. |