home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / SYSUTL / TSRWRK32.ZIP / DEVICES.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-06  |  10.7 KB  |  409 lines

  1. Title    DeviceS.ASM -- Display DOS Device Chain - 22-May-1989 - 03:10
  2.     DOSSEG
  3.     .MODEL  small
  4.     .STACK
  5.     .DATA
  6.  
  7. fail$ DB ' Device Header Chain NOT Found '
  8. flgs DW 4C00h,0,0            ; ErrLvl, Last Drive & RePlaced
  9.  
  10. kind$ DB 'Block'
  11.     db    'Drives'
  12.     db    'ABCDEFGHIJKLMNetWork'    ;+11
  13.     db    'Character'        ;+31
  14.     db    'Replaced'        ;+40
  15.     db    'Mappable Drives'    ;+48
  16.     DB    'System Date/Time'    ;+63
  17.     db    'EMMXXXX0'        ;+79
  18.     db    'Expanded Mem Mgr'
  19.     db    'XMFXXXX0'        ;+103
  20.     db    'HI-MEM'
  21.     db    ' Busy Rpt'        ;+117
  22. newl    DB    13,10,'        $'
  23. hdgm    DB    ' Address Strat Inter Attr Type'
  24.     db    ' Device  Name         Remarks     '    ;+30
  25. Dev  Struc
  26.     DB    'R',63  DUP (32)
  27. Dev    EndS
  28. DevS    Dev    32  DUP (<>)
  29. SZ    Equ    SIZE    Dev
  30.  
  31.     .CODE
  32.  
  33. Main    Proc
  34.     mov    ax,@data        ; Make Data
  35.     mov    DS,ax            ; Addressable
  36.     mov    ax,40h            ; Search Data
  37.     mov    ES,ax            ; Segment of
  38.     xor    di,di            ; DOS for
  39.     mov    al,'C'            ; CON Device
  40. ;v1.1    mov    dl,'O'            ; Segment to
  41. ;v1.1    mov    dh,'N'            ; Store NUL and
  42.     mov    dx,'NO'            ;'ON' backwards            v1.1
  43.     mov    cx,-1            ; Other Devices
  44.     xor    bp,bp            ; Within DevS Array and
  45.     call    DevFind            ; Make Data Addressable by
  46.     mov    ax,@data        ; Extra Segment Register
  47.     mov    ES,ax            ; If DeviceS Found
  48.     jnz    DoHdr            ; Then Display Heading
  49.      mov    byte ptr flgs,1        ; Else Display
  50.      mov    dx,offset fail$        ; Error Message
  51.      mov    cx,31            ; and Exit
  52.      jmp    short Show
  53.  
  54. DoHdr:    mov    dx,offset hdgm        ; Heading
  55.     mov    cx,SZ            ; Line
  56.     call    ShowMsg
  57.     mov    bx,bp            ; Set Limit for Sort by
  58.     xor    bp,bp            ; Ascending Addresses
  59.     call    DevSort
  60. DoDev:    mov    dx,offset DevS        ; Point to DeviceS at
  61.     mov    cx,SZ            ;set line length        v1.1
  62.     add    bp,cx    ;SZ        ; Place Where Unit(s)        v1.1
  63.     add    dx,bp            ; Will be Changed to
  64.     mov    di,dx            ; Disk Drive Letters
  65.     add    di,40
  66. ;v1.1    mov    cx,SZ            ; Set Line Length
  67. Show:    call    ShowMsg            ; If More Lines
  68.     cmp    bp,bx            ; To be Displayed
  69.     jc    DoDev            ; Then Loop for Next
  70. Exit:    mov    ah,9            ; Else End
  71.     mov    dx,offset newl        ; Last Line
  72.     int    21h
  73.     mov    ax,flgs            ; ErrorLevel
  74.     int    21h            ; Exit to DOS
  75. Main    EndP
  76.  
  77. DevSort Proc
  78.     add    bp,SZ            ; If Next Device Level
  79.     mov    dx,bp            ; Is ABOVE the Top Floor
  80.     cmp    bp,bx            ; Then Sorting is Done
  81.     ja    DSexit            ;
  82.  
  83.     mov    cx,8            ; Else If Address
  84.     mov    si,offset DevS        ; Of Device at
  85.     add    si,bp            ; New Level is
  86.     mov    di,si            ; Less Than Next
  87.     add    di,SZ            ; Level Address
  88.     rep    cmpsb
  89.     jc    DevSort            ; Then Advance
  90.  
  91.     mov    cx,SZ            ; Else Copy
  92.     mov    si,offset DevS        ; Next Level
  93.     add    si,bp            ; Device Line
  94.     add    si,cx    ;SZ        ; Into Basement or        v1.1
  95.     mov    di,offset DevS        ; Zero Array Member
  96.     push    si
  97.     rep    movsb
  98.     mov    cx,SZ            ; Copy
  99.     mov    si,offset DevS        ; Current
  100.     add    si,bp            ; Level Into
  101.     pop    di            ; Level Above
  102.     rep    movsb
  103.  
  104.     mov    cx,SZ            ; Complete
  105.     mov    si,offset DevS        ; Swap by
  106.     mov    di,si            ; Copying Zero
  107.     add    di,bp            ; Level to Current
  108.     rep    movsb
  109. DSsink: cmp    bp,SZ            ; If ABOVE Ground Level
  110.     ja    DSdown            ; Then Sink to the Ground
  111. DSdone: mov    bp,dx            ; Else Restore Pre-Sink Level
  112.     jmp    short DevSort        ;  and Resume Sort Ascending
  113.  
  114. DSdown: mov    cx,8            ; Compare the
  115.     mov    di,offset DevS        ; Current Level
  116.     add    di,bp            ; Address With
  117.     mov    si,di            ; Address in
  118.     sub    si,SZ            ; Lower Level
  119.     rep    cmpsb            ; If Current Higher
  120.     jc    DSdone            ; Then Sinking Done
  121.  
  122.     mov    si,offset DevS        ; Else Copy
  123.     mov    di,si            ; Lower Level
  124.     add    si,bp            ; Device Line
  125.     mov    cx,SZ            ;load now            v1.1
  126.     sub    si,cx    ;SZ        ; Into Zero or            v1.1
  127. ;done    mov    cx,SZ            ; Basement Level
  128.     rep    movsb
  129.     mov    di,si            ; Copy Current
  130.     mov    cx,SZ            ;load now            v1.1
  131.     sub    di,cx    ;SZ        ; Into Lower
  132. ;done    mov    cx,SZ
  133.     rep    movsb
  134.  
  135.     mov    si,offset DevS        ; Complete Swap by
  136.     mov    di,si            ; Moving Previous
  137.     add    di,bp            ; From Basement
  138.     mov    cx,SZ            ; Into Current
  139.     sub    bp,cx    ;SZ        ;do now                v1.1
  140.     rep    movsb
  141. ;done    sub    bp,SZ            ; Do Next Lower Level
  142.     jmp    short DSsink        ; Until Ground Level
  143.  
  144. DSexit: Xor    bp,bp            ; Return BP=basement
  145.     ret                ;    and BX=top floor
  146. DevSort EndP
  147.  
  148. DevFind Proc
  149.     repne    scasb            ; If NO "C"
  150.     jcxz    DFexit            ; Then Exit
  151.     jne    DevFind            ; Else If
  152.     cmp    ES:[di],dx        ; NO C"ON"
  153.     jne    DevFind            ; Then Look On
  154.     mov    bx,ES:[di-7]        ; Or If Attribute
  155.     and    bx,801Fh        ; Word Is NOT
  156.     cmp    bx,8013h        ; One for CON
  157.     jne    DevFind            ; Then Look Further
  158.  
  159.     sub    di,11            ; Else Use Next
  160.     mov    ES,ES:[di+2]        ; Device Segment to
  161.     xor    di,di            ; Scan for "NU"L
  162.     mov    ax,'UN'            ; Device Header
  163.  
  164. FNloop: repne    scasw            ; If Search in Vain
  165.     jcxz    DFexit            ; Then Zero Flag Exit
  166.     cmp    byte ptr ES:[di],"L"    ; Else If NOT NU"L"
  167.     jne    FNloop            ; Then Look Some More
  168.     mov    bx,ES:[di-8]        ; Else If Attribute
  169.     and    bx,801Fh        ; Word Is NOT Right
  170.     cmp    bx,8004h        ;  for NUL Device
  171.     jne    FNloop            ; Then Look Some More
  172.  
  173.     push    cx            ; Else Preserve Counter
  174.     sub    di,12            ; Store NUL Data First
  175.  
  176. DFnext: add    bp,SZ            ; Index of Next
  177.     mov    bx,offset DevS        ; Array Member
  178.     Call    DevLine            ; Store Device Data
  179. ;v1.1    mov    bx,ES:[di]        ; Adjust ES:DI to
  180. ;v1.1    mov    ES,ES:[di+2]        ; Next Device Address
  181.     les    bx,dword ptr ES:[di]    ;Adjust ES:DI..            v1.1
  182.                     ;to next device address        v1.1
  183.     mov    di,bx            ; If Next Offset
  184.     cmp    bx,-1            ; Is NOT End of Chain
  185.     jne    DFnext            ; Then Store Next Member
  186.     pop    cx            ; Else Restore Counter
  187. DFexit:
  188. ;v1.1    cmp    cx,0            ; Return NZ If Found
  189.     or    cx,cx            ;v1.1
  190.     ret                ; OR ZR If NOT Found
  191. DevFind EndP
  192.  
  193. DevLine Proc
  194.     mov    ax,ES            ; Store Segment
  195.     add    bx,bp            ; of Next Device
  196.     call    AX2ASCh            ; as HEX Address
  197.     push    di            ; Preserve and
  198.     mov    ax,di            ; Store Offset
  199.     call    AX2ASCh            ; HEX Address
  200.     mov    ax,ES:[di+6]        ; Store Strategy
  201.     call    AX2ASCh            ; Offset HEX Word
  202.     mov    ax,ES:[di+8]        ; Store Interrupt
  203.     call    AX2ASCh            ; Offset HEX Word
  204.     mov    ax,ES:[di+4]
  205.     inc    bx            ; Position for
  206.     mov    dx,ax            ; Attributes
  207.     call    AX2ASCh            ; Storage
  208.     add    di,10            ; If Attribute of
  209.     test    dx,8000h        ; Character Device
  210.     jnz    DoName            ; Then Has a Name
  211.     mov    si,offset kind$        ; Else Copy
  212.     mov    cx,5            ; "Block"
  213.     call    SI2BX            ; Type
  214.     test    ax,1000h        ; If NOT NetWork
  215.     jz    DoDisk            ; Then Is Disk Drive
  216.     add    si,20            ; Else Point Source to
  217.     mov    cx,8            ; Copy "NetWork " to
  218.     add    bx,cx            ; Name Field and
  219.     call    SI2BX            ; End The Record
  220.     jmp    DLdone
  221.  
  222. DoDisk: inc    bx            ; Leave a Space
  223.     mov    al,ES:[di]        ; If Number of
  224.     aam                ; Units is More
  225.     cmp    al,1            ; Than Singular
  226.     mov    cx,6            ; Then "Drives"
  227.     ja    Drives            ; Else Cut to
  228.      dec    cx            ; "Drive"
  229. Drives: push    bx            ; Preserve Destination
  230.     call    SI2BX            ; While Outputting
  231.     pop    bx            ; So As to be Able to
  232.     add    bx,8            ; Find "Name" Location
  233.     mov    [bx],al            ; and Store Unit(s)
  234.     cmp    dx,0840h        ; If NOT OCRM and IOCTL
  235.     jne    DLlily            ; Then NO Remarks
  236.      mov    si,offset kind$+48    ; Else Make
  237.      add    bx,8            ; Remark
  238.      mov    cx,15            ; "Mappable
  239.      call    SI2BX            ;  Drives"
  240. DLlily: jmp    DLdone            ; Lily Pad to Done
  241.  
  242. DoName: mov    si,offset kind$+31    ; Store Type as
  243.     mov    cx,9            ; "Character"
  244.     call    SI2BX
  245.     add    bx,4            ; Adjust Pointer to
  246.     xor    si,si            ; "Name" Zero Offset
  247.     xchg    si,bx            ; Swap Pointers to
  248.     mov    cx,8            ; Copy "dev_Name"
  249. DNloop: mov    al,ES:[di+bx]        ; Put a Name
  250.     mov    DS:[si+bx],al        ; Byte in Data
  251.     inc    bx            ; Advance Index
  252.     loop    DNloop            ; Until 8 Bytes
  253.  
  254.     add    bx,si            ; Point to
  255.     inc    bx            ; "Remarks"
  256.     mov    si,offset kind$+79    ; If "EMMXXXX0"
  257.     push    di            ; Is NOT
  258.     mov    cx,8            ; Name In
  259.     rep    cmpsb            ; Device Line
  260.     pop    di            ; Restored
  261.     jne    HIMEM?            ; Then Check HI-MEM
  262.      jmp    short DLlast        ; Else Copy Remark
  263.  
  264. HIMEM?: mov    si,offset kind$+103    ; If "XMFXXXX0"
  265.     mov    cx,8            ; Is NOT Name
  266.     rep    cmpsb            ; In Device Line
  267.     jne    DLbusy            ; Then Check Busy
  268.      mov    cx,7            ; Else Copy "HI-MEM "
  269.      call    SI2BX            ; Into Remarks
  270. DLbusy: test    dx,2000h        ; If NOT Busy
  271.     jz    DL?CON            ; Then CONorCLK Replaced?
  272.      mov    si,offset kind$+117    ; Else " Busy Rpt"
  273.      mov    cx,9
  274.      call    SI2BX
  275. DL?CON: mov    si,offset kind$+40    ; Pointer to
  276.     mov    cx,8            ; "Replaced"
  277.     cmp    dx,8013h        ; If NOT CON
  278.     jne    DL?CLK            ; Then Clock?
  279.      test    byte ptr flgs+4,3    ; Else If Previous
  280.      jnz    DLrepl            ; Then IS Replaced
  281.       or    byte ptr flgs+4,3    ; Else Flag First
  282.       jmp    short DLdone
  283.  
  284. DL?CLK: cmp    dx,8008h        ; If NOT Clock
  285.     jne    DLdone            ; Then Line Done
  286.     test    byte ptr flgs+5,8    ; Else If Previous
  287.     jnz    DLrepl            ; Then IS Replaced
  288.  
  289.     or    byte ptr flgs+5,8    ; Else Flag System Clock
  290.     mov    si,offset kind$+63
  291. DLlast: mov    cx,16            ; Copy Full Width
  292.     call    SI2BX            ; Remark and Done
  293.     jmp    short DLdone
  294.  
  295. DLrepl: push    cx            ; Remark IS
  296.     call    SI2BX            ; "Replaced"
  297.     mov    si,offset hdgm+30    ; " Device "
  298.     pop    cx
  299.     call    SI2BX
  300. DLdone: pop    di            ; Restore Offset
  301.     ret                ; to Device Header
  302. DevLine EndP
  303.  
  304. SI2BX    Proc
  305.     push    ax
  306. SI2BXl: lodsb                ; Transfer CX
  307.     mov    [bx],al            ; Characters
  308.     inc    bx            ; From [SI] to [BX]
  309.     loop    SI2BXl            ; SI and BX are
  310.     pop    ax            ; Advanced by CX
  311.     ret
  312. SI2BX    EndP
  313.  
  314. AX2ASCh Proc
  315.     push    ax            ; Preserve Value
  316.     mov    al,ah            ; Copy High Byte
  317.     call    AX2HEX            ; Do 2 HEX Digits
  318. ;v1.1    add    bx,2            ; Advance Index
  319.     inc    bx            ;advance index            v1.1
  320.     inc    bx            ;(faster)            v1.1
  321.     pop    ax            ; Restore Value
  322.     call    AX2HEX            ; Do 2 HEX Digits
  323.     add    bx,3            ; Advance Index
  324.     ret
  325. AX2ASCh Endp
  326.  
  327. AX2HEX  Proc
  328.     mov    ah,al            ; Preserve Byte
  329.     mov    cx,4            ; Isolate High
  330.     shr    al,cl            ; Nibble and
  331.     call    AL2HEX            ; Make HEX
  332.     mov    [bx],al            ; Store it
  333.     mov    al,ah            ; Recover Byte
  334.     and    al,0Fh            ; Isolate Low
  335.     call    AL2HEX            ; Nibble to
  336.     mov    [bx+1],al        ; HEX digit
  337.     ret
  338. AX2HEX  EndP
  339.  
  340. AL2HEX  Proc
  341.     add    al,'0'            ; Make ASCII
  342.     cmp    al,'9'            ; If Decimal
  343.     jle    ALexit            ; Then Ok for HEX
  344.      add    al,7            ; Else Make Letter
  345. ALexit: ret
  346.  
  347. AL2HEX  EndP
  348.  
  349. ShowMsg Proc
  350.     push    bx            ; Preserve
  351.     push    cx            ; Counts and
  352.     mov    si,dx            ; Pointer
  353.     mov    dx,offset newl        ; Carriage
  354.     mov    ah,9            ; Return and
  355.     int    21h            ; Line Feed
  356.     pop    cx            ; Restore Count
  357.     cmp    byte ptr [si],' '    ; If a Record
  358.     jne    SMproc            ; Then Process
  359.      mov    bx,09h            ; Else Underline
  360.      jmp    short SMnext
  361.  
  362. SMproc: mov    al,ES:[di]        ; If Byte as a
  363.     cbw                ; Word Value
  364.     cmp    al,' '            ; Is Printable
  365.     jnc    SMblue            ; Then Display
  366.     push    si            ; Else Preserve
  367.     mov    si,flgs+2        ; Pointer While
  368.     add    si,offset kind$+11    ; Up-Date Next
  369.     add    flgs+2,ax        ; Drive Letter
  370.     movsb                ; Replace Unit(s)
  371.     dec    ax            ; If UnitS
  372. ;v1.1    jnz    SMmore            ; Then Show More
  373. ;v1.1     pop    si            ; Else Restore
  374. ;v1.1     jmp    short SMblue        ; Display Pointer
  375.     jz    SMblue1            ;v1.1
  376.  
  377. SMmore: dec    ax            ; Adjust for
  378.     add    si,ax            ; Last Drive
  379.     lodsb                ; Letter and
  380.     mov    ah,' '            ; Put Space
  381.     xchg    ah,al            ; Ahead of it
  382.     push    ax            ; Store
  383.     mov    ah,'-'
  384.     stosw                ; " - " and Last
  385.     pop    ax
  386.     stosw                ; Store Last and
  387. SMblue1:                ;v1.1
  388.     pop    si            ; Restore Pointer
  389. SMblue: mov    bx,1Fh            ; White on Blue
  390.     mov    di,si            ; Adjust Index to
  391.     add    di,SZ            ; Next Record
  392. SMnext: cmp    cx,12h            ; When Down to
  393.     jnc    SMcolr            ; Below 18 Bytes
  394.      mov    bx,4Fh            ; Use White on Red
  395. SMcolr: push    cx            ; Preserve Count
  396.     mov    cx,1            ; While We
  397.     mov    ax,920h            ; Color me
  398.     int    10h            ; "purple"
  399.     pop    cx            ; Restore Count
  400.     mov    ah,0Eh            ; Teletype
  401. SMbyte: lodsb                ; Bytes
  402.     int    10h            ; Until
  403.     loop    SMnext            ; CX done
  404.     pop    bx
  405.     ret
  406. ShowMsg EndP
  407.  
  408.     End    Main
  409.