Annotation of os2sdk/demos/examples/iopl/ioplsub.asm, revision 1.1.1.2

1.1       root        1:        TITLE    CURSOR
                      2: 
                      3: ;      This file exports the function _GetCurLoc which gets the location
                      4: ;      of the cursor on the CRT screen.
                      5: ;
                      6: ;      This routine illustrates the use of the DosPortAccess() call.  This
                      7: ;      call is supposed to give the IOPL segment access to ports and CLI/STI
                      8: ;      instructions. In fact, on the PC/AT (80286) there is no enforcement.
                      9: ;      This call is provided for future compatibility with the 80386.
                     10: ;      At present, the use of DosPortAccess() from an IOPL segment is not
                     11: ;      supported (the calls are commented out here) but will be in the future.
                     12: ;      The form and placement of these calls is indicated here as a guide
                     13: ;      to future usage.
                     14: ;
                     15: ;      One thing to beware of: if you disable interrupts (CLI) they may be
                     16: ;      re-enabled for you by the operating system.  This will occur if you
                     17: ;      generate a fault of some sort.  The easiest example is a segment not
                     18: ;      present fault.  When the segment is loaded and your code starts to
                     19: ;      execute the interrupts will be enabled.  The solution is simple: don't
                     20: ;      load any selectors within the CLI/STI code.
                     21: ;
                     22: ;      Any other fault will cause your process to be booted (i.e. GP fault).
                     23: ;
1.1.1.2 ! root       24: ;      Created by Microsoft Corp. 1986
        !            25: ;
1.1       root       26:        .286p
                     27: 
                     28: _TEXT2 SEGMENT  BYTE PUBLIC 'CODE'
                     29: _TEXT2 ENDS
                     30: _DATA  SEGMENT  WORD PUBLIC 'DATA'
                     31: _DATA  ENDS
                     32: CONST  SEGMENT  WORD PUBLIC 'CONST'
                     33: CONST  ENDS
                     34: _BSS   SEGMENT  WORD PUBLIC 'BSS'
                     35: _BSS   ENDS
                     36: 
                     37: DGROUP GROUP   CONST,  _BSS,   _DATA
                     38: 
                     39: ;       EXTRN   DOSPORTACCESS:FAR
                     40: 
                     41:        ASSUME  CS: _TEXT2, DS: DGROUP, SS: DGROUP, ES: DGROUP
                     42: 
                     43: _TEXT2    SEGMENT
                     44: 
                     45:        PORT1           EQU     3D4h
                     46:        PORT2           EQU     3D5h
                     47:        CURSOR_H        EQU     14      ; cursor location HIGH register
                     48:        CURSOR_L        EQU     15      ; cursor location LOW register
                     49:        ACCESSREQ       EQU     0       ; request access to port(s)
                     50:        ACCESSREL       EQU     1       ; release access to port(s)
                     51: 
                     52: ;**    _GetCurLoc - gets cursor location on the CRT screen
                     53: ;
                     54: ;      ENTRY   NONE
                     55: ;
                     56: ;      EXIT    (AX) = cursor location
                     57: ;
                     58: ;      USES    AX, BX, DX
                     59: 
                     60:        PUBLIC  _GetCurLoc              ; gets cursor location on CRT screen
                     61: 
                     62: _GetCurLoc     PROC    FAR
                     63: 
                     64: ;       push    0               ; RESERVED WORD
                     65: ;       push    ACCESSREQ       ; request access to port(s)
                     66: ;       push    PORT1
                     67: ;       push    PORT2
                     68: ;       call    DOSPORTACCESS   ; request access to ports PORT1, PORT2
                     69: 
                     70:        mov     ax,CURSOR_H     ; address of register we want to read from
                     71:        call    ReadLoc         ; gets cursor location (H) in AL
                     72:        mov     bh,al           ; (BH) = cursor location (H)
                     73: 
                     74:        mov     ax,CURSOR_L     ; address of register we want to read from
                     75:        call    ReadLoc         ; gets cursor location (L) in AL
                     76:        mov     ah,bh           ; (AH) = cursor location (H)
                     77: 
                     78:        push    ax              ; save cursor location
                     79: ;       push    0               ; RESERVED WORD
                     80: ;       push    ACCESSREL       ; release access to port(s)
                     81: ;       push    PORT1
                     82: ;       push    PORT2
                     83: ;       call    DOSPORTACCESS   ; release access to ports PORT1, PORT2
                     84:        pop     ax              ; restore cursor location
                     85: 
                     86:        ret
                     87: _GetCurLoc     ENDP
                     88: 
                     89: ;*     ReadLoc - reads cursor location on the CRT screen
                     90: ;
                     91: ;      ENTRY   (AX) = address of register to read from
                     92: ;
                     93: ;      EXIT    (AL) = cursor location read
                     94: ;
                     95: ;      USES    AX,DX
                     96: 
                     97: ReadLoc        PROC    NEAR
                     98:        cli
                     99:        mov     dx,PORT1        ; set address we want to output to
                    100:        out     dx,al
                    101:        jmp     $+2             ; PC/AT IO delay
                    102:        mov     dx,PORT2        ; set address we want to read from
                    103:        in      al,dx           ; read cursor location
                    104:        sti
                    105:        ret
                    106: ReadLoc        ENDP
                    107: 
                    108: _TEXT2 ENDS
                    109: 
                    110: END

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.