home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
C-ASM_VI.ARJ
/
PROGASM.ZIP
/
PROG043P.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-04-17
|
2KB
|
53 lines
;************************************************************************
; Get current cursor position by reading CRTC registers *
; Entry: Row - Pointer to where to save current cursor row *
; Column- Pointer to where to save current cursor column *
; Exit: Values at the pointers are set to proper values *
;************************************************************************
row_seg EQU [BP+12]
row_offset EQU [BP+10]
column_seg EQU [BP+8]
column_offset EQU [BP+6]
PUBLIC Get_Cursor_Position
Get_Cursor_Position PROC FAR
PUSH BP
MOV BP,SP
PUSH DS
PUSH ES
XOR AX,AX ;Point ES to segment 0
MOV ES,AX
MOV DX,ES:[BIOS_CRT_Addr] ;Load CRTC address
MOV AL,0EH ;Fetch index of cursor high
OUT DX,AL ;Select index
INC DX ;Load CRTC address
IN AL,DX ;Read the high address
JMP $+2
MOV BH,AL ;Save value in BH
DEC DX ;Load CRTC address
MOV AL,0FH ;Fetch index of cursor low
OUT DX,AL ;Select index
INC DX ;Load CRTC address
IN AL,DX ;Read the low part of address
JMP $+2
MOV AH,BH ;Fetch the high byte from earlier
XOR DX,DX ;convert to row and column
MOV BX,ES:[BIOS_Columns] ;by dividing absolute address
DIV BX ;with columns
MOV DS,row_seg
MOV BX,row_offset ;Fetch pointer where to save row
MOV [BX],AX ;Save row number
MOV DS,column_seg
MOV BX,column_offset ;Fetch pointer where to save column
MOV [BX],DX ;Save column number
POP DS
POP ES
POP BP
RET 8
Get_Cursor_Position ENDP