Documente Academic
Documente Profesional
Documente Cultură
code_seg segment
assume cs:code_seg,ds:nothing,es:nothing
ORG 100H
entry_point proc near
jmp init
even
;olddisk label dword ;saved vector for int 13h
;olddisko dw ?
;olddisks dw ?
altdisk label dword ;saved vector for int 40h
altdisko dw ?
altdisks dw ?
;
established db 00h
;
;number of tracks is 40 for DD and 80 for HD & 3.5" but most DD will do 41 or 42 and most others 82
;
table label near ;format/drive type device assignments for system with A=5.25"HD B=3.5"HD
table0 db 0Fh,54h,05h,1Bh ; 1.2M / 1.2M
table1 db 11h,1Ah,07h,07h ; 1.4M / 1.2M device=c:\dos\driver.sys /d:68 /s:17 /t:82
table2 db 09h,50h,64h,2Ah ; 360k / 1.2M
table3 db 0Ah,1Ah,47h,07h ; 800k / 1.2M device=c:\dos\driver.sys /d:76 /s:10 /t:82
table4 db 09h,50h,83h,2Ah ;*720k / 3.5" or QD device=c:\dos\driver.sys /d:80 /s:09 /t:80 /f:2 *360k / DD device=c:\dos\driver.sys /d:81 /s:09 /t:40 /f:0
table5 db 0Ah,1Ah,87h,07h ;#800k / 3.5" or QD device=c:\dos\driver.sys /d:84 /s:10 /t:82 #400k / DD device=c:\dos\driver.sys /d:85 /s:10 /t:42
table6 db 12h,6Ch,07h,1Bh ;1.44M / 1.44M device=c:\dos\driver.sys /d:88 /s:18 /t:80 /f:7
table7 db 14h,0Ah,07h,03h ;1.67M / 1.44M device=c:\dos\driver.sys /d:92 /s:20 /t:82
table8 db 0ch,1Ah,47h,07h ;!999k / 3.5" or QD device=c:\dos\driver.sys /d:96 /s:12 /t:82 !500k / DD device=c:\dos\driver.sys /d:97 /s:12 /t:42
table9 db 09h,50h,47h,2ah ; 720k / 1.2M device=c:\dos\driver.sys /d:100/s:09 /t:80 /f:2
tablea db 15h,00h,00h,00h ;1.7/ 1.44 device=c:\dos\driver.sys /d:104/s:21 /t:80
tableb db 14h,0Ah,07h,03h ; available | Drive number is 64 + 4*table entry number + 0 for A
tablec db 14h,0Ah,07h,03h ; available | Drive number is 64 + 4*table entry number + 1 for B
tabled db 14h,0Ah,07h,03h ; available ^
tablee db 14h,0Ah,07h,03h ; available | Drive number is 64 + 4*table entry number + 0 for A
tablef db 14h,0Ah,07h,03h ; available | Drive number is 64 + 4*table entry number + 1 for B
;table10 db 14h,0Ah,07h,03h ; available
;table11 db 14h,0Ah,07h,03h ; available
;table12 db 14h,0Ah,07h,03h ; available
;table13 db 14h,0Ah,07h,03h ; available
;table14 db 14h,0Ah,07h,03h ; available
;table15 db 14h,0Ah,07h,03h ; available
;table16 db 14h,0Ah,07h,03h ; available
;table17 db 14h,0Ah,07h,03h ; available
;table18 db 14h,0Ah,07h,03h ; available
;table19 db 14h,0Ah,07h,03h ; available
;table1a db 14h,0Ah,07h,03h ; available
;table1b db 14h,0Ah,07h,03h ; available
;table1c db 14h,0Ah,07h,03h ; available
;table1d db 14h,0Ah,07h,03h ; available
;table1e db 14h,0Ah,07h,03h ; available
;table1f db 14h,0Ah,07h,03h ; available
;
;;
;table label near ;format/drive type device assignments for system with A=5.25"HD B=3.5"HD
;table0 db 0Fh,54h,15h,1Bh ; 1.2M / 1.2M
;table1 db 11h,1Ah,17h,07h ; 1.4M / 1.2M device=c:\dos\driver.sys /d:68 /s:17 /t:82
;table2 db 09h,50h,74h,2Ah ; 360k / 1.2M
;table3 db 0Ah,1Ah,57h,07h ; 800k / 1.2M device=c:\dos\driver.sys /d:76 /s:10 /t:82
;table4 db 09h,50h,93h,2Ah ;*720k / 3.5" or QD device=c:\dos\driver.sys /d:81 /s:09 /t:80 /f:2 *360k / DD device=c:\dos\driver.sys /d:81 /s:09 /t:40 /f:0
;table5 db 0Ah,1Ah,97h,07h ;#800k / 3.5" or QD device=c:\dos\driver.sys /d:85 /s:10 /t:82 #400k / DD device=c:\dos\driver.sys /d:85 /s:10 /t:42
;table6 db 12h,6Ch,17h,1Bh ;1.44M / 1.44M device=c:\dos\driver.sys /d:89 /s:18 /t:80 /f:7
;table7 db 14h,0Ah,17h,03h ;1.67M / 1.44M device=c:\dos\driver.sys /d:93 /s:20 /t:82
;table8 db 0ch,1Ah,57h,07h ;!999k / 3.5" or QD device=c:\dos\driver.sys /d:97 /s:12 /t:82 !500k / DD device=c:\dos\driver.sys /d:97 /s:12 /t:42
;table9 db 09h,50h,57h,2ah ; 720k / 1.2M device=c:\dos\driver.sys /d:100/s:09 /t:80 /f:2
;tablea db 14h,0Ah,17h,03h ; available ^
;tableb db 14h,0Ah,17h,03h ; available | Drive number is 64 + 4*table entry number + 0 for A
;tablec db 14h,0Ah,17h,03h ; available | Drive number is 64 + 4*table entry number + 1 for B
;tabled db 14h,0Ah,17h,03h ; available
;tablee db 14h,0Ah,17h,03h ; available
;tablef db 14h,0Ah,17h,03h ; available
;;table10 db 14h,0Ah,17h,03h ; available
;;table11 db 14h,0Ah,17h,03h ; available
;;table12 db 14h,0Ah,17h,03h ; available
;;table13 db 14h,0Ah,17h,03h ; available
;;table14 db 14h,0Ah,17h,03h ; available
;;table15 db 14h,0Ah,17h,03h ; available
;;table16 db 14h,0Ah,17h,03h ; available
;;table17 db 14h,0Ah,17h,03h ; available
;;table18 db 14h,0Ah,17h,03h ; available
;;table19 db 14h,0Ah,17h,03h ; available
;;table1a db 14h,0Ah,17h,03h ; available
;;table1b db 14h,0Ah,17h,03h ; available
;;table1c db 14h,0Ah,17h,03h ; available
;;table1d db 14h,0Ah,17h,03h ; available
;;table1e db 14h,0Ah,17h,03h ; available
;;table1f db 14h,0Ah,17h,03h ; available
;;
a_save db 0Fh,54h,15h,1Bh ;1.2M
b_save db 12h,6Ch,17h,1Bh ;1.44M
;current_crud db 0Fh,54h,15h,1Bh
;
;
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 ?
it dw ?
;
install_check:
cmp bx,'Fa'
jne pass_it_on
cmp cx,'ke'
jne pass_it_on
cmp dl,7eh
je toggle_established
cmp dl,7fh
jne pass_it_on
bye_bye_:
mov bx,'fA'
mov cx,'KE'
mov ah,01
stc
db 0caH ;retf 2
dw 2
toggle_established:
mov dl,cs:established
xor dl,10h
mov cs:established,dl
jmp bye_bye_
;
;INT 40H handler
altd label near
mov cs:ax_save,ax
cmp ah,10h
jne pass_it_on
jmp install_check
pass_it_on:
call near ptr test_it
mov ax,cs:ax_save
pushf
call dword ptr altdisk
; pushf
; call near ptr post_process
; popf
db 0caH ;retf 2
dw 2
;
test_it label near
mov cs:dx_save,dx
test dl,80H
jz continue1
db 0c3h ; rets -- is hard drive (shouldn't get here)
continue1 label near
; comment out the next three lines if you want to mess with third and fourth floppies
; as well as first and second
; change jz continue2 to jnz continue2 if you want to do third and fourth floppies
; but not first and second
test dl,02H
jz continue2
db 0c3h ; rets -- physical drives 02 or 03 - we don't mess with
;
continue2 label near
test dl,40H
jnz continue3
db 0c3h ; rets -- hasn't our bit flag in drive number
continue3 label near
and dl,7fH
xor dl,40H
mov cs:dx_save,dx
and dl,01h
xchg cs:dx_save,dx
mov cs:ds_save,ds
mov cs:es_save,es
;have saved - set up addressing
mov ax,0
mov es,ax
assume cs:code_seg,ds:nothing,es:abs0
push cs
pop ds
assume cs:code_seg,ds:code_seg,es:abs0
mov bx_save,bx
mov cx_save,cx
mov si_save,si
mov di_save,di
mov bp_save,bp
and dx,03Ch
add dx,offset table
mov si,dx
;
;now do sectors/track
les bx,dword ptr es:[dskparm]
assume cs:code_seg,ds:code_seg,es:nothing
mov cx,word ptr es:[bx+4]
; mov current_crud,cl
mov cl,byte ptr ds:[si]
mov ch,byte ptr ds:[si+3]
cmp ch,byte ptr ds:[si+1]
jb rw_gap_ok
mov ch,byte ptr ds:[si+1]
shr ch,1
shr ch,1
or ch,01h
rw_gap_ok label near
mov word ptr es:[bx+4],cx
;now do format gap
mov cx,word ptr es:[bx+6]
; mov current_crud[1],ch
mov ch,byte ptr ds:[si+1]
mov cl,0ffH
mov word ptr es:[bx+6],cx
;setup addressing for BIOS DISK STATE MACHINE values
mov ax,40h
mov es,ax
assume cs:code_seg,ds:code_seg,es:bios_data
;set BIOS DISK STATE MACHINE values
mov cx,word ptr es:[90h]
mov ax,dx_save
test al,1
je we_do_a
; mov current_crud[2],ch
and ch,10h
or ch,byte ptr ds:[si+2]
or ch,established
; mov b_save[3],1
jmp dsm_all_done
we_do_a label near
; mov current_crud[2],ch
and cl,10h
or cl,byte ptr ds:[si+2]
or cl,established
; mov a_save[3],1
dsm_all_done label near
mov word ptr es:[90h],cx
; restore and exit
assume cs:code_seg,ds:nothing,es:nothing
restore_and_exit label near
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
db 0c3h ; rets
;
;;
;post_process label near
; mov cs:ds_save,ds
; mov cs:es_save,es
;;have saved - set up addressing
; mov ax,0
; mov es,ax
; assume cs:code_seg,ds:nothing,es:abs0
; push cs
; pop ds
; assume cs:code_seg,ds:code_seg,es:abs0
; mov bx_save,bx
; mov cx_save,cx
; mov si_save,si
; mov di_save,di
; mov bp_save,bp
; mov cx,dx_save
; mov dx_save,dx
; les bx,dword ptr es:[dskparm]
; assume cs:code_seg,ds:code_seg,es:bios_data
; test cl,01
; jz do_a
; jmp do_b
;do_a label near
; test a_save[3],1
; jnz restore_a
;save_a label near
; mov cx,word ptr es:[bx+4]
; mov a_save,cl
; mov cx,word ptr es:[bx+6]
; mov a_save[1],ch
;;setup addressing for BIOS DISK STATE MACHINE values
; mov ax,40h
; mov es,ax
; assume cs:code_seg,ds:code_seg,es:bios_data
;;set BIOS DISK STATE MACHINE values
; mov al,byte ptr es:a_state
; mov a_save[2],al
; jmp restore_and_exit
;;
;restore_a label near
; mov cx,word ptr es:[bx+4]
; mov cl,current_crud
; mov a_save,cl
; mov word ptr es:[bx+4],cx
; mov cx,word ptr es:[bx+6]
; mov ch,current_crud[1]
; mov a_save[1],ch
; mov word ptr es:[bx+6],cx
;;setup addressing for BIOS DISK STATE MACHINE values
; mov ax,40h
; mov es,ax
; assume cs:code_seg,ds:code_seg,es:bios_data
; mov al,current_crud[2]
; mov byte ptr es:a_state,al
; mov a_save[2],al
; mov a_save[3],0
; jmp restore_and_exit
;;
;do_b label near
; test b_save[3],1
; jnz restore_b
;save_b label near
; mov cx,word ptr es:[bx+4]
; mov b_save,cl
; mov cx,word ptr es:[bx+6]
; mov b_save[1],ch
;;setup addressing for BIOS DISK STATE MACHINE values
; mov ax,40h
; mov es,ax
; assume cs:code_seg,ds:code_seg,es:bios_data
;;set BIOS DISK STATE MACHINE values
; mov al,byte ptr es:b_state
; mov b_save[2],al
; jmp restore_and_exit
;;
;restore_b label near
; mov cx,word ptr es:[bx+4]
; mov cl,current_crud
; mov b_save,cl
; mov word ptr es:[bx+4],cx
; mov cx,word ptr es:[bx+6]
; mov ch,current_crud[1]
; mov b_save[1],ch
; mov word ptr es:[bx+6],cx
;;setup addressing for BIOS DISK STATE MACHINE values
; mov ax,40h
; mov es,ax
; assume cs:code_seg,ds:code_seg,es:bios_data
; mov al,current_crud[2]
; mov byte ptr es:b_state,al
; mov b_save[2],al
; mov b_save[3],0
; jmp restore_and_exit
;;
;;
;
;
;
init label near
assume cs:code_seg,ds:code_seg,es:nothing
mov bx,'Fa' ;install check, are we already installed?
mov cx,'ke'
mov dl,7fh
mov ah,10h
int 40h
cmp bx,'fA'
jne can_do_install
cmp cx,'KE'
jne can_do_install
push cs
pop ds
lea dx,id_mess
mov ah,9
int 21h
;
mov bx,'Fa' ;we are already installed
mov cx,'ke' ;toggle established state
mov dl,7eh
mov ah,10h
int 40h
mov ah,9
cmp dl,0
jne is_active
lea dx,is_off
jmp display_status
is_active:
lea dx,is_on
display_status:
int 21h
mov ax,4c01h ;
int 21h ; DOS 2+ Exit
int 20h ; DOS 1.x Exit (So?, I'm paranoid.)
can_do_install:
xor ax,ax
mov es,ax
assume cs:code_seg,ds:code_seg,es:abs0
les di,dword ptr es:[diskalt]
mov word ptr altdisko,di
mov di,es
mov word ptr altdisks,di
mov ax,40h
mov es,ax
assume cs:code_seg,ds:code_seg,es:bios_data
mov ax,es:[90h]
mov a_save[2],al
mov b_save[2],ah
xor ax,ax
mov es,ax
assume cs:code_seg,ds:code_seg,es:abs0
les bx,dword ptr es:[dskparm]
mov cx,word ptr es:[bx+4]
mov a_save,ch
mov b_save,ch
mov cx,word ptr es:[bx+6]
mov a_save[1],cl
mov b_save[1],cl
xor ax,ax
mov es,ax
cli
mov ax,offset altd
mov word ptr es:altoff,ax
mov ax,cs
mov word ptr es:altseg,ax
lea dx,sign_on
mov ah,09
int 21h
push cs
pop ds
push cs
pop es
assume cs:code_seg,ds:code_seg,es:code_seg
mov di,0081H ;copy an ID mess to command line buffer
mov si,offset id_mess
mov cx,(offset id_end) - (offset id_mess)
mov byte ptr ds:[080H],cl
cld
rep movsb
code_seg ends
;
;
abs0 segment at 0
abs0 ends
;
;
bios_data segment at 040h
org 090h
a_state db ?
b_state db ?
a_state_op db ?
b_state_op db ?
a_cyl db ?
b_cyl db ?
bios_data ends
end entry_point