Author: Gerd Isenberg
Date: 13:08:03 10/01/04
Go up one level in this thread
On October 01, 2004 at 10:58:43, Dan Honeycutt wrote:
>If I have an inline function, ie:
>
>_inline int Distance(int square1, int square2)
This is fine.
Most likely there is an implicit fastcall if inlined, not pushing copies of the
squares on the stack, but passing them via registers. You may try explicit
__fastcall with msc and inspect assembly.
>
>which is going to return the max rank/file difference but is not going to alter
>the arguements, would I be better off passing the arguements by reference, ie:
>
>_inline int Distance(int & square1, int & square2)
This is bad - if you don't want to change the passed squares.
A clever compiler may "understand" that there are no sideeffects on the squares
- and the resulting asm may be the same, but it isn't necessary to "fool" the
compiler. You can tell compiler this explicitely by using const refs/pointer,
that there is no sideeffect:
_inline int Distance(const int & square1, const int & square2)
This is fine for types with size of pointer (4 on x86-32) (refs are similar to
pointer in asm) is less the size of the type of the parameter, like passing
structs with some ints, and clearly required for sizeof(type) > 8.
On x86-64 passing 64-bit as parameter is most likely via fastcall too (by
default?), rcx on the first place. I am not sure whether size of pointer is 8
(64-bit) in x86 64-bit mode.
>
>so as to save having to make a copy of the arguements. Or would the compiler
>figure that out on it's own since the function is inline? I'm using MS VC 6.
You may generate an assmbly listing (Project Settings, C/C++, Categoty Listing
File, Listing file type = e.g. assembly with source code).
Or you may but an debug break (interrupt 3), a hard coded breakpoint temporary
inside your source functions to inspect the release assembly in the disassemly
window (alt 8).
E.g. for msc6
__forceinline int Distance(int square1, int square2)
{
__asm int 3
// code to inspect
}
Are there cmp- and jxx, like jge, jle etc. instructions behind?
Gerd
>
>Thanks
>Dan H.
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.