Functions 0007h and 0008h set the limits of the pointer: 0007h the horizontal range, 0008h the vertical one, each from CX to DX inclusive. The pointer cannot leave the rectangle, however far the mouse moves, and if it is outside when the call is made the driver moves it to the nearest edge. Most drivers swap CX and DX if the minimum is the larger.

Two uses. The first is confining the pointer to part of the screen: a dialog box, a playfield, a scroll bar while it is being dragged. The second is telling the driver the real size of the screen. The reset sets the range for the modes the driver knows; for others (VESA modes, tweaked "mode X" screens, or a game that wants x in 0..319 in mode 13h) the program sets it itself.

prints: 80 40 152 72
XOR AX, AX ; reset: the whole screen
INT 33h
MOV AX, 0007h ; horizontal range: columns 10..19
MOV CX, 80
MOV DX, 159
INT 33h
MOV AX, 0008h ; vertical range: rows 5..9
MOV CX, 40
MOV DX, 79
INT 33h
MOV AX, 0004h ; try the top left corner of the screen
XOR CX, CX
XOR DX, DX
INT 33h
CALL SHOWP1 ; 80 40: held at the corner of the range
MOV AX, 0004h ; and the bottom right
MOV CX, 639
MOV DX, 199
INT 33h
CALL SHOWP1 ; 152 72: column 19, row 9
XOR AX, AX ; reset: the whole screen again
INT 33h
SHOWP1 PROC NEAR ; print the mouse position: x y
MOV AX, 0003h
INT 33h ; CX = x, DX = y
MOV BX, DX ; keep y: printing uses DL
MOV AX, CX
CALL PDEC
MOV DL, " "
MOV AH, 02h
INT 21h
MOV AX, BX
CALL PDEC
MOV DL, " "
MOV AH, 02h
INT 21h
RET
SHOWP1 ENDP
PDEC PROC NEAR ; print AX in decimal; keeps every register
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV BX, 10
XOR CX, CX ; digits on the stack
DECD1:
XOR DX, DX
DIV BX ; AX = AX / 10, DX = the last digit
PUSH DX
INC CX
TEST AX, AX
JNZ DECD1
DECD2:
POP DX ; the digits come back first to last
ADD DL, "0"
MOV AH, 02h
INT 21h
LOOP DECD2
POP DX
POP CX
POP BX
POP AX
RET
PDEC ENDP

Pitfalls

The limits are pixels of the virtual screen, not character cells: in text mode the window from column 10 to column 19 is x = 80 to 159, the last cell included through its last pixel. A reset or a video mode change (with a reset after it) restores the full range, so set the range after both. A program that confines the pointer should undo that before it exits, with a reset, since the driver stays resident and the next program inherits the setting. DOSBox-X also uses the first range a program sets after a mode change to learn the size of the screen, so that the host pointer maps onto it correctly.