标题:c语言求救!!!
只看楼主
guohao0427
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-3-24
 问题点数:0 回复次数:2 
c语言求救!!!
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<stdio.h>
#include<bios.h>
#include<process.h>
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef unsigned long DWORD;
#define PDI_BUS_SHIFT 8
#define PDI_BUS_SIZE 8
#define PDI_BUS_MAX 0xFF
#define PDI_BUS_MASK 0xFF00
#define PDI_DEVICE_SHIFT 3
#define PDI_DEVICE_SIZE 5
#define PDI_DEVICE_MAX 0x1F
#define PDI_DEVICE_MASK 0x00F8
#define PDI_FUNCTION_SHIFT 0
#define PDI_FUNCTION_SIZE 3
#define PDI_FUNCTION_MAX 0x7
#define PDI_FUNCTION_MASK 0x0007
#define MK_PDI(bus,dev,func) (WORD)((bus&PDI_BUS_MAX)<<PDI_DEVICE_SIZE|(dev&PDI_DEVICE_MAX)<<PDI_DEVICE_SHIFT|(func&PDI_FUNCTION_MAX) )
#define PCI_CONFIG_ADDRESS 0xCF8
#define PCI_CONFIG_DATA 0xCFC
#define MK_PCICFGADDR(bus,dev,func) (DWORD)(0x80000000L|(DWORD)MK_PDI(bus,dev,func)<<8)

DWORD inpd(int portid)
{
  DWORD dwRet;
  _asm("mov dx,portid");
  _asm("lea bx,dwRet");
  __emit__(
           0x66,0x50,
           0x66,0xED,
           0x66,0x89,0x07,
           0x66,0x58);
  return dwRet;
}

void outpd(int portid,DWORD dwVal)
{
   _asm("mov dx,portid");
   _asm("lea bx,dwVal");
   __emit__(
          0x66,0x50,
          0x66,0x8B,0x07,
          0x66,0xEF,
          0x66,0x58);
   return;
}
            
int main(void)
{
   int bus,dev,func;
   int i;
   DWORD dwAddr;
   DWORD dwData;
   FILE*hF;
   char szFile[0x10];
   printf("\n");
   printf("Bus#\tDevice#\tFunc#\tVendor\tDevice\tClass\tIRQ\tIntPin\n");
   for(bus=0;bus<=PDI_BUS_MAX;++bus)
      {
         for(dev=0;dev<=PDI_DEVICE_MAX;++dev)
            {
              for(func=0;func<=PDI_FUNCTION_MAX;++func)
                 {
                    dwAddr=MK_PCICFGADDR(bus,dev,func);
                    outpd(PCI_CONFIG_ADDRESS,dwAddr);
                    dwData=inpd(PCI_CONFIG_DATA);
                    if ((WORD)dwData!=0xFFFF)
                       {
                         printf("%2.2X\t%2.2X\t%1X\t",bus,dev,func);
                         printf("%4.4X\t%4.4X\t",(WORD)dwData,dwData>>16);
                         outpd(PCI_CONFIG_ADDRESS, dwAddr|0x8);
                         dwData = inpd(PCI_CONFIG_DATA);
                         printf("%6.6lX\t", dwData>>8);
                         outpd(PCI_CONFIG_ADDRESS,dwAddr|0x3C);
                         dwData=inpd(PCI_CONFIG_DATA);
                         printf("%d\t",(BYTE)dwData);
                         printf("%d",(BYTE)(dwData>>8));
                         printf("\n");
                         sprintf(szFile,"PCI%2.2X%2.2X%X.bin",bus,dev,func);
                         hF=fopen(szFile,"wb");
                         if(hF!=NULL)
                            {
                              for(i=0;i<0x100;i+=4)
                                 {
                                   outpd(PCI_CONFIG_ADDRESS,dwAddr|i);
                                   dwData=inpd(PCI_CONFIG_DATA);
                                   fwrite(&dwData,sizeof(dwData),1,hF);
                                 }
                         fclose(hF);
                        }
                     }
                  }
           }
       }
            
return 0;
}
运行后报:linker error:undefined symbol '__asm' in module pci.c
_asm("lea bx,dwVal");在tc2.0中运行没问题,asm lea bx,dwVal就报错!
求救!!!急急!!
搜索更多相关主题的帖子: PDI define c语言 include DEVICE 
2008-03-25 19:51
jerry4966263
Rank: 1
来 自:浙江杭州
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-3-8
得分:0 
TC也通不过啊,土问这是做啥的程序?
2008-03-25 19:54
wangjiefeng
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-7-28
得分:0 
asm mov dx, portid;
  asm lea bx, dwRet;
好象是这个格式
2008-08-21 10:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-205325-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020914 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved