How to find current date in Intel x86 Assembly?

I need to find the current date in binary format for building Intel x86 on Windows. I am allowed to use Windows procedures.

+4
source share
4 answers

I'm not sure if it is technically β€œWindows” (and, indeed, only works in a Windows emulation environment such as NTVDM, as confirmed by Greg Hugill), but you can use INT $ 21, with $ 2A in AH , since this function DOS will return the date. See the link for more information.

+4
source

If you are allowed to use Win32 functions, the answer to this question will be the same as the answer to the question "How to find the current date in C on Windows?" To do this, look at the GetSystemTime and SystemTimeToFileTime functions (hey, there’s even the GetSystemTimeAsFileTime function now (since Windows 2000)).

+6
source

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

To find out the exact assembly code, write a call in C, compile with / FA (suppose the Microsoft compiler), and kill the calling sequence from the listing file. It may help if you are not sure about the calling convention or how to refer to the name of an external function in the assembly.

+2
source

int 20h and int 21h are used to call DOS routines. They can be called either in virtual mode supported by 32-bit Windows, or in real mode, i.e. when you run DOS as your actual OS and never enter protected (32-bit) mode. Please note that 64-bit processors have lost support for virtual mode, so you cannot use this with a 64-bit chip at all.

For a list of them , Ralf Brown's Interrupt List , which is a truly comprehensive guide to this legacy interface.

On Linux and possibly other * nixes there is a syscall interface on int 80h . However, all of them can also be called using C calling conventions, which are better documented. Check the Linux source tree for matching the names number β†’ and run the man syscall_name to document the equivalent function page of function C. I believe that the arguments are ordered the same way for both conventions. (I checked this for several system calls.)

The int 80h calling convention (for * nix) is described here: int80h.org

+1
source

All Articles