Date: Sun, 18 Jun 2000 08:32:56 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Alvin Lau cc: djgpp AT delorie DOT com Subject: Re: Inline assembly code problem In-Reply-To: <394b2954@newsgate.hknet.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Precedence: bulk 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.