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

  1.  
  2. ;************************************************************************
  3. ; Determine if a second video adapter is present                        *
  4. ; and return result in AX                                               *
  5. ; Exixt:  AX = 0 if there is no second adapter                          *
  6. ;            = 1 if there is a second adapter                           *
  7. ;************************************************************************
  8.  
  9.         PUBLIC  _Get_Second_Adapter
  10.  
  11. _Get_Second_Adapter PROC NEAR
  12.         PUSH    ES                      ;Preserve ES
  13.         XOR     AX,AX                   ;Move segment zero into ES
  14.         MOV     ES,AX
  15.         MOV     DX,03D4H                ;Assume mono attached
  16.         TEST    BYTE PTR ES:[BIOS_Equipment],2   ;Is mono attached?
  17.         JNZ     Find_Second             ;...Yes, go look for CGA
  18.         MOV     DX,03B4H                ;...No, look for MDA
  19.  
  20. Find_Second:
  21.         MOV     AL,0FH                  ;Select cursor low
  22.         OUT     DX,AL
  23.         MOV     AL,55H                  ;Write first pattern
  24.         INC     DX
  25.         OUT     DX,AL
  26.         IN      AL,DX                   ;Read pattern back
  27.         JMP     $+2
  28.         CMP     AL,55H                  ;Is pattern same?
  29.         JNE     No_Second               ;...No, adapter not there
  30.  
  31.         MOV     AL,0AAH                 ;Write second pattern
  32.         OUT     DX,AL
  33.         IN      AL,DX                   ;Read pattern back
  34.         JMP     $+2
  35.         CMP     AL,0AAH                 ;Is pattern same?
  36.         JNE     No_Second               ;...No, adapter not there
  37.  
  38.         MOV     AX,1                    ;...Yes, return count 1
  39.         POP     ES                      ;Restore ES
  40.         RET
  41.  
  42. No_Second:
  43.         XOR     AX,AX                   ;Return count 0
  44.         POP     ES
  45.         RET
  46. _Get_Second_Adapter ENDP
  47.