delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/06/22:05:39

From: buers AT gmx DOT de (Dieter Buerssner)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How to get bios timer tick count?
Date: 6 Apr 2000 23:42:23 GMT
Lines: 32
Message-ID: <8cj7cu$6fskm$1@fu-berlin.de>
References: <8cg55n$1kl$1 AT mailint03 DOT im DOT hou DOT compaq DOT com> <200004061524 DOT UAA01453 AT midpec DOT com> <sB7H4.2784$x62 DOT 8311 AT typhoon DOT southeast DOT rr DOT com>
NNTP-Posting-Host: pec-105-106.tnt5.s2.uunet.de (149.225.105.106)
Mime-Version: 1.0
X-Trace: fu-berlin.de 955064543 6812310 149.225.105.106 (16 [17104])
X-Posting-Agent: Hamster/1.3.13.0
User-Agent: Xnews/03.02.04
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

[There is bad line wrapping in the C++ style comment I cite]

pwillard AT mindspring DOT com (pwillard) wrote:

>#include <sys\farptr.h>
>#include <go32.h>
>
>int main (void)
>   {
>    long int x;

I would suggest, to make x an unsigned long.

>
>    // Ok, the formula for accessing DOS memory using
>the_go32_conventional_mem_selector()
>    // command is segment * 16 + offset, so we need to access 0x40 * 0x10
>+0x6c
>    // This assumes the first argument in PTR in pascal is segment and
>thelatter offset.
>
>    x = _farpeekl(_go32_conventional_mem_selector(), 0x40 * 0x10 + 0x6C);
>
>    printf("The BIOS tick count is %d.", x);

The %d is wrong for long int. Use %ld instead (or %lu if you make
x unsigned long). Yes, I do know, that %d will work with DJGPP, but
more by accident, than by design.

>   }

-- Regards, Dieter

- Raw text -


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