home *** CD-ROM | disk | FTP | other *** search
- ;=============================================================================
- ;
- ; The INSTALL program source code, object code, sample script files,
- ; executable program, and documentation are subject to copyright
- ; protection under the laws of the United States and other countries.
- ;
- ; This software is licensed, not sold, and may only be redistributed
- ; in executable format and only in accordance with the provisions of
- ; the INSTALL Source Code License Agreement.
- ;
- ; INSTALL is Copyright(C) 1987-1989 by Knowledge Dynamics Corp
- ; Highway Contract 4 Box 185-H, Canyon Lake, TX (USA) 78133-3508
- ; 512-964-3994 (Voice) 512-964-3958 (24-hr FAX)
- ;
- ; All rights reserved worldwide.
- ;
- ;===============================================================================
- ;
- ;FILENAME:
- ; _getsys.asm
- ;
- ;AUTHOR:
- ; eric jon heflin
- ;
- ;PUBLIC FUNCTIONS:
- ;
- ;LOCAL FUNCTIONS:
- ;
- ;DESCRIPTION:
- ; The purpose of the functions in this file are to determine
- ; information not available to a high-level language under MS-DOS.
- ;
- ; Under OS/2, most of these functions are not applicable, or are
- ; directly available through a API call. The single exception is the
- ; function _cpu_type which is the only function in this file needed
- ; for the OS/2 version.
- ;
- ;REVISION HISTORY:
- ; DATE: AUTHOR: DESCRIPTION OF CHANGES:
- ; 900130 ejh Added OS/2 compatiblility.
- ;
- ;==============================================================================*/
-
- TITLE getsys - copr(c) 1989 Knowledge Dynamics Corp.
- PAGE 66,132
-
- IFNDEF LCODE
- IF1
- err
- %out//////////////////////////////////////////////////////////////////////////////
- %out// You must define the memory model using the "/DLCODE=#" command line //
- %out// argument to either TASM, MASM, or LASM, where # indicates data seg size //
- %out// and is either: //
- %out// 0 for the compact model //
- %out// 1 for the large model //
- %out// //
- %out// For example /DLCODE=0 assembles this file in the compact model, //
- %out// /DLCODE=1 assembles this file in the large model. //
- %out// //
- %out// To assemble this file automatically use the 'make' utility. For //
- %out// Knowledge Dynamics' make, just type 'make'. //
- %out//////////////////////////////////////////////////////////////////////////////
- nowarn
- ENDIF
- ENDIF
-
- IF LCODE EQ 1
- .model large
- ELSE
- .model compact
- ENDIF
-
- IF1
- IF ((@CodeSize EQ 0) AND (@DataSize EQ 0))
- %out _GETSYS.ASM Has Been Assembled In The Small or Tiny Memory Model
- ENDIF
- IF ((@CodeSize EQ 0) AND (@DataSize EQ 1))
- %out _GETSYS.ASM Has Been Assembled In The Compact Memory Model
- ENDIF
- IF ((@CodeSize EQ 1) AND (@DataSize EQ 0))
- %out _GETSYS.ASM Has Been Assembled In The Medium Memory Model
- ENDIF
- IF ((@CodeSize EQ 1) AND (@DataSize EQ 3))
- %out _GETSYS.ASM Has Been Assembled In The Huge Memory Model
- ENDIF
- IF ((@CodeSize EQ 1) AND (@DataSize EQ 1))
- %out _GETSYS.ASM Has Been Assembled In The Large Memory Model
- ENDIF
- ENDIF
-
- if (@CodeSize EQ 1)
- x equ 6
- else
- x equ 4
- endif
-
- sgmnt equ 0
- offst equ 2
-
- if (@DataSize EQ 1) OR (@DataSize EQ 2)
- s_off equ 4
- s_seg equ 6
- len equ 8
- else
- string equ 4
- len equ 6
- endif
-
- IFNDEF OS2_TARGET
-
- ;----------------------------------------------------------------------------
- ;
- ; DESC:
- ; Return EMM status information in three global vars.
- ;
- ; REFERENCES:
- ; Advanced MS-DOS Programming, Ray Duncan.
- ;
- ; RETURNS:
- ; _emm_major = major version number (i.e. 3 or 4 for 3.0 or 4.0)
- ; _emm_minor = minor version number
- ; _emm_total = total number of pages of EMM installed
- ; _emm_avail = total number of pages of EMM available for allocation
- ;
- ;----------------------------------------------------------------------------
-
- emm equ 67h
-
- .data
- public __emm_major
- public __emm_minor
- public __emm_total
- public __emm_avail
-
- __emm_major db ?
- __emm_minor db ?
- __emm_total dw ?
- __emm_avail dw ?
- emm_name db "EMMXXXX0",0 ;EMM device driver name (always)
-
- .code
- public _emm_stat
- _emm_stat proc
- push bp ;Save regs
- mov bp,sp ;set up our stack addressability
- push es
- push si
- push di
- push ds
- push cx
- push dx
- pushf ;save flags (esp. direction flag)
-
- ; assume the worst - no emm
- xor ax,ax
- mov __emm_major,al
- mov __emm_minor,al
- mov __emm_avail,ax
- mov __emm_total,ax
-
- mov al,emm ;EMM int number
- mov ah,35h ;get vector
- int 21h ;ES:0000 = base of EMM
- mov di,10
- ; the following two lines may be needed by some compilers
- ; mov si,seg emm_name
- ; mov ds,si
- mov si,offset emm_name
- mov cx,8 ;length of name
- cld
- repz cmpsb ;compare names
- jnz @@bye ;jmp if no EMM driver
-
- ; now get EMM status
- mov ah,40h
- int 67h
- or ah,ah
- jnz @@bye
-
- ; now get EMM version
- mov ah,46h
- int 67h
- or ah,ah
- jnz @@bye
- mov __emm_minor,al
- and __emm_minor,0fh
- mov ah,al
- shr al,1
- shr al,1
- shr al,1
- shr al,1
- mov __emm_major,al
-
- ; ensure version >= 3.0
- cmp ah,030h
- jb @@bye
-
- ; get total & available 16K pages
- mov ah,42h
- int 67h
- or ah,ah
- jnz @@bye
- mov __emm_total,dx
- mov __emm_avail,bx
- @@bye:
- popf
- pop dx
- pop cx
- pop ds
- pop di
- pop si
- pop es
- pop bp
- ret
- _emm_stat endp
-
- ;----------------------------------------------------------------------------
- ;
- ; DESC:
- ; Return RAM size information in two global vars.
- ;
- ; REFERENCES:
- ; IBM PC Technical Reference Manual.
- ;
- ; RETURNS:
- ; _ram_total = total number of paragraphs of RAM installed
- ; _ram_avail = total paragrpahs of RAM available for allocation
- ;
- ;----------------------------------------------------------------------------
-
- .data
- public __ram_total
- public __ram_avail
-
- __ram_total dw ?
- __ram_avail dw ?
-
- .code
- public _ram_stat
- _ram_stat proc
- push bp ;Save regs
- mov bp,sp ;set up our stack addressability
- push cx
- push dx
-
- xor ax,ax
- int 12h ; get conventional memory size
- mov __ram_total,ax
-
- pop dx
- pop cx
- pop bp
- ret
- _ram_stat endp
-
- ;----------------------------------------------------------------------------
- ;
- ; DESC:
- ; Return RAM size information in two global vars.
- ;
- ; REFERENCES:
- ; IBM PC Technical Reference Manual.
- ;
- ; RETURNS:
- ; _ram_total = total number of paragraphs of RAM installed
- ; _ram_avail = total paragrpahs of RAM available for allocation
- ;
- ;----------------------------------------------------------------------------
- .data
- public __equ_list
- __equ_list dw ?
-
- .code
- public _equ_stat
- _equ_stat proc
- push bp ;Save regs
- mov bp,sp ;set up our stack addressability
- push cx
- push dx
-
- xor ax,ax
- int 11h ; get conventional memory size
- mov __equ_list,ax
-
- pop dx
- pop cx
- pop bp
- ret
- _equ_stat endp
-
-
-
- ;-----------------------------------------------------------------------------
- ;
- ; DESCRIPTION:
- ; This function determines if the BIOS supports extended keyboard
- ; calls.
- ;
- ; RETURNS:
- ; 0 = extended keyboard calls not supported.
- ; >0 = extended keyboard calls supported.
- ;
- ; All regs preserved except AX.
- ;-----------------------------------------------------------------------------
-
- public _kbdtype
- _kbdtype proc
- push bp ; std entry
- mov bp,sp ; set up our stack addressability
-
- push ds ; save used regs
- push es
- push bx
- push cx
- push dx
-
- xor ax,ax ; clear es
- mov es,ax
- mov ah,12h ; ask for extended 'get shift info'
- int 16h ; call BIOS
- cmp al,byte ptr es:[417h] ; see if al agrees with actual status
- jne @@bad ; jmp if al is incorrect
-
- xor byte ptr es:[417h],80h ; change data area
- mov ah,12h ; get extended shift info again
- int 16h
- cmp al,byte ptr es:[417h] ; check al and data area again
- jne @@bad ; jmp al is wrong
- mov ax,1 ; return 1
- jmp short @@good
- @@bad:
- xor ax,ax ; return 0
- @@good:
- xor byte ptr es:[417h],80h ; restore data area
-
- pop dx ; restore regs
- pop cx
- pop bx
- pop es
- pop ds
- pop bp ; std exit
- ret
- _kbdtype endp
-
- ;-----------------------------------------------------------------------------
- ;
- ; DESCRIPTION:
- ; Using safe methods, deterime if NetBIOS is installed.
- ;
- ; RETURNS:
- ; -1 = could not safely determine presence.
- ; 0 = NetBIOS is not present.
- ; >0 = NetBios is present.
- ;
- ; CAUTIONS:
- ; Testing for the presence of NetBIOS can result in a system crash
- ; on IBM-XT class machines if care is not taken. This routine
- ; takes the approach that will result in a return of -1 (unknown)
- ; if it decides that it would be dangerous to use other tests. This
- ; code takes advantage of the BIOS power-on behaviour of initializing
- ; unused interupt vectors in the low-memory table to point to an
- ; IRET instruction. Unfornuately, PC's and XT's uninitilized vectors
- ; point to 0000:0000. If a debugger takes over the NetBIOS interrupt
- ; thus changing the interupt to not point to 0000:0000, there is no
- ; reliable method to determine if the vector is valid withought
- ; crashing the machine. Don't blame Knowledge Dynamics, this
- ; deplorable situation is due to IBM & Microsoft design decisions
- ; made over 10 years ago.
- ;
- ;-----------------------------------------------------------------------------
- public _netbios
- _netbios proc
- push bp ; Save regs
- mov bp,sp ; set up our stack addressability
- push es
- push si
- push di
- push ds
-
- ; first, confirm DOS version supports networks >= 3.1
- mov ah,30h
- int 21h
- cmp ax,301h
- jb @@no_net
-
- ; next, see if a LANA card is installed
- mov ax,0cc00h ; addr of NetBIOS ROM option
- mov es,ax
- cmp byte ptr es:[0],0aah ; look for extended ROM signature
- cmp byte ptr es:[1],55h
- jne @@no_net
-
- ; see if SHARE.EXE is installed by checking multiplex interrupt
-
-
- ; now see if network interrupts point to a reasonable value
- mov ah,35h
- mov al,2ah ; check int 2ah
- int 21h
- mov ax,es
- cmp ax,0
- je @@no_net
- cmp ax,0f000h
- je @@no_net
- mov ah,35h
- mov ah,5ch ; check int 5ch
- int 21h
- mov ax,es
- cmp ax,0
- je @@no_net
- cmp ax,0f000h
- je @@no_net
-
- ; finally, issue a bad NetBIOS call and see if ah is changed
- xor ah,ah
- int 2ah ; set if NetBIOS is loaded
- cmp ah,0 ; if ah == 0, NetBIOS is not loaded
- jne @@no_net
-
- ; if execute gets here, NetBIOS is available
- mov ax,1 ; return present status
- jmp short @@net_ok
-
- @@no_net:
- xor ax,ax ; return not present status
-
- @@net_ok:
- pop ds
- pop di
- pop si
- pop es
- pop bp
- ret
- _netbios endp
-
- ENDIF ; !OS2_TARGET
-
-
- ;-----------------------------------------------------------------------------
- ;
- ; DESC:
- ; Determine CPU class.
- ;
- ; REFERENCES:
- ; Based on COMPAQ DESKPRO 386/20 Technical Reference Guide
- ; (originally suggested by INTEL).
- ;
- ; RETURNS:
- ; AX = CPU type
- ; 0086 if 8088/8086
- ; 0286 if 80286
- ; 0386 if 80386
- ;
- ; All regs preserved except AX.
- ;
- ;-----------------------------------------------------------------------------
- .code
- public _cputype
- _cputype proc
- push bp ; Save regs
- mov bp,sp ; set up our stack addressability
- pushf ;save the real flags register
-
- pop ax ;get register off stack
- push ax ;and save it again
-
- and ax,0fffh ;zero out bits 12-15
- push ax
- popf ;try to put into flags
- pushf
- pop ax ;let's see what came out
- ;of flags
- and ax,0F000h ;mask off bits 12-15
- cmp ax,0F000h ;were these bits all 1's
- je is_86 ;if so, it's an 8086
-
- pop ax ;get flags register to AX
- push ax ;and save it again
-
- or ax,0F000h ;now try to set bits 12-15
- push ax
- popf ;of the flags register
- pushf
- pop ax ;and see what came out
- and ax,0F000h ;are high bits set
- je is_286 ;if so, we have a 386
- is_386: mov ax,0386
- jmp short cpu_exit
-
- is_286: mov ax,0286
- jmp short cpu_exit
-
- is_86: mov ax,86
-
- cpu_exit:
- popf ;restore flags
- pop bp
- ret
- _cputype endp
-
- end
-
- ; end-of-file
-
-