You are on page 1of 11

; DISKMON (c) copyright 1992 Kevin G. Rhoads, all rights reserved.

; This code is copyrighted, all rights reserved except as stated below.


;
; This software is provided "as-is".
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;---------------------------------------------------------------------
;
; Permission to copy and distribute source (DISKMON.asm), binary
; (DISKMON.com) and documentation is
; granted to any individuals or companies who do so in accordance with
; the GNU Public License v 2.0 or later.
;
code_seg segment
assume cs:code_seg,ds:nothing,es:nothing
ORG 100H
entry_point proc near
jmp init
oldtick label dword ;saved vector for int 1cH
oldticko dw ?
oldticks dw ?
;olddisk label dword ;saved vector for int 13h
;olddisko dw ?
;olddisks dw ?
altdisk label dword ;saved vector for int 40h
altdisko dw ?
altdisks dw ?
;
the_count dw 0
max_count dw 09h
hex_dig db '0123456789ABCDEF'
string db ' '
;
ax_save dw ?
bx_save dw ?
cx_save dw ?
dx_save dw ?
ds_save dw ?
es_save dw ?
si_save dw ?
di_save dw ?
bp_save dw ?
ax_savw dw ?
bx_savw dw ?
cx_savw dw ?
dx_savw dw ?
ds_savw dw ?
es_savw dw ?
si_savw dw ?
di_savw dw ?
bp_savw dw ?
it dw ?
cursor dw ?
row db ?
;
;
;INT 40H handler
altd: pushf
call dword ptr altdisk
pushf
mov cs:ax_save,ax
call near ptr bingo
mov cs:the_count,ax
mov ax,cs:ax_save
popf
db 0caH ;retf 2
dw 2
;
;INT 1cH HANDLER
counter label near
cli
mov cs:ax_savw,ax
mov ax,cs:the_count
dec ax
jnz no_bingo
call near ptr bingow
no_bingo label near
mov cs:the_count,ax
mov ax,cs:ax_savw
jmp dword ptr cs:[oldtick]
;
;
bingow label near
mov cs:bx_savw,bx
mov cs:cx_savw,cx
mov cs:dx_savw,dx
mov cs:si_savw,si
mov cs:di_savw,di
mov cs:bp_savw,bp
mov cs:ds_savw,ds
mov cs:es_savw,es
call near ptr bingoc
; restore and exit
mov es,cs:es_savw
mov ds,cs:ds_savw
mov bp,cs:bp_savw
mov di,cs:di_savw
mov si,cs:si_savw
mov dx,cs:dx_savw
mov cx,cs:cx_savw
mov bx,cs:bx_savw
mov ax,cs:max_count
db 0c3h ; rets
;
bingo label near
mov cs:bx_save,bx
mov cs:cx_save,cx
mov cs:dx_save,dx
mov cs:si_save,si
mov cs:di_save,di
mov cs:bp_save,bp
mov cs:ds_save,ds
mov cs:es_save,es
call near ptr bingoc
; restore and exit
mov es,cs:es_save
mov ds,cs:ds_save
mov bp,cs:bp_save
mov di,cs:di_save
mov si,cs:si_save
mov dx,cs:dx_save
mov cx,cs:cx_save
mov bx,cs:bx_save
mov ax,cs:max_count
db 0c3h ; rets
;
bingoc label near
;have saved - set up addressing
mov ax,40h
mov es,ax
assume cs:code_seg,ds:nothing,es:bios_data
push cs
pop ds
assume cs:code_seg,ds:code_seg,es:bios_data
;reset count for next round
mov ax,max_count
mov the_count,ax
;get BIOS DISK data values -- recal status / motor status
mov bx,word ptr es:[3eh]
call convert
mov al,0
mov row,al
call display
; 41/42 diskette status/NEC status byte 1
mov bx,word ptr es:[41h]
call convert
mov al,1
mov row,al
call display
; 43/44 NEC status bytes 2 & 3
mov bx,word ptr es:[43h]
call convert
mov al,2
mov row,al
call display
;now do sectors/track & r/w/v gap
mov ax,0
mov es,ax
les bx,dword ptr es:[78h]
mov bx,word ptr es:[bx+4]
call convert
mov al,3
mov row,al
call display
; restore and exit
assume cs:code_seg,ds:nothing,es:nothing
db 0c3h ; rets
;
assume cs:code_seg,ds:code_seg
convert label near
mov si,offset hex_dig
mov it,bx
and bx,0fH
add bx,si
mov al,byte ptr ds:[bx]
mov string[1],al
mov bx,it
shr bl,1
shr bl,1
shr bl,1
shr bl,1
and bx,0fH
add bx,si
mov al,byte ptr ds:[bx]
mov string,al
mov bx,it
mov bl,bh
mov it,bx
and bx,0fH
add bx,si
mov al,byte ptr ds:[bx]
mov string[4],al
mov bx,it
shr bl,1
shr bl,1
shr bl,1
shr bl,1
and bx,0fH
add bx,si
mov al,byte ptr ds:[bx]
mov string[3],al
db 0c3h ; rets
;
;
display label near
mov ah,3
xor bx,bx
int 10h
mov cursor,dx
mov ah,2
mov bh,0
mov dl,075d
mov dh,row
int 10h
mov ah,10d
mov al,string
mov bx,070
mov cx,1
int 10h
mov ah,2
mov bh,0
mov dl,076d
mov dh,row
int 10h
mov ah,10d
mov al,string[1]
mov bx,070
mov cx,1
int 10h
mov ah,2
mov bh,0
mov dl,077d
mov dh,row
int 10h
mov ah,10d
mov al,string[2]
mov bx,070
mov cx,1
int 10h
mov ah,2
mov bh,0
mov dl,078d
mov dh,row
int 10h
mov ah,10d
mov al,string[3]
mov bx,070
mov cx,1
int 10h
mov ah,2
mov bh,0
mov dl,079d
mov dh,row
int 10h
mov ah,10d
mov al,string[4]
mov bx,070
mov cx,1
int 10h
mov ah,2
xor bx,bx
mov dx,cursor
int 10h
db 0c3h ; rets
;
init label near
assume cs:code_seg,ds:code_seg,es:nothing
xor ax,ax
mov es,ax
assume cs:code_seg,ds:code_seg,es:abs0
les di,dword ptr es:[timertk]
mov word ptr oldticko,di
mov di,es
mov word ptr oldticks,di
xor ax,ax
mov es,ax
les di,dword ptr es:[diskalt]
mov word ptr altdisko,di
mov di,es
mov word ptr altdisks,di
xor ax,ax
mov es,ax
cli
mov ax,offset counter
mov word ptr es:tickoff,ax
mov ax,cs
mov word ptr es:tickseg,ax
mov ax,offset altd
mov word ptr es:altoff,ax
mov ax,cs
mov word ptr es:altseg,ax
mov ax,max_count
mov the_count,ax

