Newsgroups: comp.os.msdos.programmer Path: utzoo!censor!meadow!py From: py@meadow.uucp (Peter Yeung) Subject: Re: Generating delays Message-ID: <1991Mar7.053927.12273@meadow.uucp> Reply-To: py@meadow.UUCP (Peter Yeung) Organization: Amdahl Canada Ltd., Software Development Center References: Distribution: comp Date: Thu, 7 Mar 91 05:39:27 GMT In article melling@cs.psu.edu (Michael D Mellinger) writes: > >I need to be able to generate delays of around 1/2 second. Anyone >have a good way of doing this? I'm using MS C 6.0. The best I can >come up with is a 1 second delay. > If it does not have to be really accurate, use a loop to check the clock counter at location 0x46c (4 bytes counter) until it advances 9 times. This method has the accuracy of within 1/18 of a second. A more accurate method is to write a counting loop to count how many times does it loop when the clock counter advance from x to x+1 and use the loop count as a timing base for a timing loop which take the same number of cycles to loop once as the initial counting loop. Yes, this implies intimate knowledge of the code generated by the compiler or write both loops in assembler (can be easily done in TC). >-Mike -- Peter Yeung Amdahl Canada Ltd., Software Development Center 2000 Argentia Road, Plaza 2, Suite 300 Mississauga, Ont. L5N 1V8 Phone: (416) 542-6300 Fax: (416) 858-2233