Author: Gerd Isenberg
Date: 06:43:52 05/01/05
Go up one level in this thread
>Just curious about the MUL mreg16 - doesn't it need another upcode prefix (like
>many 16 bit operations on x86-32)?
>
Yes 0x66 - operand size prefix.
int mul32 (int a, int b) {
__asm {
mov eax, [a]
mov ecx, [b]
imul ecx
}
}
?mul32@@YAHHH@Z PROC ; mul32
00550 8b 44 24 04 mov eax, DWORD PTR _a$[esp-4]
00554 8b 4c 24 08 mov ecx, DWORD PTR _b$[esp-4]
00558 f7 e9 imul ecx
0055a c3 ret 0
?mul32@@YAHHH@Z ENDP ; mul32
short mul16 (short a, short b) {
__asm {
mov ax, [a]
mov cx, [b]
imul cx
}
}
?mul16@@YAFFF@Z PROC ; mul16
00560 66 8b 44 24 04 mov ax, WORD PTR _a$[esp-4]
00565 66 8b 4c 24 08 mov cx, WORD PTR _b$[esp-4]
0056a 66 f7 e9 imul cx
0056d c3 ret 0
?mul16@@YAFFF@Z ENDP ; mul16
msc2005ß does following:
short mul16 (short a, short b)
{
return a * b;
}
?mul16@@YAFFF@Z PROC ; mul16
00560 8b 44 24 04 mov eax, DWORD PTR _a$[esp-4]
00564 8b 4c 24 08 mov ecx, DWORD PTR _b$[esp-4]
00568 0f af c1 imul eax, ecx
0056b c3 ret 0
?mul16@@YAFFF@Z ENDP ; mul16
as you already mentioned
__int64 mul64_32 (int a, int b)
{
return a * b; // carefull
}
?mul64_32@@YA_JHH@Z PROC ; mul64_32
00560 8b 44 24 04 mov eax, DWORD PTR _a$[esp-4]
00564 0f af 44 24 08 imul eax, DWORD PTR _b$[esp-4]
00569 99 cdq
0056a c3 ret 0
?mul64_32@@YA_JHH@Z ENDP ; mul64_32
__int64 mul64_32 (int a, int b)
{
return (__int64)a * b;
}
?mul64_32@@YA_JHH@Z PROC ; mul64_32
00560 8b 44 24 04 mov eax, DWORD PTR _a$[esp-4]
00564 f7 6c 24 08 imul DWORD PTR _b$[esp-4]
00568 c3 ret 0
?mul64_32@@YA_JHH@Z ENDP ; mul64_32
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.