home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-ASM_VI.ARJ / PROGASM.ZIP / PROG043.ASM < prev    next >
Assembly Source File  |  1988-04-10  |  2KB  |  47 lines

  1.  
  2. ;************************************************************************
  3. ; Get current cursor position by reading CRTC registers                 *
  4. ; Entry: Row   - Pointer to where to save current cursor row            *
  5. ;        Column- Pointer to where to save current cursor column         *
  6. ; Exit:  Values at the pointers are set to proper values                *
  7. ;************************************************************************
  8.  
  9. Row     EQU     [BP+4]
  10. Column  EQU     [BP+6]
  11.  
  12.         PUBLIC  _Get_Cursor_Position
  13.  
  14. _Get_Cursor_Position PROC NEAR
  15.         PUSH    BP
  16.         MOV     BP,SP
  17.         PUSH    ES
  18.         XOR     AX,AX                   ;Point ES to segment 0
  19.         MOV     ES,AX
  20.         MOV     DX,ES:[BIOS_CRT_Addr]   ;Load CRTC address
  21.         MOV     AL,0EH                  ;Fetch index of cursor high
  22.         OUT     DX,AL                   ;Select index
  23.         INC     DX                      ;Load CRTC address
  24.         IN      AL,DX                   ;Read the high address
  25.         JMP     $+2
  26.         MOV     BH,AL                   ;Save value in BH
  27.  
  28.         DEC     DX                      ;Load CRTC address
  29.         MOV     AL,0FH                  ;Fetch index of cursor low
  30.         OUT     DX,AL                   ;Select index
  31.         INC     DX                      ;Load CRTC address
  32.         IN      AL,DX                   ;Read the low part of address
  33.         JMP     $+2
  34.  
  35.         MOV     AH,BH                   ;Fetch the high byte from earlier
  36.         XOR     DX,DX                   ;convert to row and column
  37.         MOV     BX,ES:[BIOS_Columns]    ;by dividing absolute address
  38.         DIV     BX                      ;with columns
  39.         MOV     BX,Row                  ;Fetch pointer where to save row
  40.         MOV     [BX],AX                 ;Save row number
  41.         MOV     BX,Column               ;Fetch pointer where to save column
  42.         MOV     [BX],DX                 ;Save column number
  43.         POP     ES
  44.         POP     BP
  45.         RET
  46. _Get_Cursor_Position ENDP
  47.