/* LASTDRV2.C -- uses only documented DOS */

#include <stdlib.h>
#include <stdio.h>

main()
{
    unsigned lastdrv;

#ifdef __TURBOC__
    asm mov ah, 19h         /* C-style comments only */
    asm int 21h
    asm mov dl, al
    asm mov ah, 0x0e        /* C-style hex */
    asm int 21h             /* assembly-style hex */
    asm xor ah, ah
    asm mov lastdrv, ax     /* refer to C variables */
#elif (defined(_MSC_VER) && (_MSC_VER >= 600)) || defined(_QC)
    _asm {
        mov ah, 19h         ; can include assembly-style comments
        int 21h             /* and C-style as well */
        mov dl, al          // and this style as well
        mov ah, 0x0E        ; can include C-style hex numbers
        int 21h             ; or assembly-style hex numbers
        xor ah, ah
        mov lastdrv, ax     ; can refer to C variables in _asm
        }
#else
#error Requires inline assembler
#endif

    fputs("LASTDRIVE=", stdout);
    putchar('A' - 1 + lastdrv);
    putchar('\n');
    return lastdrv;
}
