[Top][All Lists]
[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 02:21:57 +0100 |
Hi there :)
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 = tS.a ;
b = tS.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
- [Bug-gnubg] Bitfields,
W.Stroop <=
[Bug-gnubg] Bitfields, W.Stroop, 2002/11/25
[Bug-gnubg] bitfields, W.Stroop, 2002/11/25