home *** CD-ROM | disk | FTP | other *** search
-
- ***************************** SYSTEM *************************************
-
- ASMLIB system subroutines Copyright (C) 1991, 1992 Douglas Herr
- all rights reserved
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- BREAKTRAP: initialize Ctrl+Break trap
- BREAKRELEASE:restore previous Ctrl+Break handler
- Source: break.asm
-
- BREAKFLAG: public byte in DGROUP, indicating Ctrl+Break key press
- Source: asmflags.asm
-
- Call with: no parameters
- BreakTrap uses well-behaved methods to trap Ctrl+Break,
- Ctrl+C and Ctrl-Alt-Del key sequences. When one of these
- key combinations is pressed, ASMLIB's break trap sets the
- public flag "breakflag" in the data area. BreakRelease
- de-activates ASMLIB's break trap, restoring the previous
- Ctrl+Break handler. BreakFlag = 0 until a monitored key
- combination is pressed, at which time breakflag is set
- equal to 1. If you use BreakTrap, you MUST call BreakRelease
- before the end of your program, or you will find yourself
- reaching for the Big Red Switch. See STARTUP.ASM.
- Returns: nothing
- Uses: nothing
- Example: see STARTUP.ASM
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- DOSALLOC: allocate memory block from unused DOS memory
- Source: dosalloc.asm
-
- Call with: DX:AX = number of bytes to allocate
- DOSAlloc uses DOS function 48h to allocate memory from free
- DOS memory. See STARTUP.ASM and subroutine ENDPROG.
- Returns: if CF = 0, AX = segment address of start of memory block
- offset of start of memory block = 0
- if CF = 1, insufficient DOS memory space is available.
- Uses: AX, CF; all other flags and registers are saved
- Example:
-
- .model huge
-
- extrn bitblockbytes:proc, dosalloc:proc
-
- .code
- ; this example uses bitblockbytes to calculate the memory required
- ; to save a bit block on a graphics screen
- .
- .
- .
- lea bx,corners ; point to bit block corner coordinates
- call bitblockbytes ; returns DX:AX = number of bytes required
- call dosalloc
- jc no_memory ; do some error handling stuff
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- ENDPROG: determines program's code, static data and stack size
- this is handy for dynamic memory allocation, or for TSR work
- Source: endprog.asm
-
- Call with: no parameters
- Returns: AX = segment address of end of program. See STARTUP.ASM.
- ENDPROG defines ZSEG as the last segment in the program.
- If you add any object modules to ASMLIB.LIB, be certain any
- segments in the added modules are defined before LINK
- encounters ENDPROG. Be sure to review the .MAP file after
- linking.
- Uses: AX
- Example: see STARTUP.ASM
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- EXENAME: determine the full path and filename of the executing program
- Source: exename.asm (strlen.asm)
-
- Call with: ES = PSP segment (see STARTUP.ASM)
- Returns: ES:[BX] pointing to the the name of the executing program,
- including drive and full path, CX = length of the filename.
- The filename returned is an ASCIIZ string, and may be mixed
- upper- and lower-case characters.
- Uses: ES, BX, CX; all other registers and flags are saved.
- Example:
-
- include asm.inc
-
- extrn exename:proc
-
- .data
- extrn pspseg:word
-
- .code
- ; program fragment assumes DS:@data
- .
- .
- .
- mov es,pspseg
- call exename ; string returned at ES:[BX] can be
- ; copied to heap with STRNDUP
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- FINDMONO: detects a monochrome-compatible video card
- this is handy in 2-monitor systems.
- Source: findmono.asm (a$herc.asm, isega.asm, find6845.asm)
-
- Parameters: none
- Returns: if CF = 1, no monochrome monitor
- if CF = 0, AX = monitor code
- 0 = MDA
- 0101h = EGA monochrome
- 0301h = VGA monochrome
- 128 = Hercules or clone
- 144 = Hercules Graphics Card plus
- 208 = Hercules InColor
- Uses: AX, CF
- Supports: MDA, EGA & VGA MONO, HGC, HGC+, InColor
- Example: call findmono
- jc no_monochrome
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- FLOPPIES: determine the number of floppy disk drives intalled
- Source: floppies.asm
-
- Call with: no parameters
- Returns: AX = number of floppy drives
- Uses: AX; all other registers and flags are saved
- Example:
-
- .model medium
-
- public myproc
- extrn floppies:proc
-
- .code
- myproc proc
- .
- call floppies
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- FLOPPYTYPE: determine the number of floppy disk drives intalled
- Source: floptype.asm
-
- Call with: DL = drive number (0 = drive A:)
- Returns: AX = floppy drive type
- 0 = invalid drive number
- 1 = 360k
- 2 = 1.2M
- 3 = 720k
- 4 = 1.44M
- Uses: AX, flags
- Example:
-
- .model medium
-
- public myproc
- extrn floppytype:proc
-
- .data
- drive_number db 0
-
- .code
- myproc proc
- .
- mov dl,drive_number
- call floppytype
- or ax,ax
- jz bad_drive_number
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- GETCPU: detects cpu type
- Source: getcpu.asm
-
- Call with: no parameters
- Returns: AX = 0 if 8086/8088
- AX = 1 if 80186/80188
- AX = 2 if 80286
- AX = 3 if 386 (SX or DX)
- AX = 4 if 486 (SX or DX)
- Uses: AX
- Example: call getcpu
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- GETCRT: determines active monitor type
- Source: getcrt.asm (a$herc.asm, isevga.asm)
-
- Call with: no parameters
- Returns: AX = code for active video system
- CGA = -1
- MDA = 0
- EGA mono = 0100h
- VGA mono = 0300h
- EGA color = 1
- MCGA = 2
- VGA color = 3
- HGC = 128
- HGC+ = 144
- InColor = 208
- Note: GetCRT may be re-assembled with the /DNOHERC switch
- to eliminate code which detects Hercules equipment
- Uses: AX
- Supports: CGA, MCGA, MDA, HGC, HGC+, InColor, EGA, VGA
- Example: call getcrt
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- HALLOC: allocates memory from near heap
- Source: heap.asm
-
- Call with: AX = bytes requested; assumes DS:@data
- heap must be initialized with hinit
- Returns: if space available:
- BX = near pointer for allocated data
- if space not available:
- CF = 1
- Uses: AX, BX, flags
- Example: mov ax,bytes
- call halloc
- jc no_memory ; check to see if there was enough space
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- HFREE: releases heap memory previously allocated
- Source: heap.asm
-
- Call with: BX = near pointer to memory block; assumes DS:@data
- Returns: nothing
- Uses: AX, BX, flags
- Example: mov bx,pointer
- call hfree
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- HINIT: initializes heap manager
- Source: heap.asm
-
- Call with: AX = number of bytes to be managed by heap manager
- 2 <=bytes<= 32767
- BX = near pointer to memory block to be managed
- assumes DS:@data
- Returns: CF = 0 if ok, CF = 1 if bad parameter (bytes too
- small or too large)
- Uses: flags
- Example:
-
- .data
- heap db 32767 dup(0)
-
- .code
- mov ax,@data
- mov ds,ax
- assume ds:@data
- mov ax,32767
- lea bx,heap
- call hinit
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- HMAX: determines largest free block in asmlib's near heap
- Source: heap.asm
-
- Call with: no parameters
- Returns: AX = block size in bytes
- AX = -1 if the heap has not been initialized
- Uses: AX
- Example: call hmax
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- HREALLOC: re-sizes a block of memory in the near heap
- Source: heap.asm
-
- Call with: BX = original pointer to memory block
- AX = new byte size
- Returns: if successful, CF = 0, BX = new block pointer
- if not successful, CF = 1
- Uses: BX, flags
- Example: mov bx,pointer
- mov ax,newsize
- call hrealloc
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- ISANSI: determines if ANSI or compatible is loaded and active
- Source: isansi.asm
-
- Parameters: none
- Returns: CF = 1 if no ANSI device driver loaded and active
- CF = 0 if ANSI loaded and active
- Uses: CF
- Example: call isansi ; let's see if ansi.sys is loaded
- jc no_ansi ; jump if not
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- ISEVGA: determines if an EGA or VGA is installed
- Source: isevga.asm
-
- Call with: no parameters
- Returns: if CF = 1, no EGA or VGA
- if CF = 0
- DX = video memory in kbytes
- AL = monitor type
- AL = -1 if monitor is CGA
- AL = 0 if monitor is monochrome
- AL = 1 if monitor is EGA or better
-
- AH = EGA/VGA flag
- AH = 1 if EGA
- AH = 3 if VGA
-
- Uses: AX, DX, CF
- Example: call isevga
- jc no_evga
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- ISHERC: determines if a Hercules card or compatible is installed
- and if so, determines if it is the active video system.
- Source: isherc.asm (a$herc.asm)
-
- Call with: no parameters
- Returns: if CF = 1, no Hercules or compatible installed
- if CF = 0, AX = Hercules model
- 128 = Hercules Graphics Card or compatible; active
- 144 = Hercules Graphics Card Plus; active
- 208 = Hercules InColor card; active
- -128 = Hercules Graphics Card or compatible; not active
- -144 = Hercules Graphics Card Plus; not active
- -208 = Hercules InColor card; not active
- Uses: AX, CF; all other flags and registers are saved
- Example: call isherc
- jc no_herc
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- ISMOUSE: determines if a mouse is installed
- Source: ismouse.asm (asmflags.asm)
-
- Parameters: none
- Returns: AX = number of mouse buttons
- AX = 0 if no mouse or mouse driver installed
- Uses: AX
- Example:
-
- include asm.inc
-
- .code
- .
- .
- .
- call ismouse
- or ax,ax
- jz no_mouse
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- ISSEVGA: determines if a Super EGA or Super VGA is installed
- Source: issevga.asm
-
- Parameters: none
- Returns: if CF = 1, no Super EGA or Super VGA recognized by ASMLIB
-
- if CF = 0
-
- if AH = 1: (Super EGA)
- AL = 1 if Paradise EGA 480
- AL = 2 if Everex EGA
-
- if AH = 3: (Super VGA)
- AL = 1 if Paradise VGA
- AL = 3 if Tseng VGA chipset
- AL = 4 if Oak VGA
- AL = 5 if Western Digital VGA chipset
-
- See also IsEVGA
- Uses: AX, CF
- Example: call issevga
- jc no_superevga
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- MATHCHIP: determines if 80x87 math coprocessor is installed
- Source: mathchip.asm
-
- Parameters: none
- Returns: AX = code for 80x87 model
- 0 = not installed
- 1 = 8087
- 2 = 287
- 3 = 387 (DX or SX)
- 4 = 487 (486DX or 487SX)
- If the coprocessor is present, it is initilaized by MathChip.
- Uses: AX, all 80x87 registers
- Example: call mathchip
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- MOUSEINIT: initializes mouse driver if mouse present
- Source: mouseini.asm
-
- MOUSEFLAG: public byte in DGROUP indicating mouse buttons
- Source: asmflags.asm
-
- Parameters: assumes DS:@data
- Returns: if mouse installed, ZF = 0 and AX = number of mouse buttons
- also updates mouseflag
- if no mouse, ZF = 1 and AX = 0
- Uses: AX, flags
- Example:
-
- include asm.inc
-
- extrn mouseinit:proc
-
- .code
- ; program fragment assumes DS:@data
- .
- .
- .
- call mouseinit
- jz no_mouse
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- SYSTEM: execute a second copy of COMMAND.COM; optionally runs another
- program.
- Source: system.asm (strlen.asm)
-
- Parameters: ES = PSP segment
- DS:[BX] points to command tail
- if DS:[BX] points to a nul byte, control is transfered
- to the second copy of COMMAND.COM and you get a DOS prompt.
- control is passed back to the calling program when EXIT is
- entered at the DOS prompt.
-
- if DS:[BX] points to an ASCIIZ string with the name of a
- program (and optional command line parameters), the program
- will be executed, and control will pass back to the calling
- program at the termination of the second program.
- Returns: nothing
- Uses: AX
- Example:
-
- include asm.inc
-
- ; I want to go to DOS temporarily to format a 720k disk
- extrn system:proc
-
- .data
- ; PSP segment is saved here by my startup code
- pspseg dw ?
- cmdtail db 'format a: /n:9 /t:80',0
-
- .code
- ; program fragment assumes DS:@data
- .
- .
- lea bx,cmdtail ; DS:[BX] points to command tail
- mov es,pspseg
- call system
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- USE32K: limit Hercules equipment to 32k memory (128k on InColor)
- USE64K: allow full 64k on HGC and HGC+ (256k on InColor)
- Source: a$herc.asm
-
- Requires Hercules or compatible
-
- Call with: no parameters
- Use32k is equivalent to the Hercules "half" configuration
- Use64k is equivalent to the Hercules "full" configuration
- ASMLIB's default is "half". Use this configuration if you
- have a 2-monitor system, unless you are using the Hercules
- CGA card.
- Returns: nothing
- Uses: nothing
- Example: ; in this example I'm determining if a Hercules is installed
- ; and setting the configuration to "full"
- extrn IsHerc:proc
- extrn Use64k:proc
- .code
- .
- .
- .
- call IsHerc
- jc no_herc
- or ax,ax
- js use_only_half ; use_only_half if HGC is not default monitor
- call use64k ; else use all Hercules memory
- use_only_half:
-
-