BUG: DOSGetCurDate Incorrect in DISKMENU PWB ExtensionLast reviewed: July 17, 1997Article ID: Q100743 |
2.00 2.01.49
MS-DOS
kbtool kbcode kbbuglist
The information in this article applies to:
SYMPTOMSAn attempt to use the DOSGetCurDate function in the DISKMENU.C sample Programmer's WorkBench (PWB) extension provided with Microsoft C/C++ version 7.0 fails to return the date correctly.
CAUSEThe DOSGetCurDate function is designed to return the date in a packed MS- DOS format. This format is used by Interrupt 21h Function 57h that the DOSSetFileTime function calls. Therefore, the format of the unsigned integer result value should be as follows:
bits 00h-04h = day (1-31) bits 05h-08h = month (1-12) bits 09h-0Fh = year (relative to 1980)However, because the extension code shifts the DH register left by five bits the most significant bit of the month number is lost and only the first seven months are represented.
RESOLUTIONReplace the DOSGetCurDate function in the DISKMENU extension with the following code:
// DOSGetCurDate - Get current DOS date // // Returns the current DOS date in packed format // unsigned __pascal DOSGetCurDate(void) { unsigned rv; _asm { mov ah, 2ah // Get the date int 21h sub cx, 1980 // CX contains the year. Make relative // to 1980 for DOSSetFileTime function #ifdef _M_I8086 shl cx, 1 // shift to add month from DH shl cx, 1 shl cx, 1 shl cx, 1 #else shl cx, 4 #endif or cl, dh // insert month from DH #ifdef _M_I8086 shl cx, 1 // shift to add day shl cx, 1 shl cx, 1 shl cx, 1 shl cx, 1 #else shl cx, 5 #endif or cl, dl // insert day from DL mov rv, cx } return rv; } MORE INFORMATIONThe incorrect code is as follows:
Sample code
unsigned __pascal DOSGetCurDate( void ) { unsigned rv; _asm { mov ah, 2ah int 21h sub cx, 1980 #ifdef _M_I8086 shl cx, 1 shl cx, 1 shl cx, 1 shl cx, 1 shl cx, 1 shl cx, 1 shl cx, 1 shl cx, 1 shl cx, 1 #else shl cx, 9 #endif or cl, dl #ifdef _M_I8086 shl dh, 1 shl dh, 1 shl dh, 1 shl dh, 1 shl dh, 1 #else shl dh, 5 #endif or cl, dh mov rv, cx } return rv; } |
Additional reference words: 2.00 2.01.49 buglist2.00 buglist2.01.49
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |