2 ms·
They can, yes. I recommend playing around with code at https://godbolt.org https://godbolt.org. Here's an example using division: https://godbolt.org/z/xqebM6d
by Jtsummers 2y ago
They can, yes. I recommend playing around with code at https://godbolt.org https://godbolt.org. Here's an example using division:
https://godbolt.org/z/xqebM6d11 https://godbolt.org/z/xqebM6d11
That code is simple, just divides the argument by a constant. The linked version divides by 32, note the sar eax, 5 instruction, that's the actual division computation. Play around with other constants and you'll get other results (including multiply/shift instruction combinations for non-power of two constants).