bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnubg] Bitfields


From: W.Stroop
Subject: [Bug-gnubg] Bitfields
Date: Mon, 25 Nov 2002 04:27:54 +0100

Hi there :)

OEPS typo in C code fragment
Here is the right version

Just a remark.
While examining 'eval.c' , i saw that some structures, which are used in
a.o.  'eval.c &  'rollout.c ', contain bitfields. IMO those  bitfields( if
used extensivily) are slowing down the program  a lot . As an example i give
the assembly output of the following ' C ' code fragment

struct {
unsigned int a : 5;
unsigned int b : 6;
}tbf ;

 void testfunc () {
 int a,b;
/* initialise struct */
 tbf.a = 24 ;
 tbf.b = 25;
/* extract into a & b  */
 a = tbf.a ;
 b = tbf.b ;
}

Assemby output :

// initialise struct

and byte ptr [00403000], E0
or byte ptr [00403000], 18
and word ptr [00403000], F81F
or word ptr [00403000], 0320

// extract  the bitfields into the vars a & b ;
    movzx eax, byte ptr [00403000]
    mov edx, eax
    and edx, 0000001F
    mov dword ptr [ebp-04], edx  /* a = initialised
    movzx eax, word ptr [00403000]
   shr ax, 05
   movzx edx, ax
   mov eax, edx
  and eax, 0000003F
  mov dword ptr [ebp-08], eax /* b =  initialised


 Greetings Rob





reply via email to

[Prev in Thread] Current Thread [Next in Thread]