home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / MISC_ASM.ZIP / C_ANSI.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-01-05  |  2.5 KB  |  68 lines

  1. COMMENT +                     
  2.     The object of this program is to parse the reply, if any, to a DSR.
  3. Check for 'cursor position report'(CSR), the ansi system response to the 
  4. 'device status report' (DSR).  The CPR format is '[##;##;R' so check                                                  
  5. for the important parts of the string, the ESC and the R, but ignore the 
  6. line and column numbers returned along with the CPR.  Results are returned
  7. in AX: 0 if Ansi present, 1 if not.
  8.  
  9. +            MASM 5.1 SOURCE
  10.  
  11.  DOSSEG                        ; New MASM default declarations
  12. .MODEL LARGE, C                 ; produce necessary segs
  13. .DATA                        ; data segment
  14.  
  15. QUERY     DB      1BH,"[6n$"            ; Device Status Report (DSR)
  16. str1      db      10 dup(00)            ; buffer for ansi string                     
  17. UNQUERY   DB      4 DUP(8," ",8),"$"        ; to clear string from display
  18.  
  19. EXTRN  main: far                ; calling program
  20. PUBLIC check_for_ansi                ; declare this routine public
  21.  
  22. .CODE                        ; code segment directive
  23. ;
  24. ;    OUTPUTS:                    ; returned in AX
  25. ;      AX = 0 (ANSI Driver Found)        
  26. ;      AX = 1 (ANSI Driver Not Found)
  27. ;
  28.  
  29. check_for_ansi proc far            ; far procedure
  30.  
  31.     push    DX                                ; Save Registers
  32.         mov     DX, offset @data: QUERY           ; Output DSR to ANSI Driver
  33.         mov     AH,9                ; DOS Print screen function
  34.         int     21H                ; call DOS
  35.  
  36.         mov     AH,6                              ; DOS Direct display I/O function
  37.         mov     DL,0FFH                ; tell AL to accept input
  38.         int     21H                ; call DOS
  39.         jz      ANSI_CK2                    ; If ZF = 1, AL = 0, & no ANSI
  40.       cmp     al,1BH                ; Does AL = Escape ?
  41.         jnz     ANSI_CK2            ; No, goto ansi_ck2
  42.     mov cx,8                 ; yes, now get 8 bytes    
  43. L1:
  44.     mov    AH,6                ; put next byte into AL     
  45.         mov     DL,0FFH             ; set up DOS service
  46.         int     21H                ; call DOS
  47.     cmp     al,"R"                ; Ansi returns an R if loaded
  48.     jz     ansi_ck1            ; If R found, show ansi loaded
  49.     loop    L1                ; not yet, get another byte
  50.     jmp     short ansi_ck2            ; no R found, exit no ansi
  51. ansi_ck1:                    ; ansi found label
  52.     xor     ax,ax                ; code 0 if ansi found
  53.     jmp     short ansi_ck3               ; exit
  54.     
  55. ANSI_CK2:                     ; fix screen if no match
  56.     mov     dx,offset unquery               ; Clear Query Code from Screen
  57.         mov     ah,9                ; print screen
  58.         int     21H                ; call DOS
  59.         mov     ax,1                            ; Return Code = 1
  60. ANSI_CK3: 
  61.     pop     dx                              ; Restore Registers
  62.         ret                                     ; Done
  63.  
  64.  
  65. check_for_ansi endp
  66.  
  67. END     
  68.