INT 21h AH=30h returns the DOS version: the major number in AL, the minor in AH. The minor part is the two decimal digits after the point, stored as a binary number, so MS-DOS 6.22 returns AL = 6 and AH = 22 (16h), and DOS 3.3 returns AL = 3 and AH = 30 (1Eh). DOS 1 did not have the function and leaves AL = 0, which is an answer too.

prints: DOS 5.00 (DOSBox-X's default; VER SET in the box changes it)
MOV AX, 3000h ; DOS: get the version; AL = 0: OEM number in BH
INT 21h ; AL = major, AH = minor
PUSH AX
MOV DX, OFFSET MSG1
MOV AH, 09h ; DOS: print the string at DS:DX
INT 21h
POP AX
PUSH AX
XOR AH, AH ; AX = the major number
CALL PDEC1
MOV DL, "."
MOV AH, 02h ; DOS: print the character in DL
INT 21h
POP AX
MOV AL, AH ; the minor number: always two digits
CALL P2D1
MSG1 DB "DOS $"
PDEC1 PROC NEAR ; print AX in decimal
MOV BX, 10
XOR CX, CX ; digits so far
PD1:
XOR DX, DX
DIV BX ; AX = AX / 10, DX = the last digit
PUSH DX
INC CX
TEST AX, AX
JNZ PD1
PD2:
POP DX ; the digits come back first to last
ADD DL, "0"
MOV AH, 02h
INT 21h
LOOP PD2
RET
PDEC1 ENDP
P2D1 PROC NEAR ; print AL (0-99) as two digits
AAM ; AH = AL / 10, AL = AL mod 10
ADD AX, 3030h ; both digits to characters
PUSH AX
MOV DL, AH ; the tens
MOV AH, 02h
INT 21h
POP DX ; DL = the units
MOV AH, 02h
INT 21h
RET
P2D1 ENDP

Programs check the version before using functions a version introduced: handles and directories need 2.0, the extended error code 3.0, many network and code page functions 3.3. A check compares the major numbers first and the minor ones only when the majors are equal; swapping the halves lets one word comparison do both:

MOV AH, 30h ; DOS: get the version
INT 21h
XCHG AL, AH ; AH = major, AL = minor
CMP AX, 0314h ; at least 3.20? (20 = 14h)
JB TOOOLD1

Without the XCHG, AX holds minor:major, and 5.00 (AX = 0005h) would look older than 3.30 (AX = 1E03h).

What it does not tell

The number can be a polite fiction. SETVER makes DOS report a chosen version to a chosen program, Windows 95 reports 7, and the DOS box of Windows NT reports 5.0. DOS 5 and later have function 33h with AL = 06h (MOV AX, 3306h), which returns the true version in BL and BH and which SETVER does not change. BH tells the maker: FFh for Microsoft, 00h for IBM PC DOS.

DOSBox-X reports 5.0 unless told otherwise, by the ver setting in its configuration or by the VER SET command (VER SET 6 22), and returns BH = FFh with a serial number of 0. Its built-in DOS has the functions of a later DOS regardless of the number it reports.