Reputation: 49
Today I'm solving this problem in assembly lang: "Output the time and date using the GetSystemTime function. Output format:
Date: 22 вересня 2007 року
Time: 17:05:35
Day of the week: Thursday
Pay attention to the time zone and indents in the text"
The problem is that when the data is displayed on the screen, the time is 3 hours behind the current time.
Answer who knows how to display the current time without using "GetLocalTime"? function
.inc File
include WINDOWS.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
.data
Time_title db ' Lab_2',0
FORMAT_STRING \
db ' system time:',0dh,0ah,0dh,0ah
db ' Date: %ld %s %ld ðîêó',0dh,0ah
db ' Time: %ld : %ld : %ld',0dh,0ah
db ' Day of the week: %s',0dh,0ah
db 0
Month_ \
db 'грудня',4 dup(0),\
'січеня',5 dup(0),\
'лютого',4 dup(0),\
'березня', 3 dup(0),\
'квітня',4 dup(0),\
'травня',4 dup(0),\
'червяня',4 dup(0),\
'липня',5 dup(0),\
'серпня',4 dup(0),\
'вересеня',3 dup(0),\
'жовтня',4 dup(0),\
'листопадв',0
Day_of_week \
db 'Неділя',4 dup(0),\
'Понеділок',0,\
'Вівторок',2 dup(0),\
'Середа',4 dup(0),\
'Четвер',3 dup(0),\
"П'ятниця",2 dup(0),\
'Субота',0
.data?
Save_esp dd ?
.asm File
.386
.model flat,STDCALL
option casemap :none ;case sensitive
include Second.inc
include RADbg.inc
.code
Begin:
call main
invoke ExitProcess,NULL
main proc
LOCAL Time:SYSTEMTIME
LOCAL Buf[100]:BYTE
mov Save_esp,esp
invoke GetSystemTime,addr Time;
xor eax,eax ; eax=0
mov ax,Time.wDayOfWeek
mov bx,10
mul bx ;ax*bx
add eax,offset Day_of_week ;eax=address Day_of_week[Time.wDayOfWeek*10]
push eax
xor eax,eax
mov ax,Time.wSecond
push eax
mov ax,Time.wMinute
push eax
mov ax,Time.wHour
push eax
mov ax,Time.wYear
push eax
mov ax,Time.wMonth
mul bx
add eax,offset Month_ ;eax=address Day_of_week[Time.wDayOfWeek*10]
push eax
xor eax,eax
mov ax,Time.wDay
push eax
push offset FORMAT_STRING
lea eax,Buf
push eax
call wsprintf
mov esp, Save_esp
invoke MessageBox,NULL,addr Buf,addr Time_title,MB_OKCANCEL
ret
main endp
end Begin
Upvotes: 1
Views: 234