delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/18/01:37:31

Date: Sun, 18 Jun 2000 08:32:56 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alvin Lau <alvin_lau AT yahoo DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Inline assembly code problem
In-Reply-To: <394b2954@newsgate.hknet.com>
Message-ID: <Pine.SUN.3.91.1000618083225.14456M-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sat, 17 Jun 2000, Alvin Lau wrote:

> When I run the following code, my computer will halt and sometimes will
> reboot automatically:
> 
> int main(void)
> {
>   unsigned factor=4;
>   unsigned short rate=1193180/(18*factor);
>   // speed up timer
>   asm (
>     "cli\n"
>     "movb $36h,%%al\n"
>     "outb %%al,$43h\n"
>     "movw %0,%%ax\n"
>     "outb %%al,$40h\n"
>     "movb %%ah,%%al\n"
>     "outb %%al,$40h\n"
>     "sti\n"
>     :
>     :"m"(rate)
>   );
> }

My references indicate that you need to insert some delay after each
OUTB (except the last).  The delay must be at least 1 microsecond, to
allow the timer device sufficient time to handle the previous request
before the next one.

More importantly, note that this code speeds up the system clock, but
doesn't take care to install a timer interrupt handler so that the
rest of the system sees the normal 18.2 times-per-second heartbeat.
That means you are forcing the entire OS to work 4 times faster, which
might indeed cause reboots if some software that sits on the timer
interrupt chain doesn't have enough time to do its thing before the
next timer tick strikes.

- Raw text -


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