以下代码用于在日志中打印时间:
#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)
有没有办法为此添加毫秒?
我正在为我的大学做一个项目。任务是打印当前日期和时间。我成功地创建了一个打印数字的子程序,我现在需要的只是获取日期。我试过这种方法:
%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。