2 ms·
Well, if you want a correct result with negative numbers, you have to implement the modulo operation, not remainder. The distance in the example can be negative
by junke 10y ago
Well, if you want a correct result with negative numbers, you have to implement the modulo operation, not remainder. The distance in the example can be negative, so can be the sum, but you want the resulting position to always be positive.
There are other instructions that probably deal with returning a proper fixnum. If I remember correctly, the CLC before the RET is to signal that there is a single return value, not multiple ones. I am not saying that there aren't possible optimisations, but (i) some things are tied to the existing computation models and (ii) SBCL developers have limited resources.
See also SB-ASSEM to emit machine code (https://www.pvk.ca/Blog/2014/03/15/sbcl-the-ultimate-assembly-code-breadboard/ https://www.pvk.ca/Blog/2014/03/15/sbcl-the-ultimate-assembl...).