mov ah,30h ;DOS 2.0 or higher?


int 21h ; if so close handles 0 .. 4
cmp al,0
je bye_bye ; is DOS 1.x

mov bx,0 ; handle 0


mov ah,3eh ; close
int 21h
mov bx,1 ; handle 1
mov ah,3eh ; close
int 21h
mov bx,2 ; handle 2
mov ah,3eh ; close
int 21h
mov bx,3 ; handle 3
mov ah,3eh ; close
int 21h
mov bx,4 ; handle 4
mov ah,3eh ; close
int 21h
;;
;; mov bx,cs:[2Ch] ; get environment seg from PSP
;; mov es,bx ; and free it
;; mov ah,49h
;; int 21h
;;
mov dx,offset init ;get offset
add dx,0Fh ; will convert bytes to paragraphs
shr dx,1 ; so add 15 to avoid truncation
shr dx,1 ; error then divide by 16, implemented
shr dx,1 ; as four successive 1 bit shifts
shr dx,1
mov ax,3100h ; DOS 2.0+ TSR
int 21h
; if DOS 2.0+ TSR call returns (? how) will fall through to INT 27h
bye_bye label near
sti
mov dx,offset init
int 27h
entry_point endp
code_seg ends
;
;
abs0 segment at 0
org 4ch
romdisk label dword
diskoff dw ?
diskseg label word
org 70h
timertk label dword
tickoff dw ?
tickseg label word
org 78h
dskparm label dword
parmoff dw ?
parmseg label word
org 100h
diskalt label dword
altoff dw ?
altseg label word
abs0 ends
;
bios_data segment at 040h
org 090h
states label word
a_state db ?
b_state db ?
state_ops label word
a_state_op db ?
b_state_op db ?
cylinders label word
a_cyl db ?
b_cyl db ?
bios_data ends
end entry_point

You might also like