home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / batutl / battutor.arc / WHAT.ASM < prev    next >
Assembly Source File  |  1983-08-28  |  15KB  |  334 lines

  1.                PAGE 60,132
  2. TITLE  WHAT.COM  VER.2.0  14-AUG-83  19:00
  3. comment *
  4.  
  5.                         WHAT.COM
  6.  
  7.  
  8.         VERSION 2.0     14-AUG-83
  9.  
  10.         Written by      Warren Craycroft
  11.                         6236 Oakdale Ave.
  12.                         Oakland, CA  94605
  13.  
  14.  
  15.         (C)  1983  by Warren Craycroft.  Permission is granted to copy and
  16.         distribute this program, including source code, provided that no
  17.         charge shall be made except for a reasonable charge for the media
  18.         and handling, and that this notice shall remain intact in all copies.
  19.  
  20.  
  21. *
  22. comment *
  23.         This program is a utility that can be used with DOS 2.0 to
  24.         obtain equipment configuration information.  This information
  25.         is passed back from WHAT in the form of a returning
  26.         "errorlevel", and may therefore be tested by appropriate
  27.         IF subcommands in subsequent Batch File lines.
  28.  
  29.         The configuration information is obtained from BIOS from the
  30.         system board switch settings  and from system parameters that
  31.         DOS manages.
  32.  
  33.  
  34.         WHAT is called with one parameter naming the equipment
  35.         to be reported.  Only the first letter of the parameter
  36.         need be entered on the WHAT command line.  The parameters
  37.         are as follows:
  38.  
  39.         D  or   DRIVES          returns the number of valid disk drive letters
  40.                                 of floppy drives and fixed disks. This is the
  41.                                 parameter that is usually patched by virtual
  42.                                 disk enhancement programs.  DOS considers a
  43.                                 one physical drive system to have two valid
  44.                                 virtual drives, so you will get a 2 with this
  45.                                 parameter on such a system.
  46.  
  47.         F  or  FLOPPIES         returns the number of physical diskette drives
  48.                                 that is set on the System Board Switches
  49.                                 With a one physical drive system, you will get
  50.                                 a 1 with this parameter.
  51.  
  52.         V  or   VIDEO           returns:        0  no monitor
  53.                                                 1  40x25, color adaptor
  54.                                                 2  80x25, color adaptor
  55.                                                 3  80x25, either color
  56.                                                    adaptor or monochrome
  57.                                                    adaptor
  58.  
  59.         J  or   JOY adaptor     returns         0  no adaptor present
  60.                                                 1  adaptor present
  61.                                                 (NOT the number of joy STICKS)
  62.  
  63.         P  or   PARALLEL ports  returns number of parallel ports: 0,1,2, ...
  64.  
  65.         S  or   SERIAL ports    returns number of serial ports: 0,1,2, ...
  66.  
  67.         K  or   K blocks        returns number of 4 K memory blocks set on
  68.                                 switches
  69.  
  70.  
  71.         R  or  RELEASE          returns the major release number of the
  72.                                 DOS you are running (e.g. 2 = DOS 2.0)
  73.                                 (returns zero for versions less than 2.0)
  74.  
  75.         M  or  MINOR            returns the minor release number of the
  76.                                 DOS you are running (e.g. 0 = DOS 2.0)
  77.                                 (returns zero for versions less than 2.0)
  78.  
  79.         C  or  CURRENT          returns the current default drive number.
  80.                                 (0 = A:, 1 = B:, etc)
  81.  
  82.  
  83.         If the command line is empty or if the parameter does not begin with
  84.         one of the above letters, an error message is printed and this
  85.         utility halts execution of a Batch File in progress by executing
  86.         a CONTROL-BREAK.
  87. *
  88. ;
  89. ;               constant equates
  90. ;
  91. BEL_CHAR        EQU     07              ;ascii BEL keycode
  92. CR              EQU     0DH             ;ascii carriage return
  93. LF              EQU     0AH             ;ascii line feed
  94. TAB_CHAR        EQU     09              ;ascii tab
  95. BLANK_CHAR      EQU     ' '             ;ascii blank
  96. ;
  97. ;
  98. ;       declare a relocatable segment.  Follow the .COM file requirements
  99. ;       of entry point at 100H and making all seg register references relative
  100. ;       to CS (no relocatable values MOV'ed into segment registers).
  101. ;
  102. ;
  103. COM_CODE      SEGMENT
  104. ;
  105.                 ORG     80H             ;PSP offset 80:  user's command line
  106. PSP_CMD_LINE    LABEL   BYTE            ;define a label for address refs
  107. ;
  108.                 ORG     100H            ;for COM file
  109. ;
  110. ;
  111.                 ASSUME  CS:COM_CODE,DS:COM_CODE    ;tell assembler value of CS
  112.                                                    ; and DS
  113. ;
  114. ;
  115. START           PROC            FAR     ;FAR is meaningless; no RETS
  116. ;
  117.                 SUB     CX,CX                   ;clear CX
  118.                 MOV     CL,PSP_CMD_LINE         ;byte count of line
  119.                 OR      CL,CL                   ;zero?
  120.                 JZ      BAD_PARAM               ;jump if yes, no param
  121.                 SUB     BX,BX                   ;else zero index
  122. ;
  123. ;       find first non-blank or non-tab character of command line
  124. ;
  125. FIND_PARAM:     INC     BX                      ;point to next byte
  126.                 CMP     PSP_CMD_LINE[BX], BLANK_CHAR    ;blank char?
  127.                 JE      LOOP_FIND               ;keep looking if yes
  128.                 CMP     PSP_CMD_LINE[BX], TAB_CHAR      ;tab ?
  129.                 JNE     FOUND_PARAM             ;if not, 1st non blank
  130. LOOP_FIND:      LOOP    FIND_PARAM              ;loop on char count
  131. ;
  132. ;       command line parameter was missing or was not recognized.
  133. ;
  134. ;       display message and return through CONTROL BREAK handler
  135. ;
  136. BAD_PARAM:      MOV     DX,OFFSET ERROR_MESSAGE ;display error message
  137.                 MOV     AH,9                    ;"display string" DOS call
  138.                 INT     21H                     ;call DOS to display message
  139.                 INT     23H                     ;exit through CNTRL BREAK
  140.                 MOV     AH,255                  ;error errorlevel
  141.                 JMP     EXIT                    ;exit through 4CH fn call
  142. ;
  143. ;       else a non-blank character was found in command line.
  144. ;
  145. ;       call INT 11H (because most of following procedures need the
  146. ;       BIOS configuration report; only K blocks of memory request needs
  147. ;       INT 12H.
  148. ;
  149. FOUND_PARAM:    INT     11H                     ;report returned in AX
  150. ;
  151. ;       now search in PARAMS table for the first letter. When matched,
  152. ;       BX pointing to corresponding entries in other tables.  Call
  153. ;       the procedure in PROCEDURES[BX], which will may use mask in
  154. ;       FIELD_MASK[BX] to get bit field, and shift count in
  155. ;       SHIFT_COUNT[BX] to right justify or divide the result of masking.
  156. ;
  157.                 MOV     DL,PSP_CMD_LINE[BX]     ;get the parameter from line
  158.                 MOV     CX,NUMBER_PARAMS        ;get table length for looping
  159.                 SUB     BX,BX                   ;zero index
  160. TABLE_LOOKUP:   CMP     DL,PARAMS[BX]           ;param in left byte of table?
  161.                 JE      DO_PARAM                ;jump if matched
  162.                 CMP     DL,PARAMS[BX+1]         ;else param in right byte?
  163.                 JE      DO_PARAM                ;jump if matched
  164.                 INC     BX                      ;else next table entry
  165.                 INC     BX
  166.                 LOOP    TABLE_LOOKUP            ;loop on table length
  167.                 JMP     BAD_PARAM               ;param not in table
  168. ;
  169. ;       param found.  execute the procedure to prepare the errorlevel
  170. ;       code from the report from INT 11H or INT 12H (report is in AX)
  171. ;
  172. DO_PARAM:       CALL    PROCEDURES[BX]
  173. ;
  174. ;       AL contains the errorlevel, return to DOS
  175. ;
  176. EXIT:           MOV     AH,4CH                  ;"terminate" func call
  177.                 INT     21H                     ;return to DOS with errorlev
  178. START           ENDP
  179. ;
  180. ;*****************************************************************************
  181. ;
  182. ;       procedures to prepare the errorlevel code for the different requests
  183. ;
  184. MASK_SHIFT      PROC    NEAR
  185.                 AND     AX,FIELD_MASK[BX]       ;pass desired bit field
  186.                                                 ;through mask
  187.                 MOV     CX,SHIFT_COUNT[BX]      ;right justify or divide
  188.                 ROR     AX,CL
  189.                 RET                             ;errorlevel in AL
  190. MASK_SHIFT      ENDP
  191. ;
  192. ;
  193. FLOPPIES        PROC    NEAR
  194. ;
  195. ;       returns the number of physcial drives set on switches
  196. ;
  197.                 PUSH    AX                      ;save report
  198.                 ROR     AX,1                    ;shift bit 0 into CY
  199.                 POP     AX                      ;restore report
  200.                 JC      DISKS_PRESENT           ;bit 0 = 1 means disks present
  201.                 SUB     AL,AL                   ;else report zero disks
  202.                 RET
  203. DISKS_PRESENT:  CALL    MASK_SHIFT              ;get 0,1,2, or 3 from report
  204.                 INC     AL
  205.                 RET                             ;return 1,2,3, or 4
  206. FLOPPIES        ENDP
  207. ;
  208. ;
  209. MEMORY          PROC    NEAR
  210. ;
  211. ;       use INT 12H to get 1K blocks, then divide by 4 to get number 4K blocks
  212. ;
  213.                 INT     12H                     ;get memory report
  214.                 CALL    MASK_SHIFT              ;divide by 4
  215.                 RET                             ;4K blocks in AL
  216. MEMORY          ENDP
  217. ;
  218. ;
  219. RELEASE         PROC    NEAR
  220. ;
  221. ;       use DOS fn 30H to get DOS version number.  AL = major,  AH = minor
  222. ;
  223.                 MOV     AH,30H                  ;DOS fn "get version numbers"
  224.                 INT     21H                     ;call DOS to get version
  225.                 CALL    MASK_SHIFT              ;mask_shift has the correct
  226.                                                 ;params for major or minor
  227.                 RET
  228. RELEASE         ENDP
  229. ;
  230. ;
  231. CURRENT         PROC    NEAR
  232. ;
  233. ;       Use DOS fn 19H to get the current default drive number
  234. ;
  235.                 MOV     AH,19H                  ;DOS fn "get current def drive"
  236.                 INT     21H                     ;call DOS to get default drive
  237.                 CALL    MASK_SHIFT              ;mask_shift has the correct
  238.                                                 ;params
  239.                 RET
  240. CURRENT         ENDP
  241. ;
  242. ;
  243. DRIVES          PROC    NEAR
  244. ;
  245. ;       returns the number of valid drives letters for floppies, fixed, and
  246. ;       virtual disks
  247. ;
  248.                 MOV     AH,19H                  ;DOS fn "return current drive"
  249.                 INT     21H                     ;current drive returned in AL
  250.                 MOV     DL,AL                   ;put current in DL for next call
  251.                                                 ;(so we dont disturb current )
  252.                 MOV     AH,0EH                  ;DOS fn "sel disk, return number
  253.                 INT     21H                     ;number of drives retd in AL
  254.                 RET
  255. DRIVES          ENDP
  256. ;*****************************************************************************
  257. ;
  258. ;               tables for parameter execution
  259. ;
  260. ;               total number of parameters (table lengths)
  261. ;
  262. NUMBER_PARAMS   EQU     10              ;all tables have this many entries
  263. ;
  264. ;               FIELD_MASK table
  265. ;
  266. ;       Each equipment request has a mask that passes the bits in the
  267. ;       equipment report word that correspond to the request
  268. ;
  269. FIELD_MASK      DW      00C0H           ;FLOPPIES       bits 7, 6
  270.                 DW      0030H           ;VIDEO          bits 5,4
  271.                 DW      1000H           ;JOY            bit 12
  272.                 DW      0C000H          ;PARALLEL       bits 15,14
  273.                 DW      0E00H           ;SERIAL         bits 11,10,9
  274.                 DW      0FFFFH          ;K MEMORY       pass entire number
  275.                 DW      00FFH           ;RELEASE(MAJOR) pass AL
  276.                 DW      0FF00H          ;MINOR RELEASE  pass AH
  277.                 DW      00FFH           ;CURRENT        pass AL
  278.                 DW      00FFH           ;DRIVES         pass AL
  279. ;
  280. ;               SHIFT_COUNT table
  281. ;
  282. ;       Each different equipment request has a shift count that either
  283. ;       right justifies the bit field passed by the mask or else divides
  284. ;       the number in AX
  285. ;
  286. SHIFT_COUNT     DW      6               ;FLOPPIES
  287.                 DW      4               ;VIDEO
  288.                 DW      12              ;JOY
  289.                 DW      14              ;PARALLELS
  290.                 DW      9               ;SERIALS
  291.                 DW      2               ;K BLOCKS (divide by 4)
  292.                 DW      0               ;RELEASE (MAJOR) NUMBER
  293.                 DW      8               ;MINOR RELEASE NUMBER
  294.                 DW      0               ;CURRENT DRIVE
  295.                 DW      0               ;DRIVES
  296. ;
  297. ;               PARAMS table
  298. ;
  299. ;       contains the legal parameter letters.  a match in this table
  300. ;       points BX to corresponding entries in other tables
  301. ;
  302. PARAMS          DB      'F','f'         ;FLOPPIES
  303.                 DB      'V','v'         ;VIDEO
  304.                 DB      'J','j'         ;JOY
  305.                 DB      'P','p'         ;PARALLEL
  306.                 DB      'S','s'         ;SERIAL
  307.                 DB      'K','k'         ;K BLOCKS
  308.                 DB      'R','r'         ;RELEASE (MAJOR) NUMBER
  309.                 DB      'M','m'         ;MINOR RELEASE NUMBER
  310.                 DB      'C','c'         ;CURRENT DRIVE
  311.                 DB      'D','d'         ;DRIVES
  312. ;
  313. ;               PROCEDURES table
  314. ;
  315. ;       Each equipment request is treated by a procedure called through
  316. ;       this table.
  317. ;
  318. PROCEDURES      DW      FLOPPIES
  319.                 DW      MASK_SHIFT
  320.                 DW      MASK_SHIFT
  321.                 DW      MASK_SHIFT
  322.                 DW      MASK_SHIFT
  323.                 DW      MEMORY
  324.                 DW      RELEASE
  325.                 DW      RELEASE
  326.                 DW      CURRENT
  327.                 DW      DRIVES
  328. ;
  329. ;
  330. ERROR_MESSAGE   DB      CR,LF,BEL_CHAR
  331.                 DB      '****  WHAT cannot recognize parameter ****$'
  332. COM_CODE        ENDS
  333.                 END     START
  334. ╕XÄ╪â∞hÜ╟Fⁿï^ⁿ╤π╤π╕]Ä└&╟ç&╟çâ~ⁿs Fⁿδ█╕P╗`SìQìR║ùÄ┬ìRÜéâ─╕P╗`