Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: dave DOT nugent AT ns DOT sympatico DOT ca, djgpp AT delorie DOT com Date: Mon, 29 Dec 1997 12:22:32 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: Help with optimizing for speed In-reply-to: <34A40538.F19@ns.sympatico.ca> Precedence: bulk Dave Nugent wrote: > // xoxoxoxoxoxo Snipped code... xoxoxoxoxoxoxoxoxoxoxoxox > for(loop1=0;loop1<160;loop1++) > memcpy(screen+loop1*320,screen_hold+offset+loop1*3200,320); Avoid the multiply using additions: char *scr,*scr_h; scr=screen; scr_h=screen_hold+offset; for (loop1=160; loop1; scr+=320,scr_h+=3200,--loop1) memcpy(scr,scr_h,320); Compile with -O2 -fomit-frame-pointer -ffast-math but not while debugging! > // Now send the screen buffer to VGA Memory.. > _dosmemputl(screen, 16000, 0xa0000); // Send "screen" buffer to VGA > MEMORY Good enough, a marginal gain can be achieved with far or near pointers. > // Ok.. firstly I know I can use shifts << for the multip's. I just > wrote it this way to make easier to understand. Don't worry GCC NEVER uses mul when the numbers are known. > I am copyiny 160 lines of 320 bytes from screen_hold to screen buffers > the offset and 3200 are related to where the screen is located in the > buffer screen_hold. > > I would appreciate any optimization suggestions, or any different > approaches you may have. I guess you can get another, don't know how much faster. Greetings, SET ------------------------------------ 0 -------------------------------- Visit my home page: http://set-soft.home.ml.org/ or Salvador Eduardo Tropea (SET). (Electronics Engineer) Alternative e-mail: set-sot AT usa DOT net - ICQ: 2951574 Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA TE: +(541) 759 0013