views:

113

answers:

3

I need to find the find the current date in binary for Intel x86 Assembly on Windows. I'm allowed to use Windows procedures.

+2  A: 

Not sure if this is technically "Windows" (and indeed only works in Windows' emulated DOS environment aka NTVDM, as confirmed by Greg Hewgill), but you could use INT $21, with $2A in AH, as this DOS function will return the date. See this link for more info

mjv
Unfortunately, that will not work in a Win32 environment, only in the emulated DOS environment (NTVDM).
Greg Hewgill
@Greg H, good point! +1 for your answer. I was "lazy" and didn't want to explain the details about binding to Win32, calling conventions etc.
mjv
Actually, this will work in windows, as long as it's not Windows 7. For that, you'd want to download and install DOSBox (http://www.dosbox.com/).
wallyk
Emulations don't matter, otherwise I suggest UAE :-)
Marco van de Voort
+4  A: 

If you're allowed to use Win32 functions, then the answer to this would be the same as the answer to "How can I find the current date in C on Windows?" For this, look up the GetSystemTime and SystemTimeToFileTime functions (hey neat, there's even a GetSystemTimeAsFileTime function now! (since Windows 2000)).

Greg Hewgill
+2  A: 

GetSystemTime() returns GMT (also known as UTC); for the time that the user sees use GetLocalTime().

To know the exact assembly code, write a call in C, compile with /FA (assuming Microsoft compiler) and snag the calling sequence from the listing file. Might help if you're unsure of the calling convention or how to refer to an external function name in assembly.

Seva Alekseyev