home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / asmlib37.zip / SYSTEM.DOC < prev    next >
Text File  |  1993-06-10  |  28KB  |  910 lines

  1.  
  2. *****************************  SYSTEM  *************************************
  3.  
  4. ASMLIB system subroutines Copyright (C) 1991 - 1993 Douglas Herr
  5. all rights reserved
  6.  
  7.  
  8. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  9.  
  10. ALLOCDOS:    allocate memory block from DOS memory
  11. Source:      allocdos.asm
  12.  
  13. Call with:   DX:AX = bytes requested
  14.              Before using AllocDOS, you must release unused memory with
  15.              ENDPROG (see STARTUP.ASM).  Memory allocated with AllocDOS
  16.              may be released with DOS function 49h
  17. Returns:     if CF = 0, BX = segment address of allocated memory block
  18.              if CF = 1, AH = AL = DOS error code
  19. Uses:        AX, BX, flags
  20. Example:
  21.  
  22. include asm.inc
  23.  
  24. public  myprog
  25. extrn   allocdos:proc
  26.  
  27. .data
  28. dseg    dw ?          ; storage for segment address of allocated memory
  29. bytes   dd 100000     ; about 100k
  30.  
  31. .code
  32. myprog  proc
  33. ; program fragment assumes DS:@data
  34.         .
  35.         .
  36.         .
  37.         mov     ax,word ptr bytes
  38.         mov     dx,word ptr bytes+2   ; DX:AX = bytes requested
  39.         call    allocdos
  40.         jc      alloc_error
  41.         mov     dseg,bx
  42.  
  43.  
  44. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  45.  
  46. BREAKTRAP:   initialize Ctrl+Break trap
  47. BREAKRELEASE:restore previous Ctrl+Break handler
  48. Source:      break.asm
  49.  
  50. BREAKFLAG:   public byte in DGROUP, indicating Ctrl+Break key press
  51. Source:      asmflags.asm
  52.  
  53. Call with:   no parameters
  54.              BreakTrap uses well-behaved methods to trap Ctrl+Break,
  55.              Ctrl+C and Ctrl-Alt-Del key sequences.  When one of these
  56.              key combinations is pressed, ASMLIB's break trap sets the
  57.              public flag "breakflag" in the data area.  BreakRelease
  58.              de-activates ASMLIB's break trap, restoring the previous
  59.              Ctrl+Break handler.  BreakFlag = 0 until a monitored key
  60.              combination is pressed, at which time breakflag is set
  61.              equal to 1.  If you use BreakTrap, you MUST call BreakRelease
  62.              before the end of your program, or you will find yourself
  63.              reaching for the Big Red Switch.  See STARTUP.ASM.
  64. Returns:     nothing
  65. Uses:        nothing
  66. Example:     see STARTUP.ASM
  67.  
  68.  
  69.  
  70. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  71.  
  72. COLOR16:     calculate color value for palette register
  73. Source:      color16.asm
  74.  
  75. Call with:   DS:[BX] pointing to red value (0-3), green value (0-3)
  76.              and blue value (0-3)
  77.              Assumes DS:@data; see also Palette16
  78. Returns:     AH = color value for 16-color palette register
  79. Uses:        AH
  80. Supports:    VGA 16-color modes (text or graphics)
  81.              EGA 16-color modes, except with CGA monitor
  82. Example:
  83.  
  84. .data
  85. c16     db 3                  ; brightest red
  86.         db 1                  ; dim green
  87.         db 0                  ; no blue
  88.  
  89. .code
  90. ; program fragment assumes DS:@data
  91.         .
  92.         .
  93.         .
  94.         lea   bx,c16
  95.         call  color16
  96.  
  97.  
  98.  
  99. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  100.  
  101. DOSFREE:     deteremines DOS memory available
  102. Source:      dosfree.asm
  103.  
  104. Call with:   no parameters
  105. Returns:     DX:AX = bytes available in conventional memory space
  106.              For best results, release excess memory with ENDPROG
  107.              (see STARTUP.ASM).
  108. Uses:        DX, AX
  109. Example:
  110.         call   dosfree
  111.  
  112.  
  113. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  114.  
  115. ENDPROG:     determines program's size
  116.              this is handy for dynamic memory allocation, or for TSR work
  117. Source:      endprog.asm
  118.  
  119. Call with:   no parameters
  120. Returns:     (small, medium, huge models)
  121.              AX = segment address of end of program.  See STARTUP.ASM.
  122.              ENDPROG defines ZSEG as the last segment in the program.
  123.              If you add any object modules to ASMLIB.LIB, be certain any
  124.              segments in the added modules are defined before LINK
  125.              encounters ENDPROG.  Be sure to review the .MAP file after
  126.              linking.  ZSEG should be at the end of the program.
  127.  
  128.              (tiny model)
  129.              AX = offset of end of the program's code and initialized data.
  130.              See TINY.ASM startup code.  If you add any object modules to
  131.              ASMTINY.LIB, be certain any segments in the added modules
  132.              are defined before LINK encounters ENDPROG, and that all
  133.              segments are grouped in DGROUP.  Be sure to review the .MAP
  134.              file after linking.  ZSEG should be at the end of the program.
  135.              With TINY model, program stack extends beyond the end of the
  136.              code and initialized data to the end of the 64k program
  137.              segment.
  138. Uses:        AX
  139. Example:     see STARTUP.ASM or TINY.ASM
  140.  
  141.  
  142. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  143.  
  144. EXENAME:     determine the full path and filename of the executing program
  145. Source:      exename.asm (strlen.asm)
  146.  
  147. Call with:   ES = PSP segment (see STARTUP.ASM)
  148. Returns:     ES:[BX] pointing to the the name of the executing program,
  149.              including drive and full path, CX = length of the filename.
  150.              The filename returned is an ASCIIZ string, and may be mixed
  151.              upper- and lower-case characters.
  152. Uses:        ES, BX, CX; all other registers and flags are saved.
  153. Example:
  154.  
  155. include asm.inc
  156.  
  157. extrn   exename:proc
  158.  
  159. .data
  160. extrn   pspseg:word
  161.  
  162. .code
  163. ; program fragment assumes DS:@data
  164.         .
  165.         .
  166.         .
  167.         mov   es,pspseg
  168.         call  exename         ; string returned at ES:[BX] can be
  169.                               ; copied to heap with STRNDUP
  170.  
  171.  
  172.  
  173. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  174.  
  175. EXESIZE:     determine size of .EXE program
  176.              NOTE: not in ASMTINY.LIB or 286TINY.LIB
  177. Source:      exesize.asm
  178.  
  179. Call with:   DS:[DX] pointing to ASCIIZ .EXE filename
  180. Returns:     if CF = 1, AX = DOS error code
  181.                         if AX = 0, not an EXE-format file
  182.              if CF = 0, DX:AX = bytes in .EXE file loaded by DOS program
  183.                         loader
  184.              Note that additional data may be copied to the end of a DOS
  185.              .EXE file with the DOS COPY /B command.  This is handy for
  186.              help screens or other such data that you want to keep with
  187.              the .EXE file, but that you don't want to be loaded in memory
  188.              with the program.  If you do copy additional data to the .EXE
  189.              file, EXESize will report only the portion of the file loaded
  190.              in RAM by the DOS program loader, while FSize (in DISK.DOC)
  191.              reports the entire file size.
  192. Uses:        AX, DX, flags
  193. Example:
  194.  
  195. ;
  196. ; code used to test EXEsize
  197. ;
  198. include asm.inc
  199.  
  200. public  testcode
  201. extrn   exename:proc, exesize:proc
  202. extrn   strndup:proc, i4tostr:proc
  203. extrn   tprint:proc, getkey:proc
  204.  
  205. .data
  206. extrn   pspseg:word
  207. space   db 20 dup(0)
  208.  
  209. .code
  210. testcode        proc
  211.         mov     es,pspseg
  212.         call    exename         ; get name of this program
  213.         call    strndup         ; copy to near heap
  214.                                 ; startup code was assembled with /DHEAP
  215.         mov     dx,bx           ; DS:[DX] -> EXE filename
  216.         call    exesize         ; DX:AX = EXE program size
  217.         lea     si,space
  218.         call    i4tostr         ; convert to ASCIIZ string
  219.         xor     dx,dx           ; point to UL corner of screen
  220.         mov     ah,12           ; "can't miss it" color
  221.         call    tprint          ; print it
  222.         call    getkey          ; don't scroll off screen yet
  223.         ret                     ; go back to calling code
  224. testcode        endp
  225.         end
  226.  
  227.  
  228. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  229.  
  230. FARALLOC:    allocate memory from a far heap
  231. Source:      farheap.asm
  232.  
  233. Call with:   ES = segment address of far heap
  234.              AX = requested block size
  235. Returns:     if CF = 1, insufficient memroy available in heap
  236.              if CF = 0, ES:[BX] = starting address of allocated memory
  237. Uses:        BX, flags
  238. Example:     see FarInit
  239.  
  240.  
  241. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  242.  
  243. FARFREE:     releases far heap memory previously allocated
  244. Source:      farheap.asm
  245.  
  246. Call with:   ES:[BX] pointing to memory block to be released
  247. Returns:     nothing
  248. Uses:        AX, BX, flags
  249. Example:     mov   es,heap_seg
  250.              mov   bx,pointer
  251.              call  farfree
  252.  
  253.  
  254. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  255.  
  256. FARINIT:     initializes a far heap
  257. Source:      farheap.asm
  258.  
  259. Call with:   ES = segment address of memory block to be managed by ASMLIB's
  260.              far heap manager
  261.              AX = size of memory block in bytes (2 < bytes < 32768)
  262.              FarInit assumes that the memory block begins at ES:[0].
  263.              Any number of far heaps may be used if memory is available.
  264. Returns:     if CF = 0, successful; if CF = 1, AX is out of range.
  265. Uses:        flags
  266. Example:
  267.  
  268. include asm.inc
  269.  
  270. extrn   allocdos:proc, farinit:proc
  271.  
  272. .data
  273. heap_seg        dw ?
  274.  
  275. .code
  276.         .
  277.         .
  278.         .
  279.         mov     ax,32767
  280.         xor     dx,dx           ; allocate 32k from DOS memory
  281.         push    ax
  282.         call    allocdos
  283.         mov     heap_seg,bx     ; segment address of allocated block
  284.         pop     ax              ; size of block
  285.         jc      not_enough_dos  ; insufficient memory available
  286.         mov     es,heap_seg
  287.         call    farinit         ; initialize this block
  288.         .
  289.         .
  290.         mov     ax,125          ; get 125 bytes from far heap
  291.         mov     es,heap_seg     ; heap address
  292.         call    faralloc        ; get far memory; returned at ES:[BX]
  293.         jc      not_enough_heap
  294.  
  295.  
  296.  
  297. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  298.  
  299. FARREALLOC:  re-sizes a block of memory in a far heap
  300. Source:      farheap.asm
  301.  
  302. Call with:   ES:[BX] = original pointer to memory block
  303.              AX = new byte size
  304. Returns:     if successful, CF = 0, ES:[BX] points to new block
  305.              if not successful, CF = 1
  306. Uses:        BX, flags
  307. Example:     mov    es,heap_seg
  308.              mov    bx,pointer
  309.              mov    ax,newsize
  310.              call   farrealloc
  311.  
  312.  
  313. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  314.  
  315. FINDMONO:    detects a monochrome-compatible video card
  316.              this is handy in 2-monitor systems.
  317. Source:      findmono.asm (a$herc.asm, isega.asm, $6845.asm)
  318.  
  319. Call with:   no parameters
  320. Returns:     if CF = 1, no monochrome monitor
  321.              if CF = 0, AX = monitor code
  322.               0 = MDA
  323.               0101h = EGA monochrome
  324.               0301h = VGA monochrome
  325.               128 = Hercules or clone
  326.               144 = Hercules Graphics Card plus
  327.               208 = Hercules InColor
  328. Uses:        AX, CF
  329. Supports:    MDA, EGA & VGA MONO, HGC, HGC+, InColor
  330. Example:     call  findmono
  331.              jc    no_monochrome
  332.  
  333.  
  334.  
  335. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  336.  
  337. FLOPPIES:    determine the number of floppy disk drives intalled
  338. Source:      floppies.asm
  339.  
  340. Call with:   no parameters
  341. Returns:     AX = number of floppy drives
  342. Uses:        AX; all other registers and flags are saved
  343. Example:
  344.  
  345. .model medium
  346.  
  347. public  myproc
  348. extrn   floppies:proc
  349.  
  350. .code
  351. myproc  proc
  352.         .
  353.         call   floppies
  354.  
  355.  
  356.  
  357. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  358.  
  359. FLOPPYTYPE:  determine the type of floppy disk drives intalled
  360. Source:      floptype.asm
  361.  
  362. Call with:   DL = drive number (0 = drive A:)
  363. Returns:     AX = floppy drive type
  364.               0 = invalid drive number
  365.               1 = 360k
  366.               2 = 1.2M
  367.               3 = 720k
  368.               4 = 1.44M
  369. Uses:        AX, flags
  370. Example:
  371.  
  372. .model medium
  373.  
  374. public  myproc
  375. extrn   floppytype:proc
  376.  
  377. .data
  378. drive_number   db 0
  379.  
  380. .code
  381. myproc  proc
  382.         .
  383.         mov    dl,drive_number
  384.         call   floppytype
  385.         or     ax,ax
  386.         jz     bad_drive_number
  387.  
  388. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  389.  
  390. GETCPU:      detects cpu type
  391. Source:      getcpu.asm
  392.  
  393. Call with:   no parameters
  394. Returns:     AX = 0 if 8086/8088
  395.              AX = 1 if 80186/80188
  396.              AX = 2 if 80286
  397.              AX = 3 if 386 (SX or DX)
  398.              AX = 4 if 486 (SX or DX)
  399. Uses:        AX
  400. Example:     call   getcpu
  401.  
  402.  
  403.  
  404. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  405.  
  406. GETCRT:      determines active monitor type
  407. Source:      getcrt.asm (a$herc.asm, isevga.asm)
  408.  
  409. Call with:   no parameters
  410. Returns:     AX = code for active video system
  411.              CGA = -1
  412.              MDA = 0
  413.              EGA mono = 0100h
  414.              VGA mono = 0300h
  415.              EGA color = 1
  416.              MCGA = 2
  417.              VGA color = 3
  418.              HGC = 128
  419.              HGC+ = 144
  420.              InColor = 208
  421.              Note: GetCRT may be re-assembled with the /DNOHERC switch
  422.              to eliminate code which detects Hercules equipment
  423. Uses:        AX
  424. Supports:    CGA, MCGA, MDA, HGC, HGC+, InColor, EGA, VGA
  425. Example:     call    getcrt
  426.  
  427.  
  428.  
  429. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  430.  
  431. HALLOC:      allocates memory from near heap
  432. Source:      heap.asm
  433.  
  434. Call with:   AX = bytes requested; assumes DS:@data
  435.              heap must be initialized with hinit
  436. Returns:     if space available:
  437.              BX = near pointer for allocated data
  438.              if space not available:
  439.              CF = 1
  440. Uses:        AX, BX, flags
  441. Example:     mov   ax,bytes
  442.              call  halloc
  443.              jc    no_memory       ; check to see if there was enough space
  444.  
  445.  
  446. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  447.  
  448. HFREE:       releases heap memory previously allocated
  449. Source:      heap.asm
  450.  
  451. Call with:   BX = near pointer to memory block; assumes DS:@data
  452. Returns:     nothing
  453. Uses:        flags
  454. Example:     mov   bx,pointer
  455.              call  hfree
  456.  
  457.  
  458.  
  459. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  460.  
  461. HINIT:       initializes heap manager
  462. Source:      heap.asm
  463.  
  464. Call with:   AX = number of bytes to be managed by heap manager
  465.              2 <=bytes<= 32767
  466.              BX = near pointer to memory block to be managed
  467.              assumes  DS:@data
  468. Returns:     CF = 0 if ok, CF = 1 if bad parameter (bytes too
  469.              small or too large)
  470. Uses:        flags
  471. Example:
  472.  
  473. .data
  474. heap   db  32767 dup(0)
  475.  
  476. .code
  477.        mov    ax,@data
  478.        mov    ds,ax
  479.        assume ds:@data
  480.        mov    ax,32767
  481.        lea    bx,heap
  482.        call   hinit
  483.  
  484.  
  485. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  486.  
  487. HMAX:        determines largest free block in asmlib's near heap
  488. Source:      heap.asm
  489.  
  490. Call with:   no parameters
  491. Returns:     AX = block size in bytes
  492.              AX = -1 if the heap has not been initialized
  493. Uses:        AX
  494. Example:     call   hmax
  495.  
  496.  
  497.  
  498. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  499.  
  500. HREALLOC:    re-sizes a block of memory in the near heap
  501. Source:      heap.asm
  502.  
  503. Call with:   BX = original pointer to memory block
  504.              AX = new byte size
  505. Returns:     if successful, CF = 0, BX = new block pointer
  506.              if not successful, CF = 1
  507. Uses:        BX, flags
  508. Example:     mov    bx,pointer
  509.              mov    ax,newsize
  510.              call   hrealloc
  511.  
  512.  
  513. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  514.  
  515. ISANSI:      determines if ANSI or compatible is loaded and active
  516. Source:      isansi.asm
  517.  
  518. Parameters:  none
  519. Returns:     CF = 1 if no ANSI device driver loaded and active
  520.              CF = 0 if ANSI loaded and active
  521. Uses:        CF
  522. Example:     call   isansi         ; let's see if ansi.sys is loaded
  523.              jc     no_ansi        ; jump if not
  524.  
  525.  
  526.  
  527. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  528.  
  529. ISATT:       determines if an ATT 6300-type display card is installed
  530.              this equipment is like a CGA except that it has an additional
  531.              640 x 400 2-color graphics mode (mode 40h)
  532. Source:      isatt.asm ($6845.asm, isevga.asm)
  533.  
  534. Call with:   no parameters
  535. Returns:     if CF = 1, ATT 6300 display not present
  536.              if CF = 0, ATT 6300 display is installed
  537. Uses:        flags
  538. Example:
  539.  
  540. include asm.inc
  541.  
  542. public  cgamode
  543.  
  544. extrn   isatt:proc
  545.  
  546. .code
  547. cgamode proc
  548.         mov     ax,06h             ; default: set CGA mode
  549.         call    isatt              ; see if mode 40h is available
  550.         jc      set_mode           ; nope
  551.         mov     ax,40h             ;  use ATT 6300 mode 40h
  552. set_mode:
  553.         push    bp                 ; required by old PC BIOS
  554.         int     10h                ; use BIOS to set mode
  555.         pop     bp
  556.         ret
  557. cgamode endp
  558.         end
  559.  
  560.  
  561. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  562.  
  563. ISEVGA:      determines if an EGA or VGA is installed
  564. Source:      isevga.asm
  565.  
  566. Call with:   no parameters
  567. Returns:     if CF = 1, no EGA or VGA
  568.              if CF = 0
  569.                DX = video memory in kbytes
  570.                AL = monitor type
  571.                 AL = -1 if monitor is CGA
  572.                 AL = 0 if monitor is monochrome
  573.                 AL = 1 if monitor is EGA or better
  574.  
  575.                AH = EGA/VGA flag
  576.                 AH = 1 if EGA
  577.                 AH = 3 if VGA
  578.  
  579. Uses:        AX, DX, CF
  580. Example:     call   isevga
  581.              jc     no_evga
  582.  
  583.  
  584.  
  585. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  586.  
  587. ISHERC:      determines if a Hercules card or compatible is installed
  588.              and if so, determines if it is the active video system.
  589. Source:      isherc.asm (a$herc.asm)
  590.  
  591. Call with:   no parameters
  592. Returns:     if CF = 1, no Hercules or compatible installed
  593.              if CF = 0, AX = Hercules model
  594.              128 = Hercules Graphics Card or compatible; active
  595.              144 = Hercules Graphics Card Plus; active
  596.              208 = Hercules InColor card; active
  597.              -128 = Hercules Graphics Card or compatible; not active
  598.              -144 = Hercules Graphics Card Plus; not active
  599.              -208 = Hercules InColor card; not active
  600. Uses:        AX, CF; all other flags and registers are saved
  601. Example:     call  isherc
  602.              jc    no_herc
  603.  
  604.  
  605.  
  606. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  607.  
  608. ISMOUSE:     determines if a mouse is installed
  609. Source:      ismouse.asm (asmflags.asm)
  610.  
  611. Parameters:  none
  612. Returns:     AX = number of mouse buttons
  613.              AX = 0 if no mouse or mouse driver installed
  614. Uses:        AX
  615. Example:
  616.  
  617. include  asm.inc
  618.  
  619. .code
  620.        .
  621.        .
  622.        .
  623.        call    ismouse
  624.        or      ax,ax
  625.        jz      no_mouse
  626.  
  627.  
  628.  
  629. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  630.  
  631. ISSEVGA:     determines if a Super EGA or Super VGA is installed
  632. Source:      issevga.asm
  633.  
  634. Parameters:  none
  635. Returns:     if CF = 1, no Super EGA or Super VGA recognized by ASMLIB
  636.  
  637.              if CF = 0
  638.  
  639.               if AH = 1: (Super EGA)
  640.                AL = 1 if Paradise EGA 480
  641.                AL = 2 if Everex EGA
  642.  
  643.               if AH = 3: (Super VGA)
  644.                AL = 1 if Paradise VGA
  645.                AL = 3 if Tseng VGA chipset
  646.                AL = 4 if Oak VGA
  647.                AL = 5 if Western Digital VGA chipset
  648.  
  649.              See also IsEVGA
  650. Uses:        AX, CF
  651. Example:     call   issevga
  652.              jc     no_superevga
  653.  
  654.  
  655.  
  656. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  657.  
  658. ISVM86:      determines if 32-bit processor is in V86 mode
  659. Source:      isvm86.asm (getcpu.asm)
  660.  
  661. Parameters:  none
  662.              V86 is used by Expanded Memory device drivers such as QEMM
  663.              and EMM386 to provide Expanded Memory using extended memory
  664.              of 32-bit systems such as 386 (DX and SX) and 486 (DX and SX)
  665.              computers
  666. Returns:     AX = processor type (see GetCPU)
  667.              if CF = 0, 32-bit processor in V86 mode
  668.              if CF = 1, no 32-bit processor or not V86 mode
  669. Uses:        AX, flags
  670. Example:
  671.  
  672. include asm.inc
  673.  
  674. public  test_for_vm86
  675. extrn   isvm86:proc
  676.  
  677. .data
  678. vm86    db 'VM86 detected',0Dh,0AH,'$'
  679. notvm86 db 'VM86 not detected',0Dh,0AH,'$'
  680.  
  681. .code
  682. test_for_vm86   proc
  683.         lea     dx,vm86
  684.         call    isvm86
  685.         jnc     exit
  686.         lea     dx,notvm86
  687. exit:   mov     ah,9           ; DOS function: display string
  688.         int     21h
  689.         ret
  690. test_for_vm86   endp
  691.  
  692.  
  693.  
  694. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  695.  
  696. MATHCHIP:    determines if 80x87 math coprocessor is installed
  697. Source:      mathchip.asm
  698.  
  699. Parameters:  none
  700. Returns:     AX = code for 80x87 model
  701.              0 = not installed
  702.              1 = 8087
  703.              2 = 287
  704.              3 = 387 (DX or SX)
  705.              4 = 487 (486DX or 487SX)
  706.              If the coprocessor is present, it is initilaized by MathChip.
  707. Uses:        AX, all 80x87 registers
  708. Example:     call  mathchip
  709.  
  710.  
  711.  
  712. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  713.  
  714. MOUSEINIT:   initializes mouse driver if mouse present
  715. Source:      mouseini.asm
  716.  
  717. MOUSEFLAG:   public byte in DGROUP indicating mouse buttons
  718. Source:      asmflags.asm
  719.  
  720. Parameters:  assumes DS:@data
  721. Returns:     if mouse installed, ZF = 0 and AX = number of mouse buttons
  722.              also updates mouseflag
  723.              if no mouse, ZF = 1 and AX = 0
  724. Uses:        AX, flags
  725. Example:
  726.  
  727. include asm.inc
  728.  
  729. extrn   mouseinit:proc
  730.  
  731. .code
  732. ; program fragment assumes DS:@data
  733.         .
  734.         .
  735.         .
  736.         call    mouseinit
  737.         jz      no_mouse
  738.  
  739.  
  740.  
  741. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  742.  
  743. MSAVE:       save mouse state
  744. Source:      msave.asm (dosalloc.asm)
  745.  
  746. MRESTORE:    restore previously saved mouse state
  747. Source:      msave.asm (dosalloc.asm)
  748.  
  749.              MSave and MRestore are handy when you have installed a
  750.              mouse event handler and you will be using the SYSTEM command,
  751.              where some other program may reset or otherwise change the
  752.              mouse event trapping.
  753.  
  754.              MSave allocates a buffer, saves the mouse state in the
  755.              buffer, resets the mouse driver and returns the buffer address.
  756.  
  757.              MRestore restores a specified mouse state and releases the
  758.              buffer.  Both MSave and MRestore assume that you already
  759.              know there is a mouse in the system.
  760.  
  761. Call with:   MSAve: no paramerters
  762.              MRestore: AX = buffer address returned by prior MSave call
  763. Returns:     if CF = 1, AH = MS-DOS error code
  764.              if CF = 0, no error; MSave returns buffer address in AX
  765. Uses:        AX, flags
  766. Example:
  767.  
  768. include asm.inc
  769. extrn   msave:proc, mrestore:proc
  770.  
  771. .data
  772. save_mouse dw 0
  773.  
  774. .code
  775. ; program fragment assumes DS:@data
  776.         .
  777.         .
  778.         .
  779.  
  780. ; save the mouse driver state
  781. ; I've already checked to see if there's a mouse
  782.         call    msave
  783.         jc      dos_error
  784.         mov     save_mouse,ax
  785.         .
  786.         .
  787. ; some other subroutine has messed with the mouse
  788.         mov     ax,save_mouse   ; buffer address from previous MSave
  789.         call    mrestore
  790.         jc      dos_error
  791.  
  792.  
  793.  
  794. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  795.  
  796. PALETTE16:   change palette in EGA, VGA or SVGA 16-color mode
  797.              changing the palette changes the actual color associated
  798.              with a color attribute
  799. Source:      palet16.asm
  800.  
  801. Call with:   BH = color value (see Color16 in SYSTEM.DOC)
  802.              BL = color attribute to map color to (0-0Fh)
  803.              restore default palette with BH = BL = 0FFh
  804. Returns:     nothing
  805. Uses:        nothing
  806. Example:
  807.  
  808. .data
  809. c16     db 3                  ; brightest red
  810.         db 1                  ; dim green
  811.         db 0                  ; no blue
  812.  
  813. .code
  814. ; program fragment assumes DS:@data
  815.         .
  816.         .
  817.         .
  818.         lea   bx,c16
  819.         call  color16
  820.         mov   bh,ah           ; color value in BH
  821.         mov   bl,15           ; color attribute 0Fh
  822.         call  palette16
  823.  
  824.  
  825.  
  826. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  827.  
  828. SYSTEM:      execute a second copy of COMMAND.COM;  optionally runs another
  829.              program.
  830. Source:      system.asm (strlen.asm)
  831.  
  832. Parameters:  ES = PSP segment
  833.              DS:[BX] points to command tail
  834.              if DS:[BX] points to a nul byte, control is transfered
  835.              to the second copy of COMMAND.COM and you get a DOS prompt.
  836.              control is passed back to the calling program when EXIT is
  837.              entered at the DOS prompt.
  838.  
  839.              if DS:[BX] points to an ASCIIZ string with the name of a
  840.              program (and optional command line parameters), the program
  841.              will be executed, and control will pass back to the calling
  842.              program at the termination of the second program.
  843. Returns:     nothing
  844. Uses:        AX
  845. Example:
  846.  
  847. include asm.inc
  848.  
  849. ; I want to go to DOS temporarily to format a 720k disk
  850. extrn   system:proc
  851.  
  852. .data
  853. ; PSP segment is saved here by my startup code
  854. pspseg  dw ?
  855. cmdtail db 'format a: /n:9 /t:80',0
  856.  
  857. .code
  858. ; program fragment assumes DS:@data
  859.         .
  860.         .
  861.         lea     bx,cmdtail    ; DS:[BX] points to command tail
  862.         mov     es,pspseg
  863.         call    system
  864.  
  865.  
  866. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  867.  
  868. USE32K:      limit Hercules equipment to 32k memory (128k on InColor)
  869. USE64K:      allow full 64k on HGC and HGC+ (256k on InColor)
  870. Source:      a$herc.asm
  871.  
  872. Requires Hercules or compatible
  873.  
  874. Call with:   no parameters
  875.              Use32k is equivalent to the Hercules "half" configuration
  876.              Use64k is equivalent to the Hercules "full" configuration
  877.              ASMLIB's default is "half".  Use this configuration if you
  878.              have a 2-monitor system, unless you are using the Hercules
  879.              CGA card. 
  880. Returns:     nothing
  881. Uses:        nothing
  882. Example:     ; in this example I'm determining if a Hercules is installed
  883.              ; and setting the configuration to "full"
  884. extrn  IsHerc:proc
  885. extrn  Use64k:proc
  886. .code
  887.        .
  888.        .
  889.        .
  890.        call  IsHerc
  891.        jc    no_herc
  892.        or    ax,ax
  893.        js    use_only_half   ; use_only_half if HGC is not default monitor
  894.        call  use64k          ; else use all Hercules memory
  895. use_only_half:
  896.  
  897.  
  898. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  899.  
  900. WHICHVGA:    determine if VGAKIT-compatible SuperVGA is installed
  901.              See SVGA16 and SVGA256 in MODE.DOC.
  902. Source:      banks.asm
  903.  
  904. Call with:   no parameters
  905. Returns:     if VGAKIT-compatible Super VGA is installed, AX <> 0.
  906.              if no VGAKIT equipment is installed, AX = 0.
  907. Uses:        AX
  908. Example:     see SVGA16 in MODE.DOC
  909.  
  910.