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.
XOR AX, AX ; reset: the whole screenINT 33hMOV AX, 0007h ; horizontal range: columns 10..19MOV CX, 80MOV DX, 159INT 33hMOV AX, 0008h ; vertical range: rows 5..9MOV CX, 40MOV DX, 79INT 33hMOV AX, 0004h ; try the top left corner of the screenXOR CX, CXXOR DX, DXINT 33hCALL SHOWP1 ; 80 40: held at the corner of the rangeMOV AX, 0004h ; and the bottom rightMOV CX, 639MOV DX, 199INT 33hCALL SHOWP1 ; 152 72: column 19, row 9XOR AX, AX ; reset: the whole screen againINT 33hSHOWP1 PROC NEAR ; print the mouse position: x yMOV AX, 0003hINT 33h ; CX = x, DX = yMOV BX, DX ; keep y: printing uses DLMOV AX, CXCALL PDECMOV DL, " "MOV AH, 02hINT 21hMOV AX, BXCALL PDECMOV DL, " "MOV AH, 02hINT 21hRETSHOWP1 ENDPPDEC PROC NEAR ; print AX in decimal; keeps every registerPUSH AXPUSH BXPUSH CXPUSH DXMOV BX, 10XOR CX, CX ; digits on the stackDECD1:XOR DX, DXDIV BX ; AX = AX / 10, DX = the last digitPUSH DXINC CXTEST AX, AXJNZ DECD1DECD2:POP DX ; the digits come back first to lastADD DL, "0"MOV AH, 02hINT 21hLOOP DECD2POP DXPOP CXPOP BXPOP AXRETPDEC 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.