I am having a lack of confidence in the assembler code output #1339
Replies: 1 comment
-
No, it's not wrong. Note that the destination for When multiplying 32-bit values, the differences in the results of (Also keep in mind that |
Beta Was this translation helpful? Give feedback.
-
(edited for formatting)
It seems that in all cases where the unsigned 'mul' instruction is used, SharpLab shows that an 'imul' is emitted, but that cant possibly be the actual case at runtime or else everyone would quickly notice that unsigned multiplication is broken on an x86/x64 targets.
Repro class contains a function f() overloaded with both uint and int parameters.
public class C {
public uint f(uint x, uint y) => xy;
public int f(int x, int y) => xy; }
C.f(UInt32, UInt32)
L0000: mov eax, edx
L0002: imul eax, r8d
L0006: ret
C.f(Int32, Int32)
L0000: mov eax, edx
L0002: imul eax, r8d
L0006: ret
The first is in error, that should be an unsigned 'mul' rather than the signed 'imul'
Are these just minor translation errors? How extensive is this?
Beta Was this translation helpful? Give feedback.
All reactions