www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/02/05/07:54:18

From: apr AT xs4all DOT nl (Ane Roos)
Newsgroups: list.djgpp
To: djgpp-list AT sun DOT soe DOT clarkson DOT edu
Subject: Undesired optimization.
Date: Sun, 05 Feb 1995 13:22:47 +0100
Lines: 36

	I'm trying to convert a routine written for MSDOS,which does a
wait by scanning location 0040:006C.Having not much idea yet as to
how or when this routine is used in other programs,I tried to stay
close to the original and came up with:

#include <sys/farptr.h>
#include <go32.h>
#define MK_FP(seg,off) (((seg)<<4)+(off)) 
/* ----- wait one clock tick -------- */
void wait(void) {               
    int nu,straks;
    nu=_farpeekw(_go32_conventional_mem_selector(),MK_FP(0x40,0x6c)); 
    straks=nu;
    while (nu==straks){
    straks=_farpeekw(_go32_conventional_mem_selector(),MK_FP(0x40,0x6c)); 
    continue;    
    }
}

	This doesn't work,however,because the compiler(optimization on)
doesn't honor the second _farpeekw but simply uses the stored result
of the first one.Optimization is desirable because of the farpeek
(says the FAQ),but how could I force the compiler to do it as I
wrote it?

	Being fairly new on the Net,I'm reading tons of FAQ-like material.
I find the DJGPP-one outstanding,both for its contents and for its
beautifully crisp,good-natured and unperturbed style.The tip to
stubedit GCC did wonders for performance on my 4Mb 386SX.Thank you,
Eli Zaretski.


---------
Ane Roos        |  Nice,nice,very nice--    |  Calypso 53,
apr AT xs4all DOT nl   |  So many different people |  The Book of Bokonon,
+31 20 6255904  |  In the same device.      |  - Kurt Vonnegut

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019