home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / asm_kit / vmode.asm < prev    next >
Assembly Source File  |  1983-09-26  |  4KB  |  99 lines

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