|
|
Microsoft OS/2 SDK 03-01-1988
TITLE CURSOR ; This file exports the function _GetCurLoc which gets the location ; of the cursor on the CRT screen. ; ; This routine illustrates the use of the DosPortAccess() call. This ; call is supposed to give the IOPL segment access to ports and CLI/STI ; instructions. In fact, on the PC/AT (80286) there is no enforcement. ; This call is provided for future compatibility with the 80386. ; At present, the use of DosPortAccess() from an IOPL segment is not ; supported (the calls are commented out here) but will be in the future. ; The form and placement of these calls is indicated here as a guide ; to future usage. ; ; One thing to beware of: if you disable interrupts (CLI) they may be ; re-enabled for you by the operating system. This will occur if you ; generate a fault of some sort. The easiest example is a segment not ; present fault. When the segment is loaded and your code starts to ; execute the interrupts will be enabled. The solution is simple: don't ; load any selectors within the CLI/STI code. ; ; Any other fault will cause your process to be booted (i.e. GP fault). ; ; Created by Microsoft Corp. 1986 ; .286p _TEXT2 SEGMENT BYTE PUBLIC 'CODE' _TEXT2 ENDS _DATA SEGMENT WORD PUBLIC 'DATA' _DATA ENDS CONST SEGMENT WORD PUBLIC 'CONST' CONST ENDS _BSS SEGMENT WORD PUBLIC 'BSS' _BSS ENDS DGROUP GROUP CONST, _BSS, _DATA ; EXTRN DOSPORTACCESS:FAR ASSUME CS: _TEXT2, DS: DGROUP, SS: DGROUP, ES: DGROUP _TEXT2 SEGMENT PORT1 EQU 3D4h PORT2 EQU 3D5h CURSOR_H EQU 14 ; cursor location HIGH register CURSOR_L EQU 15 ; cursor location LOW register ACCESSREQ EQU 0 ; request access to port(s) ACCESSREL EQU 1 ; release access to port(s) ;** _GetCurLoc - gets cursor location on the CRT screen ; ; ENTRY NONE ; ; EXIT (AX) = cursor location ; ; USES AX, BX, DX PUBLIC _GetCurLoc ; gets cursor location on CRT screen _GetCurLoc PROC FAR ; push 0 ; RESERVED WORD ; push ACCESSREQ ; request access to port(s) ; push PORT1 ; push PORT2 ; call DOSPORTACCESS ; request access to ports PORT1, PORT2 mov ax,CURSOR_H ; address of register we want to read from call ReadLoc ; gets cursor location (H) in AL mov bh,al ; (BH) = cursor location (H) mov ax,CURSOR_L ; address of register we want to read from call ReadLoc ; gets cursor location (L) in AL mov ah,bh ; (AH) = cursor location (H) push ax ; save cursor location ; push 0 ; RESERVED WORD ; push ACCESSREL ; release access to port(s) ; push PORT1 ; push PORT2 ; call DOSPORTACCESS ; release access to ports PORT1, PORT2 pop ax ; restore cursor location ret _GetCurLoc ENDP ;* ReadLoc - reads cursor location on the CRT screen ; ; ENTRY (AX) = address of register to read from ; ; EXIT (AL) = cursor location read ; ; USES AX,DX ReadLoc PROC NEAR cli mov dx,PORT1 ; set address we want to output to out dx,al jmp $+2 ; PC/AT IO delay mov dx,PORT2 ; set address we want to read from in al,dx ; read cursor location sti ret ReadLoc ENDP _TEXT2 ENDS END
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.