c语言中的1CH中断里面的传递涵数问题,求各位大侠帮我这大一学生啊 ( 积分: 41 )

  • 主题发起人 linuxcici
  • 开始时间
L

linuxcici

Unregistered / Unconfirmed
GUEST, unregistred user!
这是利用BOIS的1CH中断来显示的一个秒表功能,但里面有些涵数传递不是很懂,请大侠你帮帮我这学生好吗?
#include<dos.h>
#include<conio.h>
#define programsize 400
#define TRUE 1
void interrupt(*oldtimer)(); /*请问这个定义了什么呢?只说明了oldtimer是涵数指针*/
void interrupt newtimer();
void install();
static struct SREGS seg;
int b=0;
int b1=0;
unsigned intsp,intss;
unsigned myss,stack,x0,y0;
int busy=0;
void on_timer();
void goxy();
void rexy();
void prt();



main()
{

char ch;
char *p;
clrscr();
p=(char *)newtimer; /* 这里是将newtimer这个涵数的返回地址转换成char型,但newtimer涵数在哪里啊?*/
on_timer(p);


while(TRUE)
{
ch=getch();
switch(ch)
{
case '0': install(oldtimer);break;

case '1': b1=47;install(newtimer);break;

case 'q':install(oldtimer);exit(1);
default:
printf("%c",ch);
}

}

}


void on_timer(p)
int (*p)();
{
segread(&seg);
stack=programsize * 16;
myss=_SS;
oldtimer=getvect(0x1c);

}


void install(void interrupt(*faddr)()) /* 这里又是哪里传过来的地址呢? */
{
disable();
setvect(0x1c,faddr);
enable();
}

void interrupt newtimer()
{
(* oldtimer)(); / *这里不是定义一个oldtimer指针涵数吗?但是指向谁呢? */
if(busy==0)
{
busy=1;
disable();
intsp=_SP;
intss=_SS;
_SP=stack;   /*保存_SP,_SS的值*/
_SS=myss;
enable();
rexy();
clrscr();
window(50,1,54,3);
textcolor(YELLOW);
textbackground(RED);
b+=1;
if(b==18)
{
gotoxy(3,2);
b1++;
b=0;
if(b1>57)b1=48;
prt(b1);
}
goxy(x0,y0);
disable();
_SP=intsp;           /*恢复_SP,_SS的值*/
_SS=intss;
enable();
busy=0;
}
}

void goxy(int x,int y)
{
union REGS rg;
rg.h.ah=2;
rg.h.dl=y;
rg.h.dh=x;
rg.h.bh=0;
int86(0x10,&rg,&rg);
}

void rexy()
{
union REGS rg;
rg.h.ah=3;
rg.h.bh=0;
int86(0x10,&rg,&rg);
y0=rg.h.dl;
x0=rg.h.dh;

}

void prt(p)
{
union REGS rg;
rg.h.al=p;
rg.h.ah=14;
int86(0x10,&rg,&rg);
}
 
这是利用BOIS的1CH中断来显示的一个秒表功能,但里面有些涵数传递不是很懂,请大侠你帮帮我这学生好吗?
#include<dos.h>
#include<conio.h>
#define programsize 400
#define TRUE 1
void interrupt(*oldtimer)(); /*请问这个定义了什么呢?只说明了oldtimer是涵数指针*/
void interrupt newtimer();
void install();
static struct SREGS seg;
int b=0;
int b1=0;
unsigned intsp,intss;
unsigned myss,stack,x0,y0;
int busy=0;
void on_timer();
void goxy();
void rexy();
void prt();



main()
{

char ch;
char *p;
clrscr();
p=(char *)newtimer; /* 这里是将newtimer这个涵数的返回地址转换成char型,但newtimer涵数在哪里啊?*/
on_timer(p);


while(TRUE)
{
ch=getch();
switch(ch)
{
case '0': install(oldtimer);break;

case '1': b1=47;install(newtimer);break;

case 'q':install(oldtimer);exit(1);
default:
printf("%c",ch);
}

}

}


void on_timer(p)
int (*p)();
{
segread(&seg);
stack=programsize * 16;
myss=_SS;
oldtimer=getvect(0x1c);

}


void install(void interrupt(*faddr)()) /* 这里又是哪里传过来的地址呢? */
{
disable();
setvect(0x1c,faddr);
enable();
}

void interrupt newtimer()
{
(* oldtimer)(); / *这里不是定义一个oldtimer指针涵数吗?但是指向谁呢? */
if(busy==0)
{
busy=1;
disable();
intsp=_SP;
intss=_SS;
_SP=stack;   /*保存_SP,_SS的值*/
_SS=myss;
enable();
rexy();
clrscr();
window(50,1,54,3);
textcolor(YELLOW);
textbackground(RED);
b+=1;
if(b==18)
{
gotoxy(3,2);
b1++;
b=0;
if(b1>57)b1=48;
prt(b1);
}
goxy(x0,y0);
disable();
_SP=intsp;           /*恢复_SP,_SS的值*/
_SS=intss;
enable();
busy=0;
}
}

void goxy(int x,int y)
{
union REGS rg;
rg.h.ah=2;
rg.h.dl=y;
rg.h.dh=x;
rg.h.bh=0;
int86(0x10,&rg,&rg);
}

void rexy()
{
union REGS rg;
rg.h.ah=3;
rg.h.bh=0;
int86(0x10,&rg,&rg);
y0=rg.h.dl;
x0=rg.h.dh;

}

void prt(p)
{
union REGS rg;
rg.h.al=p;
rg.h.ah=14;
int86(0x10,&rg,&rg);
}
 
>> p=(char *)newtimer; /* 这里是将newtimer这个涵数的返回地址转换成char型,但newtimer涵数在哪里啊?*/
在main函数下面:void interrupt newtimer()
 
void interrupt(*oldtimer)(); /*请问这个定义了什么呢?只说明了oldtimer是涵数指针*/
void interrupt newtimer();

这两句说明什么呢?
 
顶部