home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / sampler1 / clear.asm < prev    next >
Assembly Source File  |  1985-08-28  |  5KB  |  114 lines

  1.          name      clear
  2.          page      55,132
  3.          title     'CLEAR --- control PC display'
  4. ;
  5. ; CLEAR Utility to clear display
  6. ; and set character attributes
  7. ;
  8. ; Ray Duncan,  Uncopyright (u) August 1983
  9. ; This program may be freely copied,
  10. ; mangled, enhanced, redistributed.
  11. ;
  12. input    equ       080h      ;command line tail buffer
  13. cr       equ       0dh       ;ASCII carriage return
  14. ;
  15. cseg     segment   byte
  16.          assume    cs:cseg,ds:cseg
  17. ;
  18.          org       0100h     ;since this will be
  19.                              ; a COM file
  20. ;
  21. clear:                       ;initialize display...
  22.                              ;call BIOS video driver to
  23.          mov       ah,15     ;get current display mode:
  24.          int       10h       ;returns AL = mode, and
  25.                              ;AH = no. of columns.
  26.          cmp       al,7      ;if we are in graphics modes
  27.          je        clear0    ;(modes 4,5,6) then exit
  28.          cmp       al,3      ;but if we are in mode 0-3
  29.          ja        clear9    ;or 7 then continue.
  30. clear0:                      ;set up size of window to
  31.                              ;be initialized...
  32.          xor       cx,cx     ;set upper left corner of
  33.                              ;window to (X,Y)=(0,0)
  34.          mov       dh,24     ;set Y to 24 for lower right
  35.          mov       dl,ah     ;corner, and X to the number
  36.          dec       dl        ;of columns returned by BIOS
  37.                              ;minus 1
  38.          mov       bh,7      ;initialize attribute byte
  39.                              ;to "normal" video display,
  40.                              ;i.e. white on black.
  41.                              ;set SI=address of command
  42.                              ;tail's length byte
  43.          mov       si,offset input
  44.          cld                 ;clear the Direction Flag
  45.                              ;for "LODS" string instruction.
  46.          lodsb               ;check length byte to see if
  47.          or        al,al     ;there's any command tail.
  48.          jz        clear8    ;no,go clear the screen
  49.                              ;with normal video attribute
  50.                              ;
  51. clear1:  lodsb               ;check the next byte of
  52.                              ;the command tail,
  53.          cmp       al,cr     ;if carriage return
  54.          je        clear8    ;we are done.
  55.          or        al,20h    ;fold the character to
  56.                              ;lower case.
  57.          cmp       al,'a'    ;make sure it's in range a-z
  58.          jb        clear1    ;no, skip it
  59.          cmp       al,'z'
  60.          ja        clear1    ;no, skip it
  61.          cmp       al,'i'    ;I=Set intensity
  62.          jne       clear2    ;jump if not I
  63.          or        bh,08     ;set intensity bit
  64.          jmp       short clear1
  65. clear2:  cmp       al,'r'    ;R=Reverse
  66.          jne       clear3    ;jump if not R
  67.          and       bh,088h   ;mask off old foreground/
  68.                              ;background bits and
  69.          or        bh,070h   ;change to reverse video
  70.          jmp       short clear1
  71. clear3:  cmp       al,'u'    ;U=Underline
  72.          jne       clear4    ;jump if not U
  73.          and       bh,088h   ;mask off old foreground/
  74.                              ;background bits and
  75.          or        bh,01h    ;change to underline
  76.          jmp       short clear1
  77. clear4:  cmp       al,'b'    ;B=Blink
  78.          jne       clear5    ;jump if not B
  79.          or        bh,080h   ;set blink bit
  80.          jmp       short clear1
  81. clear5:  cmp       al,'s'    ;S=Silent
  82.          jne       clear1    ;if not S try next char.
  83.          mov       bh,0      ;if S command, rig for
  84.                              ;silent running.  Clear
  85.                              ;the foreground/background
  86.                              ;display control fields, and
  87.                              ;don't bother to look for
  88.                              ;any more command characters.
  89.                              ;
  90. clear8:                      ;now we have decoded all
  91.                              ;the characters in the
  92.                              ;command tail, and are ready
  93.                              ;to initialize the display.
  94.                              ;BH=   desired attribute
  95.                              ;CL,CH=(X,Y),upper left
  96.                              ;      corner of window
  97.                              ;DL,DH=(X,Y),lower right
  98.                              ;      corner of window
  99.          mov       ax,0600h  ;AH =  function type 6,
  100.                              ;AL =  lines to scroll (zero)
  101.          int       10h       ;request initialization
  102.                              ;of window by BIOS
  103.                              ;
  104.          mov       ah,2      ;now set the cursor to
  105.          mov       bh,0      ;(X,Y)=(0,0), Page=0
  106.          xor       dx,dx
  107.          int       10h
  108.                              ;
  109. clear9:  int       20h       ;exit to PC-DOS
  110. ;
  111. cseg     ends
  112. ;
  113.          end       clear
  114.