【发布时间】:2019-10-30 05:09:44
【问题描述】:
我不是 C/ASM 开发人员,我想通过 Windows 程序从 RTC 获取当前日期和时间。
Here,我找到了一个 C 代码来做这个。
我通过以下方式更改了该代码,并使用 Visual Studio 2017 cl.exe 编译器对其进行了编译,没有出现错误和警告:
#include <stdio.h>
int main()
{
unsigned char tvalue, index;
printf("STARTING...\n");
for(index = 0; index < 128; index++)
{
__asm
{
cli /* Disable interrupts */
mov al, index /* Move index address */
/* since the 0x80 bit of al is not set, */
/* NMI is active */
out 0x70, al /* Copy address to CMOS register */
/* some kind of real delay here is probably best */
in al, 0x71 /* Fetch 1 byte to al */
sti /* Enable interrupts */
mov tvalue, al
}
printf("%u\n", (unsigned int)tvalue);
}
printf("FINISHED!\n");
return 0;
}
当我尝试从命令提示符执行 exe 时,我什么也没看到,只有“STARTING...”行。
我做错了什么?
非常感谢。
【问题讨论】:
标签: c windows assembly real-time-clock