Hi *.*:
DayOfWeek PROC pdt:PTR DATETIME
; Return in eax
; Sunday = 0, Monday = 1, ... Saturday = 6
LOCAL _st:SYSTEMTIME
INVOKE FileTimeToSystemTime, pdt, ADDR _st
.IF eax == 0
xor eax, eax
.ELSE
movzx eax, _st.wDayOfWeek
.ENDIF
ret
DayOfWeek ENDP
I am pretty sure that
.IF eax == 0
mov eax, -1; dec eax Will work if eax always zero
Regards: herge
Hi Herge,
It should return -1 and not 0 on error. The help file says it returns -1 on error. Thanks for noticing that.
DayOfWeek PROC pdt:PTR DATETIME
; Return in eax
; Sunday = 0, Monday = 1, ... Saturday = 6
LOCAL _st:SYSTEMTIME
INVOKE FileTimeToSystemTime, pdt, ADDR _st
.IF eax == 0
mov eax, -1
.ELSE
movzx eax, _st.wDayOfWeek
.ENDIF
ret
DayOfWeek ENDP
I changed my copy of the code. Now we just need to get the MASM32 copy of the code changed.
Hi Greg:
Thanks!
Regards: herge
Herge,
For now you can just make the correction in the DayOfWeek.asm file and then run \masm32\DateTime\make.bat to rebuild the DateTime.lib file and copy it to the masm32\lib directory.
In the same vein, a routine might want to return 0 if one of its subroutines returns -1. E.g.
; C source:
; ...
; hFile = CreateFile(fname, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
; if (hFile == NULL || hFile == (HANDLE)-1) {
; return 0;
; ...
invoke CreateFileA,address fname, GENERIC_WRITE,0,0,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
inc eax
jz abort_with_eax
dec eax
jz abort_with_eax
mov hFile,eax
;...