From: "Steve Patton" Newsgroups: comp.os.msdos.djgpp Subject: Re: does anyone have anyideas on how to optimize this code Date: 28 Nov 1997 18:12:26 GMT Organization: AT&T WorldNet Services Lines: 85 Message-ID: <65n1ia$q6h@bgtnsc03.worldnet.att.net> References: <346C8822 DOT D3725C8E AT earthlink DOT net> NNTP-Posting-Host: 12.67.2.170 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk STEVEN S. FALLS wrote in article <346C8822 DOT D3725C8E AT earthlink DOT net>... > Hi, my name is Ardy and I have a pixelplotting ruteen that needs to be > optmized. This is what I got, please help! > thanks, > -Ardy > > This was writen in NASM: > > BITS 32 > GLOBAL _SetPix__Fiic > GLOBAL _SetPixRam__Fiic > GLOBAL _GetPix__Fii > GLOBAL _GetPixRam__Fii > GLOBAL _ClearPg__Fv > GLOBAL _ClearPgRam__Fv > GLOBAL _CopyPg__Fv > GLOBAL _Line__Fiiiic > EXTERN __go32_info_block > EXTERN _YTbl > EXTERN _RamPg > > SECTION .text > _SetPix__Fiic: > push ebp > mov edx,[_YTbl] > mov ebx,[esp+12] > mov ebx,[edx+ebx*4] > add ebx,[esp+8] > mov al,[esp+16] > mov fs,[__go32_info_block+26] > add ebx,0A0000h > mov [fs:ebx],al > pop ebp > ret > _SetPixRam__Fiic: > Ok, that was original, here's one with suggestions. BITS 32 GLOBAL _SetPix__Fiic GLOBAL _SetPixRam__Fiic GLOBAL _GetPix__Fii GLOBAL _GetPixRam__Fii GLOBAL _ClearPg__Fv GLOBAL _ClearPgRam__Fv GLOBAL _CopyPg__Fv GLOBAL _Line__Fiiiic EXTERN __go32_info_block EXTERN _YTbl EXTERN _RamPg SECTION .text _SetPix__Fiic: push ebp mov edx,[_YTbl] mov ebx,[esp+12] mov ebx,[edx+ebx*4] // Look below add ebx,[esp+8] mov al,[esp+16] mov fs,[__go32_info_block+26] add ebx,0A0000h mov [fs:ebx],al pop ebp ret _SetPixRam__Fiic: I don't know if GCC will take care of this, but it appears that you're multiplying ebx by 4. You can simply do this shl $2, %ebx // what should be AT&T format I don't know if that's the correct syntax (I'm used to Intel format), so if you get an error, just try shl %ebx, $2 // format used by Intel That will do it in 1 clock cycel on a 486, as opposed to 10-50(about) clocks on a 486. You might try that and see if that helps you at all. -Steve