home *** CD-ROM | disk | FTP | other *** search
- ;--------------------------------------------------------------------------
- ; Änderungen gegenüber BEISPIEL.A01:
- ;
- ; - Aussagekräftige Namen für Labels vergeben
- ; - Quelltext kommentiert
- ;
- ;--------------------------------------------------------------------------
-
- jmp start
-
- titel_txt:
- db 'DRV V2.00 (C) 1990-1992 Stefan Bion, enter DRV /H for help',0Dh,0Ah,0
-
- help_txt:
- db 'Invocation syntax: DRV [options]',0Dh,0Ah,0Dh,0Ah
-
- db 'options: /H display this help information',0Dh,0Ah
- db ' /P stop after each page',0Dh,0Ah,0Dh,0Ah
-
- db 'DRV sends a listing of the installed device drivers to StdOut.',0Dh,0Ah
- db 'If you redirect the output, option /P has no effect.',0Dh,0Ah,0
-
- header_txt:
- db 0Dh,0Ah
- db ' ┌────────────────── CHR',0Dh,0Ah
- db ' │┌───────────────── IOCTL',0Dh,0Ah
- db ' ││┌──────────────── NONIBM',0Dh,0Ah
- db ' │││┌─────────────── NETWORK',0Dh,0Ah
- db ' ││││┌────────────── OCRM (OPEN DEVICE, CLOSE DEVIVE,',0Dh,0Ah
- db ' │││││ REMOVABLE MEDIA)',0Dh,0Ah
- db ' │││││ ┌───── CLOCK',0Dh,0Ah
- db ' │││││reserved│┌──── NUL',0Dh,0Ah
- db ' │││││ │ ││┌─── STDOUT',0Dh,0Ah
- db ' │││││┌┬┬┴┬┬┬┐│││┌── STDIN',0Dh,0Ah
- db ' ││││││││ ││││││││',0Dh,0Ah
- db ' Header ││││││││ ││││││││ Strategy Interrupt'
- db ' Name',0Dh,0Ah,0Dh,0Ah,0
-
- space3 db ' ',0
- blockdr_txt db ' Blockdr',0Dh,0Ah,0
- driver_name db ' ',0Dh,0Ah,0
-
- h_switch db 0
- p_switch db 0
- max_line db 0
- line_counter db 0Fh
-
- interr_txt db 'Interrupted',0Dh,0Ah,'$'
- key_txt db ' - key -',0Dh,'$'
-
- ;--------------------------------------------------------------------------
- ; Initialisierung
- ;--------------------------------------------------------------------------
- start: push dx ; Titelstring ausgeben
- mov dx,offset titel_txt
- call write_str
- pop dx
- mov ax,2523h ; Int 23h abfangen (^C-Handler)
- mov dx,offset cbreak_handler
- int 21h
-
- push ds ; Anzahl Bildschirmzeilen
- xor ax,ax ; ermitteln (Für Option /P)
- mov ds,ax
- mov al,b[484h]
- pop ds
- mov b[max_line],al
-
- mov si,81h ;'ü' ; Kommandozeile analysieren:
- cld
- l049Ah: lodsb
- cmp al,0Dh
- je l04C0h
- cmp al,2Fh ;'/' ; Schrägstrich leitet Option ein
- jne l049Ah
- lodsb
- cmp al,0Dh
- je l04C0h
- and al,0DFh
-
- cmp al,48h ;'H' ; Option /H
- jne l04B5h
- mov b[h_switch],1
- jmp short l049Ah
-
- l04B5h: cmp al,50h ;'P' ; Option /P
- jne l049Ah
- mov b[p_switch],1
- jmp short l049Ah
-
- l04C0h: cmp b[h_switch],1 ; Optionen auswerten:
- jne l04D4h
- push dx ; /H: Hilfstext ausgeben und
- mov dx,offset help_txt ; Programm beenden
- call write_str
- pop dx
- mov ax,4C00h
- int 21h
-
- l04D4h: push ds ; Feststellen, ob StdOut
- mov bx,34h ;'4' ; umgeleitet ist:
- lds bx,d[bx] ; DS:BX := Adresse Handle-Tabelle
- cmp b[bx+1],1 ; Handle 1 (StdOut) = 1 (CON) ?
- pop ds
- je l04E6h
- mov b[p_switch],0 ; Wenn ja: Option /P ausschalten
-
- ;--------------------------------------------------------------------------
- l04E6h: push dx ; Header des Driver-Listings
- mov dx,offset header_txt ; ausgeben.
- call write_str
- pop dx
-
- mov ah,52h ;'R' ; Adresse des DOS Control Block
- int 21h ; ermitteln
- add bx,22h ;'"' ; Offset 22h: Adresse NUL-Driver
- jae l04FEh
- mov ax,es
- add ax,1000h ; Segmentüberlauf korrigieren
- mov es,ax ; ES:BX := Adresse NUL-Driver
-
- l04FEh: call print_driver ; Daten dieses Drivers ausgeben
- es mov ax,w[bx] ; Adresse des nächsten Drivers:
- cmp ax,-1 ; Wenn FFFFh, dann fertig
- je l0513h
-
- es mov dx,w[bx+2] ; ES:BX := Adresse des folgenden
- mov bx,ax ; Treibers in der Kette
- mov es,dx
- jmp short l04FEh
-
- l0513h: mov ax,4C00h ; Wenn fertig, dann Programmende
- int 21h
-
- ;--------------------------------------------------------------------------
- ; Ausgeben der Treiberdaten mit ES:BX = Treiberadresse
- ;--------------------------------------------------------------------------
- print_driver: mov ax,es ; Headeradresse ES:BX ausgeben
- call write_hex
- mov ah,2
- mov dl,3Ah ;':'
- int 21h
- mov ax,bx
- call write_hex
-
- push dx ; 3 Blanks ausgeben
- mov dx,offset space3
- call write_str
- pop dx
-
- es mov ax,w[bx+4] ; Treiberattribut als
- xchg al,ah ; Binärzahl ausgeben
- call write_bin
- push ax
- mov ah,2
- mov dl,20h ;' '
- int 21h
- pop ax
- xchg al,ah
- call write_bin
-
- push dx ; 3 Blanks ausgeben
- mov dx,offset space3
- call write_str
- pop dx
-
- mov ax,es ; Adresse der Strategie-Routine
- call write_hex ; ausgeben
- mov ah,2
- mov dl,3Ah ;':'
- int 21h
- es mov ax,w[bx+6]
- call write_hex
-
- push dx ; 3 Blanks ausgeben
- mov dx,offset space3
- call write_str
- pop dx
-
- mov ax,es ; Adresse der Interrupt-Routine
- call write_hex ; ausgeben
- mov ah,2
- mov dl,3Ah ;':'
- int 21h
- es mov ax,w[bx+8]
- call write_hex
-
- push dx ; 3 Blanks ausgeben
- mov dx,offset space3
- call write_str
- pop dx
-
- es mov ax,w[bx+4] ; Feststellen, ob Zeichen-
- test ax,8000h ; oder Blocktreiber
- jne l05A0h
-
- es mov al,b[bx+0Ah] ; Blocktreiber:
- xor ah,ah
- call write_dec ; Deren Anzahl ausgeben
- push dx
- mov dx,offset blockdr_txt
- call write_str
- pop dx
- call wait_for_key ; Wenn Bildschirm voll: Warten
- ret
-
- l05A0h: mov di,bx ; Zeichentreiber:
- add di,0Ah ; Treibername in Puffer kopieren
- mov si,offset driver_name
- mov cx,4 ; 8 Bytes (4 Words)
- l05ABh: es mov ax,w[di]
- mov w[si],ax
- inc di,di,si,si
- loop l05ABh
- push dx ; Treibernamen ausgeben
- mov dx,offset driver_name
- call write_str
- pop dx
- call wait_for_key ; Wenn Bildschirm voll: Warten
- ret
-
- ;--------------------------------------------------------------------------
- ; Unterprogramme:
- ;--------------------------------------------------------------------------
- write_str: push ax,si ; Ausgeben eines ASCIIZ-Strings
- mov si,dx ; DX = Offset String
- mov ah,2
- cld
- l05C9h: lodsb
- cmp al,0
- je l05D4h
- mov dl,al
- int 21h
- jmp short l05C9h
-
- l05D4h: pop si,ax
- ret
-
- ;--------------------------------------------------------------------------
- write_dec: push ax,bx,cx,dx ; Dezimalzahl ausgeben
- mov bx,0Ah ; AX = Zahl
- xor cx,cx
- l05E0h: xor dx,dx
- div bx
- add dl,30h ;'0'
- push dx
- inc cx
- or ax,ax
- jne l05E0h
- mov ah,2
- l05EFh: pop dx
- int 21h
- loop l05EFh
- pop dx,cx,bx,ax
- ret
-
- ;--------------------------------------------------------------------------
- write_hex: push ax,bx,cx,dx,si ; Hexzahl ausgeben (4-stellig)
- mov cx,4 ; AX = Zahl
- l0601h: mov si,ax
- and si,0Fh
- mov bl,b[si+hex_digits]
- push bx
- shr ax,1
- shr ax,1
- shr ax,1
- shr ax,1
- loop l0601h
- mov cx,4
- mov ah,2
- l061Ah: pop dx
- int 21h
- loop l061Ah
- pop si,dx,cx,bx,ax
- ret
-
- hex_digits db '0123456789ABCDEF'
-
- ;--------------------------------------------------------------------------
- write_bin: push ax,bx,cx,dx ; Binärzahl ausgeben (8-stellig)
- mov bl,al ; AL = Zahl
- mov cx,8
- mov ah,2
- l0640h: rcl bl,1
- jb l0648h
- mov dl,0F9h
- jmp short l064Ah
- l0648h: mov dl,31h ;'1'
- l064Ah: int 21h
- loop l0640h
- pop dx,cx,bx,ax
- l0652h: ret
-
- ;--------------------------------------------------------------------------
- cbreak_handler: mov ax,cs ; Bei Betätigung von ^C oder
- mov ds,ax ; ^Break Meldung ausgeben und
- mov ah,9 ; Programm beenden
- mov dx,offset interr_txt
- int 21h
- mov ax,4C01h
- int 21h
-
- ;--------------------------------------------------------------------------
- wait_for_key: cmp b[p_switch],0 ; Zeilenzähler erhöhen, wenn
- je l0652h ; Bildschirm voll, dann auf
- inc b[line_counter] ; Tastendruck warten
- mov al,b[line_counter]
- cmp al,b[max_line]
- jb l0652h
- mov b[line_counter],0
- mov ah,9
- mov dx,offset key_txt
- int 21h
- mov ah,8
- int 21h
- ret
-
- ;--------------------------------------------------------------------------
-