delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/18/08:00:56

From: "Alvin Lau" <alvin_lau AT yahoo DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000618083225 DOT 14456M-100000 AT is>
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 <dos.h>
#include <dpmi.h>
#include <go32.h>

#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 ?



- Raw text -


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