Author: Gerd Isenberg
Date: 01:36:06 02/04/03
Go up one level in this thread
On February 04, 2003 at 04:00:05, Marcus Heidkamp wrote:
>Has anyone tried to use MMX instructions inside a function (with arguments)
>using the _fastcall calling convention? I have the strange impression, the the
>compiler does some weird things. Just an example:
>
>_declspec(naked) void _fastcall Test(int n)
>{
> n; // just to suppress a level 4 warning
> _asm
> {
> ret
> }
>}
>
>works ok, but
>
>_declspec(naked) void _fastcall Test(int n)
>{
> n;
> _asm
> {
> emms
> ret
> }
>}
>
>produces some code on function ENTRY similar to some prolog, which make
>absolutely no sense. The disassembler output looks something like this (the
>naked declaration is just to simplify the asm output, but it makes no difference
>to generate prolog and epilog):
>
>mov [n], ecx
>emms
>ret
>
>The problem comes in here, because the [n] memory location is somewhere on the
>stack [esp - 4], which has not been allocated properly before function call. By
>the way: This is exactly what _fastcall should do - whenever possible use
>registers (mainly ecx, edx) to pass arguments to the function, and if not
>possible, use normal stack operations (push ...).
>
>I searched for two weeks the help files, knowledge base, Microsoft home page,
>etc., but did not find anything that prohibits the use of _fastcall when also
>using MMX instructions (either inline asm or intrinsics behaves the same way). I
>am using MSVC6 (Professional) SP5, processor pack (for SP5).
>
>Any comments, hints, suggestions?
>
>Thank you in advance.
>
>Marcus Heidkamp
Hi Marcus,
No way with MSC to pass parameter via register to inlined asm functions, it's a
mess - not necessary instructions and load/stores. In a few critical functions i
pass (bitboard) parameters directly via mmx-registers and do a movq mmx, [qword
aligned bitboard] outside, the same for returning bitboards, to save two
(edx:eax) expensive (at least on Athlon) movd reg32, mmxReg vector path
instructions.
Regards,
Gerd
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.