[net.micro.pc] Cursor Positioning from Lattice C

jim@rand-unix@sri-unix.UUCP (09/02/83)

Here's a more explicit answer to the question of how to position the
cursor on a PC (assuming you don't have DOS 2.00, which has been covered
already).  You need to assemble a routine like this, then link it with
your program.  I use Lattice C; if you don't, check your manual for
the subroutine linkage conventions.

; curpos: move the cursor to specified location (depends on mode)
; J. J. Gillogly
;
PGROUP	GROUP	PROG
PROG	SEGMENT	BYTE PUBLIC 'PROG'
	PUBLIC	CURPOS
	ASSUME	CS:PGROUP
;
; name		curpos -- set cursor location
;
; synopsis	curpos(x, y)
;		int x,y;	x and y coordinates of destination
;
; description	use video interrupt to go to (x,y) on screen
;
CURPOS	PROC	NEAR
	PUSH	BP	; LATTICE return conventions
;
	MOV	AH,2		; BIOS FUNCTION: SET CURSOR POSITION
	MOV	BH,0		; DISPLAY PAGE, 0 FOR GRAPHICS MODE
	MOV	BP,SP		; LOOK FOR ARGS
	MOV	DL,[BP+4]	; FIRST ARG INTO DL, NEW ROW (Y)
	MOV	DH,[BP+6]	; 2ND ARG INTO DH, NEW COLUMN (X)
	INT	INT 10H		; EXECUTE THE VIDEO INTERRUPT
;
	POP	BP		; RESTORE LATTICE INFO
	RET
CURPOS	ENDP
;
PROG	ENDS
	END

[CURPOS.ASM has been added to the Info-IBMPC library. -Ed.]