Computer Chess Club Archives


Search

Terms

Messages

Subject: A few assembly tricks

Author: Severi Salminen

Date: 08:41:37 11/29/00

Go up one level in this thread



>  size_t a;
>  int *p
>  ...
>  p[2*a] = 0;
>
>the last expression can be translated to one assembler statement, when p
>and a are allready in an register. (Something like mov 0, (eax,edx,8))

or:

LEA eax,[2*eax]

There are many neat tricks (and fast) what can be done with this scalar
addressing:

LEA eax,[2*eax+eax]	//=3*eax
LEA eax,[4*eax]
LEA eax,[4*eax+eax]	//=5*eax
LEA eax,[8*eax]
LEA eax,[8*eax+eax]	//=9*eax

The eax can be any of the 32 bit registers and you can mix them also, and add an
offset:
LEA ebx,[4*ecx+esi+10]

And these are fast.

Severi



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.