怎么样把这段汇编嵌入程序中呢?

ppssdd 2004-11-26 02:24:14
有一段汇编代码,执行的是取得CPU的温度,如下:
PMU_SC equ 6Ch
PMU_DATA equ 68h
RD_EC_SMI equ 80h
POLLING_DATA equ 0E7h


;AL-----CPU Temperature
GetCPUTempe proc
pusha
pushf
cli
mov dx,PMU_SC
mov al,RD_EC_SMI
call pmuWait4IBE ;Must have
out dx,al

mov dx,PMU_DATA
mov al,POLLING_DATA
call pmuWait4IBE ;Must have
out dx,al

mov dx,PMU_DATA
call pmuWait4OBF ;Must have
in al,dx ;Get Temperature
sti
popf
popa
GetCPUTempe endp

;#########################################################
pmuWait4IBE proc
PUSH AX
PW4IBE:
IN AL, 06CH ; Read PMU status
TEST AL, 2 ; Is Input Buffer Empty?
JNZ PW4IBE ; Jmp if no
POP AX
ret
pmuWait4IBE endp;END OF PMUWAIT4IBE
;#########################################################
pmuWait4OBF proc
PUSH AX
PW4OBF:
IN AL, 06CH ; Read PMU status
TEST AL, 1 ; Is Output Buffer Full?
JZ PW4OBF ; Jmp if no
POP AX
ret
pmuWait4OBF endp;END OF PMUWAIT4OBF
;#########################################################

有winio例程一段,如下,问怎么样把上面的汇编嵌入下面的程序中,以达到在程序中取得CPU温度的结果:
#include <windows.h>
#include <stdio.h>
#include "winio.h"

void main()
{
DWORD dwPortVal;
DWORD dwMemVal;
bool bResult;
HANDLE hPhysicalMemory;
PBYTE pbLinAddr;

// Call InitializeWinIo to initialize the WinIo library.

bResult = InitializeWinIo();

if (bResult)
{
// Under Windows NT/2000/XP, after calling InitializeWinIo,
// you can call _inp/_outp instead of using GetPortVal/SetPortVal

GetPortVal(0x378, &dwPortVal, 4);

SetPortVal(0x378, 10, 4);

// Map physical addresses 0xA0000 - 0xAFFFF into the linear address space
// of the application. The value returned from the call to MapPhysToLin is
// a linear address corresponding to physical address 0xA0000. In case of
// an error, the return value is NULL.

pbLinAddr = MapPhysToLin((PBYTE)0xA0000, 65536, &hPhysicalMemory);

if (pbLinAddr)
{
// Now we can use pbLinAddr to access physical address 0xA0000

*pbLinAddr = 10;

// When you're done with pbLinAddr, call UnmapPhysicalMemory

UnmapPhysicalMemory(hPhysicalMemory, pbLinAddr);
}

// Instead of using MapPhysToLin, we can use GetPhysLong/SetPhysLong

GetPhysLong((PBYTE)0xA0000, &dwMemVal);

SetPhysLong((PBYTE)0xA0000, 10);

// When you're done using WinIo, call ShutdownWinIo

ShutdownWinIo();
}
else
{
printf("Error during initialization of WinIo.\n");
exit(1);
}
}
...全文
46 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
kugou123 2004-11-26
去我的站点下载吧。

http://www.mzkp.com/cooldog/download/vcasm.zip

内嵌汇编资料
回复
luxin24 2004-11-26
__asm
{
//这里加入你的汇编代码
}
回复
luolovegui 2004-11-26
__asm // __asm block
{
//.... that is you asm code.
}
回复
相关推荐
发帖
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
帖子事件
创建了帖子
2004-11-26 02:24
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……