home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / asmlib / system.doc < prev    next >
Text File  |  1994-01-06  |  29KB  |  957 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:      $flags.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 ($flags.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 ($sega.asm, $svga.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.               AH = 1: Super EGA
  640.               AH = 3: Super VGA
  641.  
  642.               AL = 1 if Paradise
  643.               AL = 2 if Everex
  644.               AL = 3: Tseng VGA chipset
  645.               AL = 4: Oak Technologies
  646.               AL = 5: Western Digital (Paradise) OEM
  647.               AL = 6: ATI
  648.               AL = 7: Compaq
  649.               AL = 8: NCR
  650.               AL = 9: Trident
  651.               AL =10: Video7
  652.               AL =11: Genoa
  653.               AL =12: Cirrus
  654.               AL =13: Chips & Technologies
  655.               AL =14: Tseng 4000
  656.               AL =15: Ahead A
  657.               AL =16: Ahead B
  658.               AL =17: Trident 8900
  659.  
  660.              See also IsEVGA
  661. Uses:        AX, CF
  662. Example:     call   issevga
  663.              jc     no_superevga
  664.  
  665.  
  666.  
  667. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  668.  
  669. ISVM86:      determines if 32-bit processor is in V86 mode
  670. Source:      isvm86.asm (getcpu.asm)
  671.  
  672. Parameters:  none
  673.              V86 is used by Expanded Memory device drivers such as QEMM
  674.              and EMM386 to provide Expanded Memory using extended memory
  675.              of 32-bit systems such as 386 (DX and SX) and 486 (DX and SX)
  676.              computers
  677. Returns:     AX = processor type (see GetCPU)
  678.              if CF = 0, 32-bit processor in V86 mode
  679.              if CF = 1, no 32-bit processor or not V86 mode
  680. Uses:        AX, flags
  681. Example:
  682.  
  683. include asm.inc
  684.  
  685. public  test_for_vm86
  686. extrn   isvm86:proc
  687.  
  688. .data
  689. vm86    db 'VM86 detected',0Dh,0AH,'$'
  690. notvm86 db 'VM86 not detected',0Dh,0AH,'$'
  691.  
  692. .code
  693. test_for_vm86   proc
  694.         lea     dx,vm86
  695.         call    isvm86
  696.         jnc     exit
  697.         lea     dx,notvm86
  698. exit:   mov     ah,9           ; DOS function: display string
  699.         int     21h
  700.         ret
  701. test_for_vm86   endp
  702.  
  703.  
  704.  
  705. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  706.  
  707. MATHCHIP:    determines if 80x87 math coprocessor is installed
  708. Source:      mathchip.asm
  709.  
  710. Parameters:  none
  711. Returns:     AX = code for 80x87 model
  712.              0 = not installed
  713.              1 = 8087
  714.              2 = 287
  715.              3 = 387 (DX or SX)
  716.              4 = 487 (486DX or 487SX)
  717.              If the coprocessor is present, it is initilaized by MathChip.
  718. Uses:        AX, all 80x87 registers
  719. Example:     call  mathchip
  720.  
  721.  
  722.  
  723. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  724.  
  725. MOUSEINIT:   initializes mouse driver if mouse present
  726. Source:      mouseini.asm
  727.  
  728. MOUSEFLAG:   public byte in DGROUP indicating mouse buttons
  729. Source:      $flags.asm
  730.  
  731. Parameters:  assumes DS:@data
  732. Returns:     if mouse installed, ZF = 0 and AX = number of mouse buttons
  733.              also updates mouseflag
  734.              if no mouse, ZF = 1 and AX = 0
  735. Uses:        AX, flags
  736. Example:
  737.  
  738. include asm.inc
  739.  
  740. extrn   mouseinit:proc
  741.  
  742. .code
  743. ; program fragment assumes DS:@data
  744.         .
  745.         .
  746.         .
  747.         call    mouseinit
  748.         jz      no_mouse
  749.  
  750.  
  751.  
  752. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  753. MOUSETYPE:   determine mouse type (bus, serial, PS/2, etc.)
  754. Source:      mousetyp.asm
  755.  
  756. Call with:   no parameters
  757.              assumes mouse driver has been loaded (see IsMouse)
  758. Returns:     AX = mouse type
  759.               0 = mouse driver error
  760.               1 = bus mouse
  761.               2 = serial mouse
  762.               3 = InPort mouse
  763.               4 = PS/2 mouse
  764.               5 = HP mouse
  765. Uses:        AX, flags
  766. Example:
  767.  
  768. include asm.inc
  769.  
  770. extrn   mousetype:proc
  771. extrn   ismouse:proc
  772.  
  773. .code
  774.         .
  775.         .
  776.         .
  777.         call   ismouse
  778.         or     ax,ax        ; is a mouse installed?
  779.         jz     no_mouse
  780.         call   mousetype    ; what kind of mouse?
  781.         or     ax,ax
  782.         jz     mouse_error
  783.         .
  784.         .
  785.  
  786.  
  787.  
  788. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  789.  
  790. MSAVE:       save mouse state
  791. Source:      msave.asm (dosalloc.asm)
  792.  
  793. MRESTORE:    restore previously saved mouse state
  794. Source:      msave.asm (dosalloc.asm)
  795.  
  796.              MSave and MRestore are handy when you have installed a
  797.              mouse event handler and you will be using the SYSTEM command,
  798.              where some other program may reset or otherwise change the
  799.              mouse event trapping.
  800.  
  801.              MSave allocates a buffer, saves the mouse state in the
  802.              buffer, resets the mouse driver and returns the buffer address.
  803.  
  804.              MRestore restores a specified mouse state and releases the
  805.              buffer.  Both MSave and MRestore assume that you already
  806.              know there is a mouse in the system.
  807.  
  808. Call with:   MSAve: no paramerters
  809.              MRestore: AX = buffer address returned by prior MSave call
  810. Returns:     if CF = 1, AH = MS-DOS error code
  811.              if CF = 0, no error; MSave returns buffer address in AX
  812. Uses:        AX, flags
  813. Example:
  814.  
  815. include asm.inc
  816. extrn   msave:proc, mrestore:proc
  817.  
  818. .data
  819. save_mouse dw 0
  820.  
  821. .code
  822. ; program fragment assumes DS:@data
  823.         .
  824.         .
  825.         .
  826.  
  827. ; save the mouse driver state
  828. ; I've already checked to see if there's a mouse
  829.         call    msave
  830.         jc      dos_error
  831.         mov     save_mouse,ax
  832.         .
  833.         .
  834. ; some other subroutine has messed with the mouse
  835.         mov     ax,save_mouse   ; buffer address from previous MSave
  836.         call    mrestore
  837.         jc      dos_error
  838.  
  839.  
  840.  
  841. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  842.  
  843. PALETTE16:   change palette in EGA, VGA or SVGA 16-color mode
  844.              changing the palette changes the actual color associated
  845.              with a color attribute
  846. Source:      palet16.asm
  847.  
  848. Call with:   BH = color value (see Color16 in SYSTEM.DOC)
  849.              BL = color attribute to map color to (0-0Fh)
  850.              restore default palette with BH = BL = 0FFh
  851. Returns:     nothing
  852. Uses:        nothing
  853. Example:
  854.  
  855. .data
  856. c16     db 3                  ; brightest red
  857.         db 1                  ; dim green
  858.         db 0                  ; no blue
  859.  
  860. .code
  861. ; program fragment assumes DS:@data
  862.         .
  863.         .
  864.         .
  865.         lea   bx,c16
  866.         call  color16
  867.         mov   bh,ah           ; color value in BH
  868.         mov   bl,15           ; color attribute 0Fh
  869.         call  palette16
  870.  
  871.  
  872.  
  873. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  874.  
  875. SYSTEM:      execute a second copy of COMMAND.COM;  optionally runs another
  876.              program.
  877. Source:      system.asm (strlen.asm)
  878.  
  879. Parameters:  ES = PSP segment
  880.              DS:[BX] points to command tail
  881.              if DS:[BX] points to a nul byte, control is transfered
  882.              to the second copy of COMMAND.COM and you get a DOS prompt.
  883.              control is passed back to the calling program when EXIT is
  884.              entered at the DOS prompt.
  885.  
  886.              if DS:[BX] points to an ASCIIZ string with the name of a
  887.              program (and optional command line parameters), the program
  888.              will be executed, and control will pass back to the calling
  889.              program at the termination of the second program.
  890. Returns:     nothing
  891. Uses:        AX
  892. Example:
  893.  
  894. include asm.inc
  895.  
  896. ; I want to go to DOS temporarily to format a 720k disk
  897. extrn   system:proc
  898.  
  899. .data
  900. ; PSP segment is saved here by my startup code
  901. pspseg  dw ?
  902. cmdtail db 'format a: /n:9 /t:80',0
  903.  
  904. .code
  905. ; program fragment assumes DS:@data
  906.         .
  907.         .
  908.         lea     bx,cmdtail    ; DS:[BX] points to command tail
  909.         mov     es,pspseg
  910.         call    system
  911.  
  912.  
  913. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  914.  
  915. USE32K:      limit Hercules equipment to 32k memory (128k on InColor)
  916. USE64K:      allow full 64k on HGC and HGC+ (256k on InColor)
  917. Source:      a$herc.asm
  918.  
  919. Requires Hercules or compatible
  920.  
  921. Call with:   no parameters
  922.              Use32k is equivalent to the Hercules "half" configuration
  923.              Use64k is equivalent to the Hercules "full" configuration
  924.              ASMLIB's default is "half".  Use this configuration if you
  925.              have a 2-monitor system, unless you are using the Hercules
  926.              CGA card. 
  927. Returns:     nothing
  928. Uses:        nothing
  929. Example:     ; in this example I'm determining if a Hercules is installed
  930.              ; and setting the configuration to "full"
  931. extrn  IsHerc:proc
  932. extrn  Use64k:proc
  933. .code
  934.        .
  935.        .
  936.        .
  937.        call  IsHerc
  938.        jc    no_herc
  939.        or    ax,ax
  940.        js    use_only_half   ; use_only_half if HGC is not default monitor
  941.        call  use64k          ; else use all Hercules memory
  942. use_only_half:
  943.  
  944.  
  945. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  946.  
  947. WHICHVGA:    determine if VGAKIT-compatible SuperVGA is installed
  948.              See SVGA16 and SVGA256 in MODE.DOC.
  949. Source:      banks.asm
  950.  
  951. Call with:   no parameters
  952. Returns:     if VGAKIT-compatible Super VGA is installed, AX <> 0.
  953.              if no VGAKIT equipment is installed, AX = 0.
  954. Uses:        AX
  955. Example:     see SVGA16 in MODE.DOC
  956.  
  957.