相关疑难解决方法(0)

以毫秒为单位捕获时间

以下代码用于在日志中打印时间:

#define PRINTTIME() struct tm  * tmptime;
time_t     tmpGetTime;
time(&tmpGetTime);
tmptime = localtime(&tmpGetTime);
cout << tmptime->tm_mday << "/" <<tmptime->tm_mon+1 << "/" << 1900+tmptime->tm_year << " " << tmptime->tm_hour << ":" << tmptime->tm_min << ":" << tmptime->tm_sec<<">>";
Run Code Online (Sandbox Code Playgroud)

有没有办法为此添加毫秒?

c++ stl resolution timer

12
推荐指数
2
解决办法
5万
查看次数

如何在不使用从 C 导出的函数的情况下在 Linux 中使用 NASM 程序集获取系统时间?

我正在为我的大学做一个项目。任务是打印当前日期和时间。我成功地创建了一个打印数字的子程序,我现在需要的只是获取日期。我试过这种方法:

%define RTCaddress  0x70
%define RTCdata     0x71

;Get time and date from RTC
.l1:    mov al,10           ;Get RTC register A
        out RTCaddress,al
        in al,RTCdata
        test al,0x80            ;Is update in progress?
        jne .l1             ; yes, wait

        mov al,0            ;Get seconds (00 to 59)
        out RTCaddress,al
        in al,RTCdata
        mov [RTCtimeSecond],al
Run Code Online (Sandbox Code Playgroud)

但只是打电话:

.l1:    mov al,10           ;Get RTC register A
        out RTCaddress,al
Run Code Online (Sandbox Code Playgroud)

足以导致崩溃。您知道如何解决这种方法吗,或者我可以使用任何不同的方法。我正在 Linux 64 位上使用 Nasm。

linux x86 assembly x86-64 nasm

2
推荐指数
1
解决办法
4038
查看次数

标签 统计

assembly ×1

c++ ×1

linux ×1

nasm ×1

resolution ×1

stl ×1

timer ×1

x86 ×1

x86-64 ×1