调用方式:整型变量=inport(0x端口号);
功能:从指定端口地址读一个字。
头文件:dos.h
inportb()从端口读入一个字节的函数
原形:unsigned char inportb(int portid)
调用方式:字符变量=inportb(0x端口号);
功能:从指定端口地址读一个字节。
头文件:dos.h
int86()执行中断函数(调用8086软中断函数)
原形:int int86(int intno,union REGS *inregs,union REGS *outregs)
调用方式:int86(中断号,&输入指针名,&输出指针名)
返回值:中断处理结束时的AX寄存器的值,错误时outregs->x.cflag!=0
功能:函数int86() 用来执行指定的8086软中断。首先把输入指针所指的共用体中的内容拷贝到CPU 的寄存器中,随即产生对应的中断,返回后将CPU寄存器(AX)的内容拷贝到输出指针指向的共用体中。在使用int86() 函数进行BIOS接口的系统调用时,有的中断调用设有若干选择项,这些选择项可以根据调用时AH寄存器中的值来进行访问。
注:1.需先定义 union REGS 输入指针名,输出指针名;
2.向寄存器传递入口信息
输入指针名.x.寄存器名=要赋的值(入口信息);
3.调用int86后得接受出口信息
变量名=输出指针名.x.寄存器名
4.REGS的定义(在dos.h中):
struct WORDREGS{unsigned int ax, bx, cx, dx, si, di, cflag, flags;}
struct BYTEREGS{unsigned char al, ah, bl, bh, cl, ch, dl, dh;}
union REGS{struct WORDREGS x;struct BYTEREGS h;}
头文件:dos.h
int86x()执行中断函数 (通用8086软中断接口函数)
头文件:dos.h
原形:int int86x(int intno,union REGS *inregs,union REGS *outregs,struct SREGS * segregs)
调用方式:int86x(中断号,&输入指针名,&输出指针名,&段寄存器指针名);
注1:需先定义 union REGS 输入指针名,输出指针名;
union REGS 示意图
struct struct
WORDREGS BYTEREGS
┌ ┌───────┬──────┐──┬── ┐
│ │ │ al │ 1 byte │
│ │ ax ├──────┤──┴─ 2 bytes
│ │ │ ah │ │
│ ├───────┼──────┤───── ┘
│ │ │ bl │
│ │ bx ├──────┤
│ │ │ bh │
│ ├───────┼──────┤
│ │ │ cl │
│ │ cx ├──────┤
│ │ │ ch │
│ ├───────┼──────┤
│ │ │ dl │
│ │ dx ├──────┤
│ │ │ dh │
union regs├───────┼──────┤
│ │ │ │
│ │ si │ │
│ │ │ │
│ ├───────┤ │
│ │ │ │
│ │ di │ │
│ │ │ │
│ ├───────┤ │
│ │ │ │
│ │ cflag │ │
│ │ │ │
│ ├───────┤ │