From: "Alvin Lau" Newsgroups: comp.os.msdos.djgpp References: Subject: Re: Inline assembly code problem Date: Sun, 18 Jun 2000 19:43:02 +0800 Lines: 116 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 X-Original-NNTP-Posting-Host: ts21085.hknet.com Message-ID: <394cb48b$1@newsgate.hknet.com> NNTP-Posting-Host: news.hknet.com X-Trace: 18 Jun 2000 19:53:14 +0800, news.hknet.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com > 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. Thank you for your help, but now I have another problem. Here is my timer program: #include #include #include #define DEBUG 1 unsigned long ticks; unsigned factor; unsigned countdown; __dpmi_paddr oldtimer; __dpmi_paddr newtimer; void timer(void) { ticks++; countdown--; if (!countdown) { countdown=factor; asm( "pushf\n" "lcall %0\n" : :"m"(oldtimer) ); } else { asm( "int $1Ch\n" "movb $20h,%al\n" "outb %al,$20h\n" ); } asm("iret\n"); } void inittimer(unsigned factor) { unsigned short rate=1193180/(18*factor); ::factor=factor; newtimer.selector=_my_cs(); newtimer.offset32=(unsigned long)timer; __dpmi_get_protected_mode_interrupt_vector(0x08,&oldtimer); #ifdef DEBUG asm("pushf\n"); timer(); #endif __dpmi_set_protected_mode_interrupt_vector(0x08,&newtimer); asm("cli\n"); outportb(0x43,0x36); outportb(0x40,rate&0xFF); outportb(0x40,rate>>8); asm("sti\n"); } void killtimer(void) { asm("cli\n"); outportb(0x43,0x36); outportb(0x40,0); outportb(0x40,0); asm("sti\n"); __dpmi_set_protected_mode_interrupt_vector(0x08,&oldtimer); } unsigned long timeticks(void) { return ticks; } int main() { inittimer(4); killtimer(); } When I run this program, I got a message "General Protection Fault". I tried to run this program step by step in RHIDE, it returns a message "Program has received signal: SIGABRT, Aborted" while running the statement asm("iret\n"); Do you know what problem ?