home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DOS_HELP / ADVMSDOS.ZIP / VMODE.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-06-19  |  4.1 KB  |  116 lines

  1.          name      vmode
  2.          page      55,132
  3.          title     'VMODE --- Set PC Video Mode'
  4.  
  5. ;
  6. ; VMODE utility to set display mode on IBM Personal Computer
  7. ;
  8. ; Copyright (C) 1983 Ray Duncan
  9. ;
  10. ; To assemble, link, and convert this program into 
  11. ; a COM file, follow these steps:
  12. ;
  13. ;    C>MASM VMODE;
  14. ;     C>LINK VMODE;
  15. ;    C>EXE2BIN VMODE.EXE VMODE.COM
  16. ;    C>DEL VMODE.EXE
  17. ;
  18. ; Ignore the message "Warning: no stack segment" from the Linker.
  19. ;
  20.  
  21. input    equ       080h      ;address of command tail
  22.                              ;buffer (set up by DOS)
  23. blank    equ       20h       ;ASCII blank code
  24. cr       equ       0dh       ;ASCII carriage return
  25. lf       equ       0ah       ;ASCII line feed
  26.  
  27. cseg     segment   byte
  28.  
  29.          assume    cs:cseg,ds:cseg,es:cseg,ss:cseg
  30.  
  31.          org       100h
  32.  
  33. vmode:                       ;initialize DI to the
  34.                              ;address of the input buffer
  35.          mov       di,offset input
  36.          mov       al,[di]   ;check if any command tail
  37.          or        al,al     ;and exit if not
  38.          jz        vmode7
  39.          mov       al,blank  ;load ASCII blank for scan
  40.          inc       di        ;increment address in DI
  41.                              ;past the input count byte
  42.          mov       cx,80     ;scan max of 80 chars.
  43.          cld                 ;clear direction flag
  44.          repz scasb          ;look for first none-blank
  45.                              ;character in input buffer
  46.          jz        vmode7    ;jump if none found
  47.                              ;load the none-blank char.,
  48.                              ;use offset of -1 since DI
  49.                              ;will be pointing past it
  50.          mov       al,-1 [di]
  51.          cmp       al,cr     ;if first none-blank char
  52.                              ;was RETURN,mode was missing
  53.          jz        vmode7    ;so go print error message
  54.          cmp       al,'0'    ;make sure it is range 0-7
  55.          jb        vmode8    ;exit if ASCII code < '0'
  56.          cmp       al,'7'
  57.          ja        vmode8    ;exit if ASCII code > '7'
  58.          mov       vmodeb,al ;store mode number into
  59.                              ;output string
  60.          and       al,0fh    ;mask off upper four bits
  61.                              ;of char. to get 0-7
  62.          push      ax        ;save mode for later
  63.          xor       bx,bx     ;set ES=zero
  64.          mov       es,bx
  65.          mov       bx,410h   ;set BX=addr of DOS's
  66.                              ;equipment flags word
  67.          cmp       al,7      ;check if monochrome
  68.                              ;or graphics board
  69.          mov       al,30h    ;assume monochome
  70.          jz        vmode6
  71.          mov       al,20h    ;no,was graphics board
  72.  
  73. vmode6:                      ;mask off the old
  74.                              ;display equipment flags
  75.          and       byte ptr es:[bx],0cfh
  76.                              ;merge in the proper flag
  77.                              ;for newly selected display
  78.          or        es:[bx],al
  79.          pop       ax        ;recover mode
  80.          xor       ah,ah     ;force AH=zero
  81.          int       10h       ;and call ROM BIOS to set mode
  82.                              ;go print success message and exit
  83.          mov       dx,offset vmodea
  84.          jmp       vmode9
  85.  
  86. vmode7:                      ;print "missing mode number"
  87.          mov       dx,offset vmodec
  88.          jmp       vmode9
  89.  
  90. vmode8:                      ;print "illegal mode number"
  91.          mov       dx,offset vmoded
  92.  
  93. vmode9:                      ;print the message whose
  94.                              ;address is in reg. DX
  95.          mov       ah,9      ;function 9 = print string
  96.          int       21h       ;call DOS to print
  97.  
  98.      mov       ax,4c00h  ;exit with retcode=0 
  99.          int       21h
  100.  
  101. vmodea   db        cr,lf
  102.          db        'Video mode set to '
  103. vmodeb   db        ' ',cr,lf,'$'
  104.  
  105. vmodec   db        cr,lf
  106.          db        'Missing mode number.'
  107.          db        cr,lf,'$'
  108.  
  109. vmoded   db        cr,lf
  110.          db        'Illegal mode number.'
  111.          db        cr,lf,'$'
  112.  
  113. cseg     ends
  114.  
  115.          end       vmode
  116.