Int 21H [2.0] Function 30H (48) Get MS-DOS version number

Returns the version number of the host MS-DOS operating system. This function is used by application programs to determine the capabilities of their environment.

Call with:

AH = 30H

AL = 00H

Returns:

If running under MS-DOS version 1

AL = 00H

If running under MS-DOS versions 2.0 or later

AL = major version number (MS-DOS 3.10 = 3, etc.)

AH = minor version number (MS-DOS 3.10 = 0AH, etc.)

BH = Original Equipment Manufacturer's (OEM's) serial number

(OEM-dependent——usually 00H for IBM's PC-DOS, 0FFH or

other values for MS-DOS)

BL:CX = 24-bit user serial number (optional, OEM-dependent)

Notes:

Because this function was not defined under MS-DOS version 1, it should always be called with AL = 00H. In an MS-DOS version 1 environment, AL will be returned unchanged.

Care must be taken not to exit in an unacceptable fashion if an MS-DOS version 1 environment is detected. For example, Int 21H Function 4CH (Terminate Process with Return Code), Int 21H Function 40H (Write to File or Device), and the standard error handle are not available in MS-DOS version 1. In such cases a program should display an error message using Int 21H Function 09H and then terminate with Int 20H or Int 21H Function 00H.

Example:

Get the MS-DOS version number, terminating the current process with an error message if not running under MS-DOS version 2.0 or later.

cr equ 0dh ; ASCII carriage return

lf equ 0ah ; ASCII line feed

msg db cr,lf

db 'Wrong MS-DOS version'

db cr,lf,'$'

.

.

.

mov ax,3000h ; function number

int 21h ; transfer to MS-DOS

cmp al,2 ; version 2 or later?

jae label1 ; yes, jump

; display error message

mov ah,09 ; function number

mov dx,offset msg ; message address

int 21h ; transfer to MS-DOS

; terminate process

mov ah,0 ; function number

int 21h ; transfer to MS-DOS

label1: .

.

.